From f719a0a63780f1ca440969d2d3e21c092dba3520 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:41:51 -0700 Subject: [PATCH 01/16] fastmod -d stdlib --accept-all '\bUnion\[([\w\.]+), ([\w\.]+)\]' '$1 | $2' --- stdlib/@python2/BaseHTTPServer.pyi | 2 +- stdlib/@python2/SimpleHTTPServer.pyi | 4 +- stdlib/@python2/SocketServer.pyi | 4 +- stdlib/@python2/UserDict.pyi | 2 +- stdlib/@python2/UserList.pyi | 2 +- stdlib/@python2/UserString.pyi | 4 +- stdlib/@python2/__builtin__.pyi | 48 ++++----- stdlib/@python2/_codecs.pyi | 16 +-- stdlib/@python2/_collections.pyi | 2 +- stdlib/@python2/_io.pyi | 6 +- stdlib/@python2/_msi.pyi | 4 +- stdlib/@python2/_osx_support.pyi | 2 +- stdlib/@python2/_socket.pyi | 2 +- stdlib/@python2/_typeshed/__init__.pyi | 2 +- stdlib/@python2/_weakrefset.pyi | 12 +-- stdlib/@python2/_winreg.pyi | 4 +- stdlib/@python2/argparse.pyi | 8 +- stdlib/@python2/array.pyi | 2 +- stdlib/@python2/ast.pyi | 2 +- stdlib/@python2/asynchat.pyi | 4 +- stdlib/@python2/asyncore.pyi | 4 +- stdlib/@python2/base64.pyi | 4 +- stdlib/@python2/bdb.pyi | 4 +- stdlib/@python2/builtins.pyi | 48 ++++----- stdlib/@python2/cProfile.pyi | 8 +- stdlib/@python2/cStringIO.pyi | 4 +- stdlib/@python2/codecs.pyi | 18 ++-- stdlib/@python2/collections.pyi | 4 +- stdlib/@python2/curses/ascii.pyi | 32 +++--- stdlib/@python2/curses/textpad.pyi | 2 +- stdlib/@python2/datetime.pyi | 2 +- stdlib/@python2/dbm/__init__.pyi | 4 +- stdlib/@python2/dbm/dumb.pyi | 4 +- stdlib/@python2/dbm/gnu.pyi | 6 +- stdlib/@python2/dbm/ndbm.pyi | 6 +- stdlib/@python2/decimal.pyi | 4 +- stdlib/@python2/dircache.pyi | 2 +- stdlib/@python2/distutils/cmd.pyi | 2 +- stdlib/@python2/distutils/command/config.pyi | 2 +- stdlib/@python2/distutils/sysconfig.pyi | 2 +- stdlib/@python2/distutils/version.pyi | 8 +- stdlib/@python2/doctest.pyi | 2 +- stdlib/@python2/fcntl.pyi | 4 +- stdlib/@python2/filecmp.pyi | 4 +- stdlib/@python2/fnmatch.pyi | 2 +- stdlib/@python2/fractions.pyi | 38 +++---- stdlib/@python2/ftplib.pyi | 4 +- stdlib/@python2/gettext.pyi | 4 +- stdlib/@python2/glob.pyi | 6 +- stdlib/@python2/imghdr.pyi | 2 +- stdlib/@python2/inspect.pyi | 6 +- stdlib/@python2/json.pyi | 14 +-- stdlib/@python2/lib2to3/pytree.pyi | 2 +- stdlib/@python2/locale.pyi | 2 +- stdlib/@python2/logging/__init__.pyi | 10 +- stdlib/@python2/logging/handlers.pyi | 2 +- stdlib/@python2/macurl2path.pyi | 2 +- stdlib/@python2/mailbox.pyi | 6 +- stdlib/@python2/mailcap.pyi | 2 +- stdlib/@python2/mmap.pyi | 6 +- stdlib/@python2/nntplib.pyi | 4 +- stdlib/@python2/optparse.pyi | 2 +- stdlib/@python2/os/__init__.pyi | 42 ++++---- stdlib/@python2/pickletools.pyi | 2 +- stdlib/@python2/pkgutil.pyi | 4 +- stdlib/@python2/plistlib.pyi | 2 +- stdlib/@python2/popen2.pyi | 2 +- stdlib/@python2/posix.pyi | 4 +- stdlib/@python2/profile.pyi | 6 +- stdlib/@python2/py_compile.pyi | 2 +- stdlib/@python2/pyclbr.pyi | 4 +- stdlib/@python2/pydoc.pyi | 8 +- stdlib/@python2/pyexpat/__init__.pyi | 2 +- stdlib/@python2/re.pyi | 18 ++-- stdlib/@python2/rlcompleter.pyi | 2 +- stdlib/@python2/smtpd.pyi | 6 +- stdlib/@python2/sndhdr.pyi | 2 +- stdlib/@python2/socket.pyi | 10 +- stdlib/@python2/sqlite3/dbapi2.pyi | 6 +- stdlib/@python2/sre_parse.pyi | 8 +- stdlib/@python2/ssl.pyi | 8 +- stdlib/@python2/string.pyi | 4 +- stdlib/@python2/struct.pyi | 2 +- stdlib/@python2/subprocess.pyi | 2 +- stdlib/@python2/sys.pyi | 2 +- stdlib/@python2/tarfile.pyi | 4 +- stdlib/@python2/tempfile.pyi | 26 ++--- stdlib/@python2/termios.pyi | 2 +- stdlib/@python2/time.pyi | 6 +- stdlib/@python2/timeit.pyi | 2 +- stdlib/@python2/trace.pyi | 4 +- stdlib/@python2/turtle.pyi | 6 +- stdlib/@python2/types.pyi | 4 +- stdlib/@python2/typing.pyi | 24 ++--- stdlib/@python2/unicodedata.pyi | 20 ++-- stdlib/@python2/unittest.pyi | 6 +- stdlib/@python2/urllib2.pyi | 8 +- stdlib/@python2/urlparse.pyi | 2 +- stdlib/@python2/uu.pyi | 2 +- stdlib/@python2/warnings.pyi | 8 +- stdlib/@python2/winsound.pyi | 2 +- stdlib/@python2/xml/dom/minidom.pyi | 2 +- stdlib/@python2/xml/etree/ElementInclude.pyi | 4 +- stdlib/@python2/xml/etree/ElementPath.pyi | 2 +- stdlib/@python2/xml/etree/ElementTree.pyi | 12 +-- stdlib/@python2/xml/sax/__init__.pyi | 2 +- stdlib/@python2/xmlrpclib.pyi | 4 +- stdlib/@python2/zipfile.pyi | 2 +- stdlib/@python2/zipimport.pyi | 2 +- stdlib/_codecs.pyi | 12 +-- stdlib/_curses.pyi | 6 +- stdlib/_msi.pyi | 4 +- stdlib/_osx_support.pyi | 2 +- stdlib/_typeshed/__init__.pyi | 2 +- stdlib/_weakrefset.pyi | 12 +-- stdlib/_winapi.pyi | 4 +- stdlib/argparse.pyi | 6 +- stdlib/array.pyi | 2 +- stdlib/ast.pyi | 14 +-- stdlib/asyncio/base_events.pyi | 2 +- stdlib/asyncio/base_subprocess.pyi | 4 +- stdlib/asyncio/events.pyi | 2 +- stdlib/asyncio/format_helpers.pyi | 2 +- stdlib/asyncio/futures.pyi | 2 +- stdlib/asyncio/locks.pyi | 6 +- stdlib/asyncio/streams.pyi | 4 +- stdlib/asyncio/subprocess.pyi | 8 +- stdlib/asyncio/tasks.pyi | 36 +++---- stdlib/asyncio/trsock.pyi | 10 +- stdlib/base64.pyi | 16 +-- stdlib/bdb.pyi | 4 +- stdlib/binascii.pyi | 14 +-- stdlib/builtins.pyi | 94 ++++++++--------- stdlib/bz2.pyi | 8 +- stdlib/cProfile.pyi | 8 +- stdlib/codecs.pyi | 18 ++-- stdlib/collections/__init__.pyi | 30 +++--- stdlib/configparser.pyi | 14 +-- stdlib/contextvars.pyi | 2 +- stdlib/crypt.pyi | 2 +- stdlib/curses/ascii.pyi | 32 +++--- stdlib/curses/textpad.pyi | 2 +- stdlib/dbm/__init__.pyi | 4 +- stdlib/dbm/dumb.pyi | 4 +- stdlib/dbm/gnu.pyi | 6 +- stdlib/dbm/ndbm.pyi | 6 +- stdlib/decimal.pyi | 2 +- stdlib/distutils/cmd.pyi | 2 +- stdlib/distutils/command/config.pyi | 2 +- stdlib/distutils/dist.pyi | 2 +- stdlib/distutils/filelist.pyi | 18 ++-- stdlib/distutils/sysconfig.pyi | 2 +- stdlib/distutils/version.pyi | 16 +-- stdlib/doctest.pyi | 2 +- stdlib/email/_header_value_parser.pyi | 2 +- stdlib/email/header.pyi | 4 +- stdlib/email/headerregistry.pyi | 2 +- stdlib/email/message.pyi | 10 +- stdlib/email/mime/application.pyi | 2 +- stdlib/email/mime/audio.pyi | 2 +- stdlib/email/mime/image.pyi | 2 +- stdlib/email/policy.pyi | 2 +- stdlib/email/utils.pyi | 2 +- stdlib/encodings/__init__.pyi | 2 +- stdlib/enum.pyi | 12 +-- stdlib/filecmp.pyi | 4 +- stdlib/fractions.pyi | 34 +++--- stdlib/ftplib.pyi | 10 +- stdlib/glob.pyi | 2 +- stdlib/gzip.pyi | 8 +- stdlib/http/client.pyi | 2 +- stdlib/http/cookiejar.pyi | 2 +- stdlib/http/server.pyi | 2 +- stdlib/imghdr.pyi | 2 +- stdlib/imp.pyi | 2 +- stdlib/importlib/abc.pyi | 4 +- stdlib/importlib/machinery.pyi | 4 +- stdlib/importlib/resources.pyi | 2 +- stdlib/inspect.pyi | 2 +- stdlib/io.pyi | 6 +- stdlib/ipaddress.pyi | 6 +- stdlib/json/__init__.pyi | 4 +- stdlib/lib2to3/pytree.pyi | 2 +- stdlib/locale.pyi | 2 +- stdlib/logging/__init__.pyi | 4 +- stdlib/logging/handlers.pyi | 2 +- stdlib/lzma.pyi | 2 +- stdlib/macurl2path.pyi | 2 +- stdlib/mailbox.pyi | 6 +- stdlib/mailcap.pyi | 2 +- stdlib/mmap.pyi | 2 +- stdlib/multiprocessing/__init__.pyi | 4 +- stdlib/multiprocessing/context.pyi | 6 +- stdlib/multiprocessing/managers.pyi | 10 +- stdlib/multiprocessing/sharedctypes.pyi | 4 +- stdlib/multiprocessing/synchronize.pyi | 2 +- stdlib/nntplib.pyi | 4 +- stdlib/os/__init__.pyi | 24 ++--- stdlib/pathlib.pyi | 12 +-- stdlib/pickletools.pyi | 2 +- stdlib/pkgutil.pyi | 4 +- stdlib/profile.pyi | 6 +- stdlib/pyclbr.pyi | 6 +- stdlib/pydoc.pyi | 8 +- stdlib/pyexpat/__init__.pyi | 2 +- stdlib/random.pyi | 2 +- stdlib/re.pyi | 6 +- stdlib/shlex.pyi | 4 +- stdlib/shutil.pyi | 4 +- stdlib/signal.pyi | 2 +- stdlib/smtpd.pyi | 6 +- stdlib/smtplib.pyi | 12 +-- stdlib/sndhdr.pyi | 2 +- stdlib/socket.pyi | 6 +- stdlib/socketserver.pyi | 4 +- stdlib/sqlite3/dbapi2.pyi | 6 +- stdlib/sre_constants.pyi | 4 +- stdlib/sre_parse.pyi | 8 +- stdlib/ssl.pyi | 14 +-- stdlib/statistics.pyi | 6 +- stdlib/string.pyi | 4 +- stdlib/struct.pyi | 14 +-- stdlib/subprocess.pyi | 2 +- stdlib/sys.pyi | 2 +- stdlib/tarfile.pyi | 4 +- stdlib/termios.pyi | 2 +- stdlib/time.pyi | 6 +- stdlib/tkinter/__init__.pyi | 104 +++++++++---------- stdlib/tkinter/colorchooser.pyi | 2 +- stdlib/tkinter/ttk.pyi | 36 +++---- stdlib/tokenize.pyi | 4 +- stdlib/trace.pyi | 4 +- stdlib/tracemalloc.pyi | 2 +- stdlib/turtle.pyi | 6 +- stdlib/types.pyi | 8 +- stdlib/typing.pyi | 38 +++---- stdlib/unicodedata.pyi | 20 ++-- stdlib/unittest/case.pyi | 2 +- stdlib/unittest/main.pyi | 2 +- stdlib/unittest/mock.pyi | 4 +- stdlib/unittest/runner.pyi | 2 +- stdlib/unittest/suite.pyi | 2 +- stdlib/urllib/error.pyi | 4 +- stdlib/urllib/parse.pyi | 2 +- stdlib/urllib/request.pyi | 14 +-- stdlib/uu.pyi | 2 +- stdlib/warnings.pyi | 8 +- stdlib/winreg.pyi | 4 +- stdlib/winsound.pyi | 2 +- stdlib/xml/dom/minidom.pyi | 2 +- stdlib/xml/etree/ElementInclude.pyi | 6 +- stdlib/xml/etree/ElementPath.pyi | 2 +- stdlib/xml/etree/ElementTree.pyi | 28 ++--- stdlib/xml/sax/__init__.pyi | 2 +- stdlib/xmlrpc/client.pyi | 2 +- stdlib/xmlrpc/server.pyi | 2 +- stdlib/zipfile.pyi | 12 +-- 257 files changed, 942 insertions(+), 942 deletions(-) diff --git a/stdlib/@python2/BaseHTTPServer.pyi b/stdlib/@python2/BaseHTTPServer.pyi index 28fc4de0409b..b044006f7e74 100644 --- a/stdlib/@python2/BaseHTTPServer.pyi +++ b/stdlib/@python2/BaseHTTPServer.pyi @@ -32,7 +32,7 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler): def send_header(self, keyword: str, value: str) -> 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: ... diff --git a/stdlib/@python2/SimpleHTTPServer.pyi b/stdlib/@python2/SimpleHTTPServer.pyi index 7e62b49e8bc6..198636e1fe6b 100644 --- a/stdlib/@python2/SimpleHTTPServer.pyi +++ b/stdlib/@python2/SimpleHTTPServer.pyi @@ -7,8 +7,8 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): def do_GET(self) -> None: ... def do_HEAD(self) -> None: ... def send_head(self) -> Optional[IO[str]]: ... - def list_directory(self, path: Union[str, unicode]) -> Optional[StringIO[Any]]: ... + def list_directory(self, path: str | unicode) -> Optional[StringIO[Any]]: ... def translate_path(self, path: AnyStr) -> AnyStr: ... def copyfile(self, source: IO[AnyStr], outputfile: IO[AnyStr]): ... - def guess_type(self, path: Union[str, unicode]) -> str: ... + def guess_type(self, path: str | unicode) -> str: ... extensions_map: Mapping[str, str] diff --git a/stdlib/@python2/SocketServer.pyi b/stdlib/@python2/SocketServer.pyi index ca6a31a0f2e1..05805ed29be9 100644 --- a/stdlib/@python2/SocketServer.pyi +++ b/stdlib/@python2/SocketServer.pyi @@ -46,14 +46,14 @@ if sys.platform != "win32": class UnixStreamServer(BaseServer): def __init__( self, - server_address: Union[Text, bytes], + server_address: Text | bytes, RequestHandlerClass: Callable[..., BaseRequestHandler], bind_and_activate: bool = ..., ) -> None: ... class UnixDatagramServer(BaseServer): def __init__( self, - server_address: Union[Text, bytes], + server_address: Text | bytes, RequestHandlerClass: Callable[..., BaseRequestHandler], bind_and_activate: bool = ..., ) -> None: ... diff --git a/stdlib/@python2/UserDict.pyi b/stdlib/@python2/UserDict.pyi index afa07d861a9e..98009d6a84e8 100644 --- a/stdlib/@python2/UserDict.pyi +++ b/stdlib/@python2/UserDict.pyi @@ -35,7 +35,7 @@ class DictMixin(Iterable[_KT], Container[_KT], Sized, Generic[_KT, _VT]): @overload def get(self, k: _KT) -> Optional[_VT]: ... @overload - def get(self, k: _KT, default: Union[_VT, _T]) -> Union[_VT, _T]: ... + def get(self, k: _KT, default: _VT | _T) -> _VT | _T: ... def values(self) -> List[_VT]: ... def items(self) -> List[Tuple[_KT, _VT]]: ... def iterkeys(self) -> Iterator[_KT]: ... diff --git a/stdlib/@python2/UserList.pyi b/stdlib/@python2/UserList.pyi index 0fc2a31b8651..91365373c7d6 100644 --- a/stdlib/@python2/UserList.pyi +++ b/stdlib/@python2/UserList.pyi @@ -10,7 +10,7 @@ class UserList(MutableSequence[_T]): def __setitem__(self, i: int, o: _T) -> None: ... @overload def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ... - def __delitem__(self, i: Union[int, slice]) -> None: ... + def __delitem__(self, i: int | slice) -> None: ... def __len__(self) -> int: ... @overload def __getitem__(self, i: int) -> _T: ... diff --git a/stdlib/@python2/UserString.pyi b/stdlib/@python2/UserString.pyi index 74ab34f6ac69..66c725e2edb7 100644 --- a/stdlib/@python2/UserString.pyi +++ b/stdlib/@python2/UserString.pyi @@ -66,8 +66,8 @@ class MutableString(UserString, MutableSequence[MutableString]): def __getitem__(self: _MST, i: int) -> _MST: ... @overload def __getitem__(self: _MST, s: slice) -> _MST: ... - def __setitem__(self, index: Union[int, slice], sub: Any) -> None: ... - def __delitem__(self, index: Union[int, slice]) -> None: ... + def __setitem__(self, index: int | slice, sub: Any) -> None: ... + def __delitem__(self, index: int | slice) -> None: ... def immutable(self) -> UserString: ... def __iadd__(self: _MST, other: Any) -> _MST: ... def __imul__(self, n: int) -> _MST: ... diff --git a/stdlib/@python2/__builtin__.pyi b/stdlib/@python2/__builtin__.pyi index 0b2c89e8d80c..ff1dfbf0c56d 100644 --- a/stdlib/@python2/__builtin__.pyi +++ b/stdlib/@python2/__builtin__.pyi @@ -353,7 +353,7 @@ class unicode(basestring, Sequence[unicode]): def __ge__(self, x: unicode) -> bool: ... def __len__(self) -> int: ... # The argument type is incompatible with Sequence - def __contains__(self, s: Union[unicode, bytes]) -> bool: ... # type: ignore + def __contains__(self, s: unicode | bytes) -> bool: ... # type: ignore def __iter__(self) -> Iterator[unicode]: ... def __str__(self) -> str: ... def __repr__(self) -> str: ... @@ -437,10 +437,10 @@ class str(Sequence[str], basestring): def zfill(self, __width: int) -> str: ... def __add__(self, s: AnyStr) -> AnyStr: ... # Incompatible with Sequence.__contains__ - def __contains__(self, o: Union[str, Text]) -> bool: ... # type: ignore + def __contains__(self, o: str | Text) -> bool: ... # type: ignore def __eq__(self, x: object) -> bool: ... def __ge__(self, x: Text) -> bool: ... - def __getitem__(self, i: Union[int, slice]) -> str: ... + def __getitem__(self, i: int | slice) -> str: ... def __gt__(self, x: Text) -> bool: ... def __hash__(self) -> int: ... def __iter__(self) -> Iterator[str]: ... @@ -530,14 +530,14 @@ class bytearray(MutableSequence[int], ByteString): def __setitem__(self, i: int, x: int) -> None: ... @overload def __setitem__(self, s: slice, x: Union[Iterable[int], bytes]) -> None: ... - def __delitem__(self, i: Union[int, slice]) -> None: ... + def __delitem__(self, i: int | slice) -> None: ... def __getslice__(self, start: int, stop: int) -> bytearray: ... def __setslice__(self, start: int, stop: int, x: Union[Sequence[int], str]) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... def __add__(self, s: bytes) -> bytearray: ... def __mul__(self, n: int) -> bytearray: ... # Incompatible with Sequence.__contains__ - def __contains__(self, o: Union[int, bytes]) -> bool: ... # type: ignore + def __contains__(self, o: int | bytes) -> bool: ... # type: ignore def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... def __lt__(self, x: bytes) -> bool: ... @@ -662,7 +662,7 @@ class list(MutableSequence[_T], Generic[_T]): def __setitem__(self, i: int, o: _T) -> None: ... @overload def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ... - def __delitem__(self, i: Union[int, slice]) -> None: ... + def __delitem__(self, i: int | slice) -> None: ... def __getslice__(self, start: int, stop: int) -> List[_T]: ... def __setslice__(self, start: int, stop: int, o: Sequence[_T]) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... @@ -743,8 +743,8 @@ 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 __or__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... + def __ior__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... @overload def __sub__(self: Set[str], s: AbstractSet[Optional[Text]]) -> Set[_T]: ... @overload @@ -753,8 +753,8 @@ class set(MutableSet[_T], Generic[_T]): def __isub__(self: Set[str], s: AbstractSet[Optional[Text]]) -> Set[_T]: ... @overload 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 __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: ... @@ -776,9 +776,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: ... @@ -830,7 +830,7 @@ def abs(__x: SupportsAbs[_T]) -> _T: ... def all(__iterable: Iterable[object]) -> bool: ... def any(__iterable: Iterable[object]) -> bool: ... def apply(__func: Callable[..., _T], __args: Optional[Sequence[Any]] = ..., __kwds: Optional[Mapping[str, Any]] = ...) -> _T: ... -def bin(__number: Union[int, _SupportsIndex]) -> str: ... +def bin(__number: int | _SupportsIndex) -> str: ... def callable(__obj: object) -> bool: ... def chr(__i: int) -> str: ... def cmp(__x: Any, __y: Any) -> int: ... @@ -838,7 +838,7 @@ def cmp(__x: Any, __y: Any) -> int: ... _N1 = TypeVar("_N1", bool, int, float, complex) def coerce(__x: _N1, __y: _N1) -> Tuple[_N1, _N1]: ... -def compile(source: Union[Text, mod], filename: Text, mode: Text, flags: int = ..., dont_inherit: int = ...) -> Any: ... +def compile(source: Text | mod, filename: Text, mode: Text, flags: int = ..., dont_inherit: int = ...) -> Any: ... def delattr(__obj: Any, __name: Text) -> None: ... def dir(__o: object = ...) -> List[str]: ... @@ -869,13 +869,13 @@ def getattr(__o: Any, name: Text) -> Any: ... @overload def getattr(__o: Any, name: Text, __default: None) -> Optional[Any]: ... @overload -def getattr(__o: Any, name: Text, __default: bool) -> Union[Any, bool]: ... +def getattr(__o: Any, name: Text, __default: bool) -> Any | bool: ... @overload -def getattr(__o: Any, name: Text, __default: _T) -> Union[Any, _T]: ... +def getattr(__o: Any, name: Text, __default: _T) -> Any | _T: ... def globals() -> Dict[str, Any]: ... def hasattr(__obj: Any, __name: Text) -> bool: ... def hash(__obj: object) -> int: ... -def hex(__number: Union[int, _SupportsIndex]) -> str: ... +def hex(__number: int | _SupportsIndex) -> str: ... def id(__obj: object) -> int: ... def input(__prompt: Any = ...) -> Any: ... def intern(__string: str) -> str: ... @@ -966,10 +966,10 @@ def min(__iterable: Iterable[_T], *, key: Callable[[_T], Any] = ...) -> _T: ... @overload def next(__i: Iterator[_T]) -> _T: ... @overload -def next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... -def oct(__number: Union[int, _SupportsIndex]) -> str: ... -def open(name: Union[unicode, int], mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... -def ord(__c: Union[Text, bytes]) -> int: ... +def next(__i: Iterator[_T], default: _VT) -> _T | _VT: ... +def oct(__number: int | _SupportsIndex) -> str: ... +def open(name: unicode | int, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... +def ord(__c: Text | bytes) -> int: ... # This is only available after from __future__ import print_function. def print( @@ -1021,9 +1021,9 @@ def sorted( __iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Optional[Callable[[_T], Any]] = ..., reverse: bool = ... ) -> List[_T]: ... @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 unichr(__i: int) -> unicode: ... def vars(__object: Any = ...) -> Dict[str, Any]: ... @overload @@ -1071,7 +1071,7 @@ class buffer(Sized): def __init__(self, object: _AnyBuffer, offset: int = ..., size: int = ...) -> None: ... def __add__(self, other: _AnyBuffer) -> str: ... def __cmp__(self, other: _AnyBuffer) -> bool: ... - def __getitem__(self, key: Union[int, slice]) -> str: ... + def __getitem__(self, key: int | slice) -> str: ... def __getslice__(self, i: int, j: int) -> str: ... def __len__(self) -> int: ... def __mul__(self, x: int) -> str: ... diff --git a/stdlib/@python2/_codecs.pyi b/stdlib/@python2/_codecs.pyi index 70f7da857f5a..0a368a71db34 100644 --- a/stdlib/@python2/_codecs.pyi +++ b/stdlib/@python2/_codecs.pyi @@ -4,10 +4,10 @@ from typing import Any, Callable, Dict, Optional, Text, Tuple, Union # For convenience: _Handler = Callable[[Exception], Tuple[Text, int]] -_String = Union[bytes, str] +_String = bytes | str _Errors = Union[str, Text, None] -_Decodable = Union[bytes, Text] -_Encodable = Union[bytes, Text] +_Decodable = bytes | Text +_Encodable = bytes | Text # This type is not exposed; it is defined in unicodeobject.c class _EncodingMap(object): @@ -16,11 +16,11 @@ class _EncodingMap(object): _MapT = Union[Dict[int, int], _EncodingMap] def register(__search_function: Callable[[str], Any]) -> None: ... -def register_error(__errors: Union[str, Text], __handler: _Handler) -> None: ... -def lookup(__encoding: Union[str, Text]) -> codecs.CodecInfo: ... -def lookup_error(__name: Union[str, Text]) -> _Handler: ... -def decode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) -> Any: ... -def encode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) -> Any: ... +def register_error(__errors: str | Text, __handler: _Handler) -> None: ... +def lookup(__encoding: str | Text) -> codecs.CodecInfo: ... +def lookup_error(__name: str | Text) -> _Handler: ... +def decode(obj: Any, encoding: str | Text = ..., errors: _Errors = ...) -> Any: ... +def encode(obj: Any, encoding: str | Text = ..., errors: _Errors = ...) -> Any: ... def charmap_build(__map: Text) -> _MapT: ... def ascii_decode(__data: _Decodable, __errors: _Errors = ...) -> Tuple[Text, int]: ... def ascii_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... diff --git a/stdlib/@python2/_collections.pyi b/stdlib/@python2/_collections.pyi index f97b6d5d6dd1..da1a96b630df 100644 --- a/stdlib/@python2/_collections.pyi +++ b/stdlib/@python2/_collections.pyi @@ -29,7 +29,7 @@ class deque(Generic[_T]): def __contains__(self, o: Any) -> bool: ... def __copy__(self) -> deque[_T]: ... def __getitem__(self, i: int) -> _T: ... - def __iadd__(self, other: deque[_T2]) -> deque[Union[_T, _T2]]: ... + def __iadd__(self, other: deque[_T2]) -> deque[_T | _T2]: ... def __iter__(self) -> Iterator[_T]: ... def __len__(self) -> int: ... def __reversed__(self) -> Iterator[_T]: ... diff --git a/stdlib/@python2/_io.pyi b/stdlib/@python2/_io.pyi index 4eafef332985..23778e445044 100644 --- a/stdlib/@python2/_io.pyi +++ b/stdlib/@python2/_io.pyi @@ -1,7 +1,7 @@ from mmap import mmap from typing import IO, Any, BinaryIO, Iterable, List, Optional, Text, TextIO, Tuple, Type, TypeVar, Union -_bytearray_like = Union[bytearray, mmap] +_bytearray_like = bytearray | mmap DEFAULT_BUFFER_SIZE: int @@ -99,12 +99,12 @@ class _RawIOBase(_IOBase): class FileIO(_RawIOBase, BytesIO): mode: str closefd: bool - def __init__(self, file: Union[str, int], mode: str = ..., closefd: bool = ...) -> None: ... + def __init__(self, file: str | int, mode: str = ..., closefd: bool = ...) -> None: ... def readinto(self, buffer: _bytearray_like) -> int: ... def write(self, pbuf: str) -> int: ... class IncrementalNewlineDecoder(object): - newlines: Union[str, unicode] + newlines: str | unicode def __init__(self, decoder, translate, z=...) -> None: ... def decode(self, input, final) -> Any: ... def getstate(self) -> Tuple[Any, int]: ... diff --git a/stdlib/@python2/_msi.pyi b/stdlib/@python2/_msi.pyi index a8f9c60bbadd..a026d4259c1e 100644 --- a/stdlib/@python2/_msi.pyi +++ b/stdlib/@python2/_msi.pyi @@ -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) -> Optional[str | bytes]: ... 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/@python2/_osx_support.pyi b/stdlib/@python2/_osx_support.pyi index 5d67d996b30a..90d7015bb16e 100644 --- a/stdlib/@python2/_osx_support.pyi +++ b/stdlib/@python2/_osx_support.pyi @@ -30,4 +30,4 @@ def customize_config_vars(_config_vars: Dict[str, str]) -> Dict[str, str]: ... def customize_compiler(_config_vars: Dict[str, str]) -> Dict[str, str]: ... def get_platform_osx( _config_vars: Dict[str, str], osname: _T, release: _K, machine: _V -) -> Tuple[Union[str, _T], Union[str, _K], Union[str, _V]]: ... +) -> Tuple[str | _T, str | _K, str | _V]: ... diff --git a/stdlib/@python2/_socket.pyi b/stdlib/@python2/_socket.pyi index 61c0def50587..5db23583604f 100644 --- a/stdlib/@python2/_socket.pyi +++ b/stdlib/@python2/_socket.pyi @@ -276,6 +276,6 @@ class SocketType(object): @overload def sendto(self, data: str, flags: int, address: Tuple[Any, ...]) -> int: ... def setblocking(self, flag: bool) -> None: ... - def setsockopt(self, level: int, option: int, value: Union[int, str]) -> None: ... + def setsockopt(self, level: int, option: int, value: int | str) -> None: ... def settimeout(self, value: Optional[float]) -> None: ... def shutdown(self, flag: int) -> None: ... diff --git a/stdlib/@python2/_typeshed/__init__.pyi b/stdlib/@python2/_typeshed/__init__.pyi index 9548a2497943..e8f0d708e70f 100644 --- a/stdlib/@python2/_typeshed/__init__.pyi +++ b/stdlib/@python2/_typeshed/__init__.pyi @@ -135,7 +135,7 @@ class HasFileno(Protocol): def fileno(self) -> int: ... FileDescriptor = int -FileDescriptorLike = Union[int, HasFileno] +FileDescriptorLike = int | HasFileno class SupportsRead(Protocol[_T_co]): def read(self, __length: int = ...) -> _T_co: ... diff --git a/stdlib/@python2/_weakrefset.pyi b/stdlib/@python2/_weakrefset.pyi index 99fa3e31166a..bb0a969f4471 100644 --- a/stdlib/@python2/_weakrefset.pyi +++ b/stdlib/@python2/_weakrefset.pyi @@ -16,7 +16,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: ... @@ -32,10 +32,10 @@ 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: ... diff --git a/stdlib/@python2/_winreg.pyi b/stdlib/@python2/_winreg.pyi index 8e729f68720e..25acd52e3d8d 100644 --- a/stdlib/@python2/_winreg.pyi +++ b/stdlib/@python2/_winreg.pyi @@ -1,7 +1,7 @@ from types import TracebackType from typing import Any, Optional, Tuple, Type, Union -_KeyType = Union[HKEYType, int] +_KeyType = HKEYType | int def CloseKey(__hkey: _KeyType) -> None: ... def ConnectRegistry(__computer_name: Optional[str], __key: _KeyType) -> HKEYType: ... @@ -23,7 +23,7 @@ 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: Optional[str], __reserved: Any, __type: int, __value: str | int ) -> None: ... # reserved is ignored def DisableReflectionKey(__key: _KeyType) -> None: ... def EnableReflectionKey(__key: _KeyType) -> None: ... diff --git a/stdlib/@python2/argparse.pyi b/stdlib/@python2/argparse.pyi index a3b5528c4a31..15bad69607d1 100644 --- a/stdlib/@python2/argparse.pyi +++ b/stdlib/@python2/argparse.pyi @@ -23,7 +23,7 @@ _T = TypeVar("_T") _ActionT = TypeVar("_ActionT", bound=Action) _N = TypeVar("_N") -_Text = Union[str, unicode] +_Text = str | unicode ONE_OR_MORE: str OPTIONAL: str @@ -69,7 +69,7 @@ class _ActionsContainer: self, *name_or_flags: Text, action: Union[Text, Type[Action]] = ..., - nargs: Union[int, Text] = ..., + nargs: int | Text = ..., const: Any = ..., default: Any = ..., type: Union[Callable[[Text], _T], Callable[[str], _T], FileType] = ..., @@ -228,7 +228,7 @@ class ArgumentDefaultsHelpFormatter(HelpFormatter): ... class Action(_AttributeHolder): option_strings: Sequence[_Text] dest: _Text - nargs: Optional[Union[int, _Text]] + nargs: Optional[int | _Text] const: Any default: Any type: Union[Callable[[str], Any], FileType, None] @@ -240,7 +240,7 @@ class Action(_AttributeHolder): self, option_strings: Sequence[Text], dest: Text, - nargs: Optional[Union[int, Text]] = ..., + nargs: Optional[int | Text] = ..., const: Optional[_T] = ..., default: Union[_T, str, None] = ..., type: Optional[Union[Callable[[Text], _T], Callable[[str], _T], FileType]] = ..., diff --git a/stdlib/@python2/array.pyi b/stdlib/@python2/array.pyi index a93742f85412..76b35956a4db 100644 --- a/stdlib/@python2/array.pyi +++ b/stdlib/@python2/array.pyi @@ -48,7 +48,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/@python2/ast.pyi b/stdlib/@python2/ast.pyi index a8432dd85978..c04cecac6738 100644 --- a/stdlib/@python2/ast.pyi +++ b/stdlib/@python2/ast.pyi @@ -9,7 +9,7 @@ from typing import Any, Iterator, Optional, Union from _ast import * from _ast import AST, Module -def parse(source: Union[str, unicode], filename: Union[str, unicode] = ..., mode: Union[str, unicode] = ...) -> Module: ... +def parse(source: str | unicode, filename: str | unicode = ..., mode: str | unicode = ...) -> Module: ... 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: ... diff --git a/stdlib/@python2/asynchat.pyi b/stdlib/@python2/asynchat.pyi index 464eb42bad52..ec548a417cfb 100644 --- a/stdlib/@python2/asynchat.pyi +++ b/stdlib/@python2/asynchat.pyi @@ -29,9 +29,9 @@ class async_chat(asyncore.dispatcher): def discard_buffers(self) -> None: ... class fifo: - def __init__(self, list: Sequence[Union[bytes, simple_producer]] = ...) -> None: ... + def __init__(self, list: Sequence[bytes | simple_producer] = ...) -> None: ... def __len__(self) -> int: ... def is_empty(self) -> bool: ... def first(self) -> bytes: ... - def push(self, data: Union[bytes, simple_producer]) -> None: ... + def push(self, data: bytes | simple_producer) -> None: ... def pop(self) -> Tuple[int, bytes]: ... diff --git a/stdlib/@python2/asyncore.pyi b/stdlib/@python2/asyncore.pyi index be551a040cc1..9c1d6e8e6aa4 100644 --- a/stdlib/@python2/asyncore.pyi +++ b/stdlib/@python2/asyncore.pyi @@ -85,8 +85,8 @@ class dispatcher: def sendall(self, data: bytes, flags: int = ...) -> None: ... def sendto(self, data: bytes, address: Union[Tuple[str, int], str], flags: int = ...) -> int: ... def setblocking(self, flag: bool) -> None: ... - def settimeout(self, value: Union[float, None]) -> None: ... - def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... + def settimeout(self, value: float | None) -> None: ... + def setsockopt(self, level: int, optname: int, value: int | bytes) -> None: ... def shutdown(self, how: int) -> None: ... class dispatcher_with_send(dispatcher): diff --git a/stdlib/@python2/base64.pyi b/stdlib/@python2/base64.pyi index 05c3ec319f38..3c10133f87d2 100644 --- a/stdlib/@python2/base64.pyi +++ b/stdlib/@python2/base64.pyi @@ -1,7 +1,7 @@ from typing import IO, Optional, Union -_encodable = Union[bytes, unicode] -_decodable = Union[bytes, unicode] +_encodable = bytes | unicode +_decodable = bytes | unicode def b64encode(s: _encodable, altchars: Optional[bytes] = ...) -> bytes: ... def b64decode(s: _decodable, altchars: Optional[bytes] = ..., validate: bool = ...) -> bytes: ... diff --git a/stdlib/@python2/bdb.pyi b/stdlib/@python2/bdb.pyi index 9d76b3afde22..7a586b0666fd 100644 --- a/stdlib/@python2/bdb.pyi +++ b/stdlib/@python2/bdb.pyi @@ -59,11 +59,11 @@ class Bdb: def get_stack(self, f: Optional[FrameType], t: Optional[TracebackType]) -> 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: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ... ) -> None: ... def runeval(self, expr: str, globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ...) -> None: ... def runctx( - self, cmd: Union[str, CodeType], globals: Optional[Dict[str, Any]], locals: Optional[Mapping[str, Any]] + self, cmd: str | CodeType, globals: Optional[Dict[str, Any]], locals: Optional[Mapping[str, Any]] ) -> None: ... def runcall(self, __func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ... diff --git a/stdlib/@python2/builtins.pyi b/stdlib/@python2/builtins.pyi index 0b2c89e8d80c..ff1dfbf0c56d 100644 --- a/stdlib/@python2/builtins.pyi +++ b/stdlib/@python2/builtins.pyi @@ -353,7 +353,7 @@ class unicode(basestring, Sequence[unicode]): def __ge__(self, x: unicode) -> bool: ... def __len__(self) -> int: ... # The argument type is incompatible with Sequence - def __contains__(self, s: Union[unicode, bytes]) -> bool: ... # type: ignore + def __contains__(self, s: unicode | bytes) -> bool: ... # type: ignore def __iter__(self) -> Iterator[unicode]: ... def __str__(self) -> str: ... def __repr__(self) -> str: ... @@ -437,10 +437,10 @@ class str(Sequence[str], basestring): def zfill(self, __width: int) -> str: ... def __add__(self, s: AnyStr) -> AnyStr: ... # Incompatible with Sequence.__contains__ - def __contains__(self, o: Union[str, Text]) -> bool: ... # type: ignore + def __contains__(self, o: str | Text) -> bool: ... # type: ignore def __eq__(self, x: object) -> bool: ... def __ge__(self, x: Text) -> bool: ... - def __getitem__(self, i: Union[int, slice]) -> str: ... + def __getitem__(self, i: int | slice) -> str: ... def __gt__(self, x: Text) -> bool: ... def __hash__(self) -> int: ... def __iter__(self) -> Iterator[str]: ... @@ -530,14 +530,14 @@ class bytearray(MutableSequence[int], ByteString): def __setitem__(self, i: int, x: int) -> None: ... @overload def __setitem__(self, s: slice, x: Union[Iterable[int], bytes]) -> None: ... - def __delitem__(self, i: Union[int, slice]) -> None: ... + def __delitem__(self, i: int | slice) -> None: ... def __getslice__(self, start: int, stop: int) -> bytearray: ... def __setslice__(self, start: int, stop: int, x: Union[Sequence[int], str]) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... def __add__(self, s: bytes) -> bytearray: ... def __mul__(self, n: int) -> bytearray: ... # Incompatible with Sequence.__contains__ - def __contains__(self, o: Union[int, bytes]) -> bool: ... # type: ignore + def __contains__(self, o: int | bytes) -> bool: ... # type: ignore def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... def __lt__(self, x: bytes) -> bool: ... @@ -662,7 +662,7 @@ class list(MutableSequence[_T], Generic[_T]): def __setitem__(self, i: int, o: _T) -> None: ... @overload def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ... - def __delitem__(self, i: Union[int, slice]) -> None: ... + def __delitem__(self, i: int | slice) -> None: ... def __getslice__(self, start: int, stop: int) -> List[_T]: ... def __setslice__(self, start: int, stop: int, o: Sequence[_T]) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... @@ -743,8 +743,8 @@ 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 __or__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... + def __ior__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... @overload def __sub__(self: Set[str], s: AbstractSet[Optional[Text]]) -> Set[_T]: ... @overload @@ -753,8 +753,8 @@ class set(MutableSet[_T], Generic[_T]): def __isub__(self: Set[str], s: AbstractSet[Optional[Text]]) -> Set[_T]: ... @overload 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 __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: ... @@ -776,9 +776,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: ... @@ -830,7 +830,7 @@ def abs(__x: SupportsAbs[_T]) -> _T: ... def all(__iterable: Iterable[object]) -> bool: ... def any(__iterable: Iterable[object]) -> bool: ... def apply(__func: Callable[..., _T], __args: Optional[Sequence[Any]] = ..., __kwds: Optional[Mapping[str, Any]] = ...) -> _T: ... -def bin(__number: Union[int, _SupportsIndex]) -> str: ... +def bin(__number: int | _SupportsIndex) -> str: ... def callable(__obj: object) -> bool: ... def chr(__i: int) -> str: ... def cmp(__x: Any, __y: Any) -> int: ... @@ -838,7 +838,7 @@ def cmp(__x: Any, __y: Any) -> int: ... _N1 = TypeVar("_N1", bool, int, float, complex) def coerce(__x: _N1, __y: _N1) -> Tuple[_N1, _N1]: ... -def compile(source: Union[Text, mod], filename: Text, mode: Text, flags: int = ..., dont_inherit: int = ...) -> Any: ... +def compile(source: Text | mod, filename: Text, mode: Text, flags: int = ..., dont_inherit: int = ...) -> Any: ... def delattr(__obj: Any, __name: Text) -> None: ... def dir(__o: object = ...) -> List[str]: ... @@ -869,13 +869,13 @@ def getattr(__o: Any, name: Text) -> Any: ... @overload def getattr(__o: Any, name: Text, __default: None) -> Optional[Any]: ... @overload -def getattr(__o: Any, name: Text, __default: bool) -> Union[Any, bool]: ... +def getattr(__o: Any, name: Text, __default: bool) -> Any | bool: ... @overload -def getattr(__o: Any, name: Text, __default: _T) -> Union[Any, _T]: ... +def getattr(__o: Any, name: Text, __default: _T) -> Any | _T: ... def globals() -> Dict[str, Any]: ... def hasattr(__obj: Any, __name: Text) -> bool: ... def hash(__obj: object) -> int: ... -def hex(__number: Union[int, _SupportsIndex]) -> str: ... +def hex(__number: int | _SupportsIndex) -> str: ... def id(__obj: object) -> int: ... def input(__prompt: Any = ...) -> Any: ... def intern(__string: str) -> str: ... @@ -966,10 +966,10 @@ def min(__iterable: Iterable[_T], *, key: Callable[[_T], Any] = ...) -> _T: ... @overload def next(__i: Iterator[_T]) -> _T: ... @overload -def next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... -def oct(__number: Union[int, _SupportsIndex]) -> str: ... -def open(name: Union[unicode, int], mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... -def ord(__c: Union[Text, bytes]) -> int: ... +def next(__i: Iterator[_T], default: _VT) -> _T | _VT: ... +def oct(__number: int | _SupportsIndex) -> str: ... +def open(name: unicode | int, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... +def ord(__c: Text | bytes) -> int: ... # This is only available after from __future__ import print_function. def print( @@ -1021,9 +1021,9 @@ def sorted( __iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Optional[Callable[[_T], Any]] = ..., reverse: bool = ... ) -> List[_T]: ... @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 unichr(__i: int) -> unicode: ... def vars(__object: Any = ...) -> Dict[str, Any]: ... @overload @@ -1071,7 +1071,7 @@ class buffer(Sized): def __init__(self, object: _AnyBuffer, offset: int = ..., size: int = ...) -> None: ... def __add__(self, other: _AnyBuffer) -> str: ... def __cmp__(self, other: _AnyBuffer) -> bool: ... - def __getitem__(self, key: Union[int, slice]) -> str: ... + def __getitem__(self, key: int | slice) -> str: ... def __getslice__(self, i: int, j: int) -> str: ... def __len__(self) -> int: ... def __mul__(self, x: int) -> str: ... diff --git a/stdlib/@python2/cProfile.pyi b/stdlib/@python2/cProfile.pyi index 0cc2e94986fc..dda463a35eab 100644 --- a/stdlib/@python2/cProfile.pyi +++ b/stdlib/@python2/cProfile.pyi @@ -1,9 +1,9 @@ from types import CodeType from typing import Any, Callable, Dict, Optional, Text, Tuple, TypeVar, Union -def run(statement: str, filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ... +def run(statement: str, filename: Optional[str] = ..., 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: Optional[str] = ..., sort: str | int = ... ) -> None: ... _SelfT = TypeVar("_SelfT", bound=Profile) @@ -17,7 +17,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: Text) -> None: ... def create_stats(self) -> None: ... def snapshot_stats(self) -> None: ... @@ -25,4 +25,4 @@ class Profile: def runctx(self: _SelfT, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> _SelfT: ... def runcall(self, __func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... -def label(code: Union[str, CodeType]) -> _Label: ... # undocumented +def label(code: str | CodeType) -> _Label: ... # undocumented diff --git a/stdlib/@python2/cStringIO.pyi b/stdlib/@python2/cStringIO.pyi index 8518625fc1df..3701e6e1d4f7 100644 --- a/stdlib/@python2/cStringIO.pyi +++ b/stdlib/@python2/cStringIO.pyi @@ -38,8 +38,8 @@ class OutputType(IO[str], Iterator[str], metaclass=ABCMeta): def __iter__(self) -> OutputType: ... def next(self) -> str: ... def reset(self) -> None: ... - def write(self, b: Union[str, unicode]) -> int: ... - def writelines(self, lines: Iterable[Union[str, unicode]]) -> None: ... + def write(self, b: str | unicode) -> int: ... + def writelines(self, lines: Iterable[str | unicode]) -> None: ... @overload def StringIO() -> OutputType: ... diff --git a/stdlib/@python2/codecs.pyi b/stdlib/@python2/codecs.pyi index 8bacab771b0d..7c9217650681 100644 --- a/stdlib/@python2/codecs.pyi +++ b/stdlib/@python2/codecs.pyi @@ -144,13 +144,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. @@ -165,8 +165,8 @@ class IncrementalEncoder: def encode(self, input: _Decoded, final: bool = ...) -> _Encoded: ... def reset(self) -> None: ... # documentation says int but str is needed for the subclass. - def getstate(self) -> Union[int, _Decoded]: ... - def setstate(self, state: Union[int, _Decoded]) -> None: ... + def getstate(self) -> int | _Decoded: ... + def setstate(self, state: int | _Decoded) -> None: ... class IncrementalDecoder: errors: str diff --git a/stdlib/@python2/collections.pyi b/stdlib/@python2/collections.pyi index f6f75cb076c2..9bca1873cf3e 100644 --- a/stdlib/@python2/collections.pyi +++ b/stdlib/@python2/collections.pyi @@ -37,8 +37,8 @@ _VT = TypeVar("_VT") # namedtuple is special-cased in the type checker; the initializer is ignored. def namedtuple( - typename: Union[str, unicode], - field_names: Union[str, unicode, Iterable[Union[str, unicode]]], + typename: str | unicode, + field_names: Union[str, unicode, Iterable[str | unicode]], verbose: bool = ..., rename: bool = ..., ) -> Type[Tuple[Any, ...]]: ... diff --git a/stdlib/@python2/curses/ascii.pyi b/stdlib/@python2/curses/ascii.pyi index 10bab853adcf..1baff6e81a11 100644 --- a/stdlib/@python2/curses/ascii.pyi +++ b/stdlib/@python2/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/@python2/curses/textpad.pyi b/stdlib/@python2/curses/textpad.pyi index d2b5766fda26..679741937fba 100644 --- a/stdlib/@python2/curses/textpad.pyi +++ b/stdlib/@python2/curses/textpad.pyi @@ -7,5 +7,5 @@ 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 do_command(self, ch: str | int) -> None: ... def gather(self) -> str: ... diff --git a/stdlib/@python2/datetime.pyi b/stdlib/@python2/datetime.pyi index d1b0d6437825..b70fe1fd4f30 100644 --- a/stdlib/@python2/datetime.pyi +++ b/stdlib/@python2/datetime.pyi @@ -3,7 +3,7 @@ from typing import AnyStr, ClassVar, Optional, SupportsAbs, Tuple, Type, TypeVar _S = TypeVar("_S") -_Text = Union[str, unicode] +_Text = str | unicode MINYEAR: int MAXYEAR: int diff --git a/stdlib/@python2/dbm/__init__.pyi b/stdlib/@python2/dbm/__init__.pyi index edce1ea02861..284385b6c965 100644 --- a/stdlib/@python2/dbm/__init__.pyi +++ b/stdlib/@python2/dbm/__init__.pyi @@ -2,8 +2,8 @@ from types import TracebackType from typing import Iterator, MutableMapping, Optional, Tuple, Type, Union from typing_extensions import Literal -_KeyType = Union[str, bytes] -_ValueType = Union[str, bytes] +_KeyType = str | bytes +_ValueType = str | bytes class _Database(MutableMapping[_KeyType, bytes]): def close(self) -> None: ... diff --git a/stdlib/@python2/dbm/dumb.pyi b/stdlib/@python2/dbm/dumb.pyi index 0b8ee50a79b7..fe0ff19ec35b 100644 --- a/stdlib/@python2/dbm/dumb.pyi +++ b/stdlib/@python2/dbm/dumb.pyi @@ -1,8 +1,8 @@ from types import TracebackType from typing import Iterator, MutableMapping, Optional, Type, Union -_KeyType = Union[str, bytes] -_ValueType = Union[str, bytes] +_KeyType = str | bytes +_ValueType = str | bytes error = OSError diff --git a/stdlib/@python2/dbm/gnu.pyi b/stdlib/@python2/dbm/gnu.pyi index 8f13a2988488..596f4c71a79b 100644 --- a/stdlib/@python2/dbm/gnu.pyi +++ b/stdlib/@python2/dbm/gnu.pyi @@ -2,8 +2,8 @@ from types import TracebackType from typing import List, Optional, Type, TypeVar, Union, overload _T = TypeVar("_T") -_KeyType = Union[str, bytes] -_ValueType = Union[str, bytes] +_KeyType = str | bytes +_ValueType = str | bytes class error(OSError): ... @@ -25,7 +25,7 @@ class _gdbm: @overload def get(self, k: _KeyType) -> Optional[bytes]: ... @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/@python2/dbm/ndbm.pyi b/stdlib/@python2/dbm/ndbm.pyi index 020131543e13..3fce371b74f4 100644 --- a/stdlib/@python2/dbm/ndbm.pyi +++ b/stdlib/@python2/dbm/ndbm.pyi @@ -2,8 +2,8 @@ from types import TracebackType from typing import List, Optional, Type, TypeVar, Union, overload _T = TypeVar("_T") -_KeyType = Union[str, bytes] -_ValueType = Union[str, bytes] +_KeyType = str | bytes +_ValueType = str | bytes class error(OSError): ... @@ -24,7 +24,7 @@ class _dbm: @overload def get(self, k: _KeyType) -> Optional[bytes]: ... @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/@python2/decimal.pyi b/stdlib/@python2/decimal.pyi index bee33d9c7af0..20e6c525e966 100644 --- a/stdlib/@python2/decimal.pyi +++ b/stdlib/@python2/decimal.pyi @@ -1,9 +1,9 @@ from types import TracebackType from typing import Any, Container, Dict, List, NamedTuple, Optional, Sequence, Text, Tuple, Type, TypeVar, Union -_Decimal = Union[Decimal, int] +_Decimal = Decimal | int _DecimalNew = Union[Decimal, float, Text, Tuple[int, Sequence[int], int]] -_ComparableNum = Union[Decimal, float] +_ComparableNum = Decimal | float _DecimalT = TypeVar("_DecimalT", bound=Decimal) class DecimalTuple(NamedTuple): diff --git a/stdlib/@python2/dircache.pyi b/stdlib/@python2/dircache.pyi index fd906f6f2ae1..07256e38bfad 100644 --- a/stdlib/@python2/dircache.pyi +++ b/stdlib/@python2/dircache.pyi @@ -5,4 +5,4 @@ def listdir(path: Text) -> List[str]: ... opendir = listdir -def annotate(head: Text, list: Union[MutableSequence[str], MutableSequence[Text], MutableSequence[Union[str, Text]]]) -> None: ... +def annotate(head: Text, list: Union[MutableSequence[str], MutableSequence[Text], MutableSequence[str | Text]]) -> None: ... diff --git a/stdlib/@python2/distutils/cmd.pyi b/stdlib/@python2/distutils/cmd.pyi index b888c189f932..17aa7e32da6c 100644 --- a/stdlib/@python2/distutils/cmd.pyi +++ b/stdlib/@python2/distutils/cmd.pyi @@ -20,7 +20,7 @@ class Command: def get_command_name(self) -> str: ... def set_undefined_options(self, src_cmd: Text, *option_pairs: Tuple[str, str]) -> None: ... def get_finalized_command(self, command: Text, create: int = ...) -> Command: ... - def reinitialize_command(self, command: Union[Command, Text], reinit_subcommands: int = ...) -> Command: ... + def reinitialize_command(self, command: Command | Text, reinit_subcommands: int = ...) -> Command: ... def run_command(self, command: Text) -> None: ... def get_sub_commands(self) -> List[str]: ... def warn(self, msg: Text) -> None: ... diff --git a/stdlib/@python2/distutils/command/config.pyi b/stdlib/@python2/distutils/command/config.pyi index 6b57a64b48b1..592de5e0cf5b 100644 --- a/stdlib/@python2/distutils/command/config.pyi +++ b/stdlib/@python2/distutils/command/config.pyi @@ -11,7 +11,7 @@ class config(Command): description: str = ... # Tuple is full name, short name, description user_options: Sequence[Tuple[str, Optional[str], str]] = ... - compiler: Optional[Union[str, CCompiler]] = ... + compiler: Optional[str | CCompiler] = ... cc: Optional[str] = ... include_dirs: Optional[Sequence[str]] = ... libraries: Optional[Sequence[str]] = ... diff --git a/stdlib/@python2/distutils/sysconfig.pyi b/stdlib/@python2/distutils/sysconfig.pyi index 9061db75ccf1..2a7af45b9c27 100644 --- a/stdlib/@python2/distutils/sysconfig.pyi +++ b/stdlib/@python2/distutils/sysconfig.pyi @@ -5,7 +5,7 @@ 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_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: ... diff --git a/stdlib/@python2/distutils/version.pyi b/stdlib/@python2/distutils/version.pyi index f55d01d1a172..e1dbfee328c7 100644 --- a/stdlib/@python2/distutils/version.pyi +++ b/stdlib/@python2/distutils/version.pyi @@ -12,7 +12,7 @@ class Version: @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] @@ -21,13 +21,13 @@ class StrictVersion(Version): def __init__(self, vstring: Optional[Text] = ...) -> None: ... def parse(self: _T, vstring: Text) -> _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: Text - version: Tuple[Union[Text, int], ...] + version: Tuple[Text | int, ...] def __init__(self, vstring: Optional[Text] = ...) -> None: ... def parse(self: _T, vstring: Text) -> _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/@python2/doctest.pyi b/stdlib/@python2/doctest.pyi index b9e0ab392374..35762bba5528 100644 --- a/stdlib/@python2/doctest.pyi +++ b/stdlib/@python2/doctest.pyi @@ -66,7 +66,7 @@ class DocTest: 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] ) -> DocTest: ... diff --git a/stdlib/@python2/fcntl.pyi b/stdlib/@python2/fcntl.pyi index 200e2249280c..4c69e5ac10b3 100644 --- a/stdlib/@python2/fcntl.pyi +++ b/stdlib/@python2/fcntl.pyi @@ -74,9 +74,9 @@ LOCK_WRITE: int # TODO All these return either int or bytes depending on the value of # cmd (not on the type of arg). -def fcntl(fd: FileDescriptorLike, op: int, arg: Union[int, bytes] = ...) -> Any: ... +def fcntl(fd: FileDescriptorLike, op: int, arg: int | bytes = ...) -> Any: ... # TODO: arg: int or read-only buffer interface or read-write buffer interface -def ioctl(fd: FileDescriptorLike, op: int, arg: Union[int, bytes] = ..., mutate_flag: bool = ...) -> Any: ... +def ioctl(fd: FileDescriptorLike, op: int, arg: int | bytes = ..., mutate_flag: bool = ...) -> Any: ... def flock(fd: FileDescriptorLike, op: int) -> None: ... def lockf(fd: FileDescriptorLike, op: int, length: int = ..., start: int = ..., whence: int = ...) -> Any: ... diff --git a/stdlib/@python2/filecmp.pyi b/stdlib/@python2/filecmp.pyi index 73fe39580c55..7b5ec48b8344 100644 --- a/stdlib/@python2/filecmp.pyi +++ b/stdlib/@python2/filecmp.pyi @@ -2,9 +2,9 @@ from typing import AnyStr, Callable, Dict, Generic, Iterable, List, Optional, Se DEFAULT_IGNORES: List[str] -def cmp(f1: Union[bytes, Text], f2: Union[bytes, Text], shallow: Union[int, bool] = ...) -> bool: ... +def cmp(f1: bytes | Text, f2: bytes | Text, shallow: int | bool = ...) -> bool: ... def cmpfiles( - a: AnyStr, b: AnyStr, common: Iterable[AnyStr], shallow: Union[int, bool] = ... + a: AnyStr, b: AnyStr, common: Iterable[AnyStr], shallow: int | bool = ... ) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ... class dircmp(Generic[AnyStr]): diff --git a/stdlib/@python2/fnmatch.pyi b/stdlib/@python2/fnmatch.pyi index e933b7b2cb62..5d060a7a2eaf 100644 --- a/stdlib/@python2/fnmatch.pyi +++ b/stdlib/@python2/fnmatch.pyi @@ -1,6 +1,6 @@ from typing import AnyStr, Iterable, List, Union -_EitherStr = Union[str, unicode] +_EitherStr = str | unicode def fnmatch(filename: _EitherStr, pattern: _EitherStr) -> bool: ... def fnmatchcase(filename: _EitherStr, pattern: _EitherStr) -> bool: ... diff --git a/stdlib/@python2/fractions.pyi b/stdlib/@python2/fractions.pyi index bb60014b398e..71a09ce1f1ec 100644 --- a/stdlib/@python2/fractions.pyi +++ b/stdlib/@python2/fractions.pyi @@ -19,8 +19,8 @@ class Fraction(Rational): @overload def __new__( cls: Type[_T], - numerator: Union[int, Rational] = ..., - denominator: Optional[Union[int, Rational]] = ..., + numerator: int | Rational = ..., + denominator: Optional[int | Rational] = ..., *, _normalize: bool = ..., ) -> _T: ... @@ -36,93 +36,93 @@ 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 __div__(self, other: Union[int, Fraction]) -> Fraction: ... + def __div__(self, other: int | Fraction) -> Fraction: ... @overload def __div__(self, other: float) -> float: ... @overload def __div__(self, other: complex) -> complex: ... @overload - def __rdiv__(self, other: Union[int, Fraction]) -> Fraction: ... + def __rdiv__(self, other: int | Fraction) -> Fraction: ... @overload def __rdiv__(self, other: float) -> float: ... @overload def __rdiv__(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 diff --git a/stdlib/@python2/ftplib.pyi b/stdlib/@python2/ftplib.pyi index bdb975fbc21e..ffdc10206e08 100644 --- a/stdlib/@python2/ftplib.pyi +++ b/stdlib/@python2/ftplib.pyi @@ -5,7 +5,7 @@ from typing import Any, BinaryIO, Callable, List, Optional, Text, Tuple, Type, T from typing_extensions import Literal _T = TypeVar("_T") -_IntOrStr = Union[int, Text] +_IntOrStr = int | Text MSG_OOB: int FTP_PORT: int @@ -44,7 +44,7 @@ class FTP: 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: Text) -> str: ... def putline(self, line: Text) -> None: ... def putcmd(self, line: Text) -> None: ... diff --git a/stdlib/@python2/gettext.pyi b/stdlib/@python2/gettext.pyi index 0930fe63813e..b7d93ee053e8 100644 --- a/stdlib/@python2/gettext.pyi +++ b/stdlib/@python2/gettext.pyi @@ -18,10 +18,10 @@ class NullTranslations(object): def add_fallback(self, fallback: NullTranslations) -> None: ... def gettext(self, message: str) -> str: ... def lgettext(self, message: str) -> str: ... - def ugettext(self, message: Union[str, unicode]) -> unicode: ... + def ugettext(self, message: str | unicode) -> unicode: ... def ngettext(self, singular: str, plural: str, n: int) -> str: ... def lngettext(self, singular: str, plural: str, n: int) -> str: ... - def ungettext(self, singular: Union[str, unicode], plural: Union[str, unicode], n: int) -> unicode: ... + def ungettext(self, singular: str | unicode, plural: str | unicode, n: int) -> unicode: ... def info(self) -> Dict[str, str]: ... def charset(self) -> Optional[str]: ... def output_charset(self) -> Optional[str]: ... diff --git a/stdlib/@python2/glob.pyi b/stdlib/@python2/glob.pyi index 2804d74a6a3f..149eaed059a5 100644 --- a/stdlib/@python2/glob.pyi +++ b/stdlib/@python2/glob.pyi @@ -2,6 +2,6 @@ from typing import AnyStr, Iterator, List, Union def glob(pathname: AnyStr) -> List[AnyStr]: ... def iglob(pathname: AnyStr) -> Iterator[AnyStr]: ... -def glob1(dirname: Union[str, unicode], pattern: AnyStr) -> List[AnyStr]: ... -def glob0(dirname: Union[str, unicode], basename: AnyStr) -> List[AnyStr]: ... -def has_magic(s: Union[str, unicode]) -> bool: ... # undocumented +def glob1(dirname: str | unicode, pattern: AnyStr) -> List[AnyStr]: ... +def glob0(dirname: str | unicode, basename: AnyStr) -> List[AnyStr]: ... +def has_magic(s: str | unicode) -> bool: ... # undocumented diff --git a/stdlib/@python2/imghdr.pyi b/stdlib/@python2/imghdr.pyi index 4a6c3f39eb27..043a27975ab4 100644 --- a/stdlib/@python2/imghdr.pyi +++ b/stdlib/@python2/imghdr.pyi @@ -5,7 +5,7 @@ class _ReadableBinary(Protocol): def read(self, size: int) -> bytes: ... def seek(self, offset: int) -> Any: ... -_File = Union[Text, _ReadableBinary] +_File = Text | _ReadableBinary @overload def what(file: _File, h: None = ...) -> Optional[str]: ... diff --git a/stdlib/@python2/inspect.pyi b/stdlib/@python2/inspect.pyi index 8e95a92cac10..64084a5cb0f8 100644 --- a/stdlib/@python2/inspect.pyi +++ b/stdlib/@python2/inspect.pyi @@ -30,7 +30,7 @@ class ModuleInfo(NamedTuple): module_type: int def getmembers(object: object, predicate: Optional[Callable[[Any], bool]] = ...) -> List[Tuple[str, Any]]: ... -def getmoduleinfo(path: Union[str, unicode]) -> Optional[ModuleInfo]: ... +def getmoduleinfo(path: str | unicode) -> Optional[ModuleInfo]: ... def getmodulename(path: AnyStr) -> Optional[AnyStr]: ... def ismodule(object: object) -> bool: ... def isclass(object: object) -> bool: ... @@ -63,7 +63,7 @@ def getsourcefile(object: _SourceObjectType) -> Optional[str]: ... def getsourcelines(object: _SourceObjectType) -> Tuple[List[str], int]: ... def getsource(object: _SourceObjectType) -> str: ... def cleandoc(doc: AnyStr) -> AnyStr: ... -def indentsize(line: Union[str, unicode]) -> int: ... +def indentsize(line: str | unicode) -> int: ... # Classes and functions def getclasstree(classes: List[type], unique: bool = ...) -> List[Union[Tuple[type, Tuple[type, ...]], List[Any]]]: ... @@ -109,7 +109,7 @@ class Traceback(NamedTuple): _FrameInfo = Tuple[FrameType, str, int, str, Optional[List[str]], Optional[int]] def getouterframes(frame: FrameType, context: int = ...) -> List[_FrameInfo]: ... -def getframeinfo(frame: Union[FrameType, TracebackType], context: int = ...) -> Traceback: ... +def getframeinfo(frame: FrameType | TracebackType, context: int = ...) -> Traceback: ... def getinnerframes(traceback: TracebackType, context: int = ...) -> List[_FrameInfo]: ... def getlineno(frame: FrameType) -> int: ... def currentframe(depth: int = ...) -> FrameType: ... diff --git a/stdlib/@python2/json.pyi b/stdlib/@python2/json.pyi index 2d38e6b47bb8..a6030f2174e8 100644 --- a/stdlib/@python2/json.pyi +++ b/stdlib/@python2/json.pyi @@ -31,7 +31,7 @@ def dump( **kwds: Any, ) -> None: ... def loads( - s: Union[Text, bytes], + s: Text | bytes, encoding: Any = ..., cls: Optional[Type[JSONDecoder]] = ..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ..., @@ -42,7 +42,7 @@ def loads( **kwds: Any, ) -> Any: ... def load( - fp: SupportsRead[Union[Text, bytes]], + fp: SupportsRead[Text | bytes], encoding: Optional[str] = ..., cls: Optional[Type[JSONDecoder]] = ..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ..., @@ -56,7 +56,7 @@ def load( class JSONDecoder(object): def __init__( self, - encoding: Union[Text, bytes] = ..., + encoding: Text | bytes = ..., object_hook: Callable[..., Any] = ..., parse_float: Callable[[str], float] = ..., parse_int: Callable[[str], int] = ..., @@ -64,8 +64,8 @@ class JSONDecoder(object): strict: bool = ..., object_pairs_hook: Callable[..., Any] = ..., ) -> None: ... - def decode(self, s: Union[Text, bytes], _w: Any = ...) -> Any: ... - def raw_decode(self, s: Union[Text, bytes], idx: int = ...) -> Tuple[Any, Any]: ... + def decode(self, s: Text | bytes, _w: Any = ...) -> Any: ... + def raw_decode(self, s: Text | bytes, idx: int = ...) -> Tuple[Any, Any]: ... class JSONEncoder(object): item_separator: str @@ -84,8 +84,8 @@ class JSONEncoder(object): allow_nan: bool = ..., sort_keys: bool = ..., indent: Optional[int] = ..., - separators: Tuple[Union[Text, bytes], Union[Text, bytes]] = ..., - encoding: Union[Text, bytes] = ..., + separators: Tuple[Text | bytes, Text | bytes] = ..., + encoding: Text | bytes = ..., default: Callable[..., Any] = ..., ) -> None: ... def default(self, o: Any) -> Any: ... diff --git a/stdlib/@python2/lib2to3/pytree.pyi b/stdlib/@python2/lib2to3/pytree.pyi index 48d11f84f201..fd201b63f893 100644 --- a/stdlib/@python2/lib2to3/pytree.pyi +++ b/stdlib/@python2/lib2to3/pytree.pyi @@ -2,7 +2,7 @@ from lib2to3.pgen2.grammar import Grammar from typing import Any, Callable, Dict, Iterator, List, Optional, Text, Tuple, TypeVar, Union _P = TypeVar("_P") -_NL = Union[Node, Leaf] +_NL = Node | Leaf _Context = Tuple[Text, int, int] _Results = Dict[Text, _NL] _RawNode = Tuple[int, Text, _Context, Optional[List[_NL]]] diff --git a/stdlib/@python2/locale.pyi b/stdlib/@python2/locale.pyi index eb73dfcb62a2..44dd2f5f6436 100644 --- a/stdlib/@python2/locale.pyi +++ b/stdlib/@python2/locale.pyi @@ -84,7 +84,7 @@ 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: ... 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 atof(string: _str, func: Callable[[_str], float] = ...) -> float: ... diff --git a/stdlib/@python2/logging/__init__.pyi b/stdlib/@python2/logging/__init__.pyi index 242132c820d5..d41e1055f4e6 100644 --- a/stdlib/@python2/logging/__init__.pyi +++ b/stdlib/@python2/logging/__init__.pyi @@ -8,7 +8,7 @@ _SysExcInfoType = Union[Tuple[type, BaseException, Optional[TracebackType]], Tup _ExcInfoType = Union[None, bool, _SysExcInfoType] _ArgsType = Union[Tuple[Any, ...], Mapping[str, Any]] _FilterType = Union[Filter, Callable[[LogRecord], int]] -_Level = Union[int, Text] +_Level = int | Text raiseExceptions: bool logThreads: bool @@ -18,7 +18,7 @@ _srcfile: Optional[str] def currentframe() -> FrameType: ... -_levelNames: Dict[Union[int, str], Union[str, int]] # Union[int:str, str:int] +_levelNames: Dict[int | str, str | int] # Union[int:str, str:int] class Filterer(object): filters: List[Filter] @@ -30,7 +30,7 @@ class Filterer(object): class Logger(Filterer): name: str level: int - parent: Union[Logger, PlaceHolder] + parent: Logger | PlaceHolder propagate: bool handlers: List[Handler] disabled: int @@ -190,7 +190,7 @@ class LoggerAdapter: @overload def getLogger() -> Logger: ... @overload -def getLogger(name: Union[Text, str]) -> Logger: ... +def getLogger(name: Text | str) -> Logger: ... def getLoggerClass() -> type: ... def debug(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> None: ... def info(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> None: ... @@ -213,7 +213,7 @@ fatal = critical def disable(level: int) -> None: ... def addLevelName(level: int, levelName: str) -> None: ... -def getLevelName(level: Union[int, str]) -> Any: ... +def getLevelName(level: int | str) -> Any: ... def makeLogRecord(dict: Mapping[str, Any]) -> LogRecord: ... @overload def basicConfig() -> None: ... diff --git a/stdlib/@python2/logging/handlers.pyi b/stdlib/@python2/logging/handlers.pyi index ed7e6d74dd17..13c561c0ce82 100644 --- a/stdlib/@python2/logging/handlers.pyi +++ b/stdlib/@python2/logging/handlers.pyi @@ -93,7 +93,7 @@ class SysLogHandler(Handler): def __init__( self, address: Union[Tuple[str, int], str] = ..., facility: int = ..., socktype: Optional[SocketKind] = ... ) -> 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): diff --git a/stdlib/@python2/macurl2path.pyi b/stdlib/@python2/macurl2path.pyi index 025820b44e89..532d464d81ab 100644 --- a/stdlib/@python2/macurl2path.pyi +++ b/stdlib/@python2/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/@python2/mailbox.pyi b/stdlib/@python2/mailbox.pyi index 38663a391b8f..42af58f32908 100644 --- a/stdlib/@python2/mailbox.pyi +++ b/stdlib/@python2/mailbox.pyi @@ -37,7 +37,7 @@ linesep: bytes class Mailbox(Generic[_MessageT]): - _path: Union[bytes, str] # undocumented + _path: bytes | str # undocumented _factory: Optional[Callable[[IO[Any]], _MessageT]] # undocumented def __init__(self, path: Text, factory: Optional[Callable[[IO[Any]], _MessageT]] = ..., create: bool = ...) -> None: ... def add(self, message: _MessageData) -> str: ... @@ -48,7 +48,7 @@ class Mailbox(Generic[_MessageT]): @overload def get(self, key: str, default: None = ...) -> Optional[_MessageT]: ... @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: ... @@ -68,7 +68,7 @@ class Mailbox(Generic[_MessageT]): @overload def pop(self, key: str, default: None = ...) -> Optional[_MessageT]: ... @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 flush(self) -> None: ... diff --git a/stdlib/@python2/mailcap.pyi b/stdlib/@python2/mailcap.pyi index a65cc3a329d3..8a721168e06b 100644 --- a/stdlib/@python2/mailcap.pyi +++ b/stdlib/@python2/mailcap.pyi @@ -1,6 +1,6 @@ from typing import Dict, List, Mapping, Optional, Sequence, Tuple, Union -_Cap = Dict[str, Union[str, int]] +_Cap = Dict[str, str | int] def findmatch( caps: Mapping[str, List[_Cap]], MIMEtype: str, key: str = ..., filename: str = ..., plist: Sequence[str] = ... diff --git a/stdlib/@python2/mmap.pyi b/stdlib/@python2/mmap.pyi index 1b8a0202fa76..1fa8121d7a9c 100644 --- a/stdlib/@python2/mmap.pyi +++ b/stdlib/@python2/mmap.pyi @@ -49,7 +49,7 @@ class mmap(_mmap[bytes], Sequence[bytes]): def rfind(self, string: bytes, start: int = ..., stop: int = ...) -> int: ... def read(self, num: int) -> bytes: ... def write(self, string: bytes) -> None: ... - def __getitem__(self, index: Union[int, slice]) -> bytes: ... + def __getitem__(self, index: int | slice) -> bytes: ... def __getslice__(self, i: Optional[int], j: Optional[int]) -> bytes: ... - def __delitem__(self, index: Union[int, slice]) -> None: ... - def __setitem__(self, index: Union[int, slice], object: bytes) -> None: ... + def __delitem__(self, index: int | slice) -> None: ... + def __setitem__(self, index: int | slice, object: bytes) -> None: ... diff --git a/stdlib/@python2/nntplib.pyi b/stdlib/@python2/nntplib.pyi index 21b33f55d051..0bbdc71841ff 100644 --- a/stdlib/@python2/nntplib.pyi +++ b/stdlib/@python2/nntplib.pyi @@ -52,9 +52,9 @@ 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 description(self, group: str) -> str: ... diff --git a/stdlib/@python2/optparse.pyi b/stdlib/@python2/optparse.pyi index 62ae8ef8a8bf..386c8e4d947c 100644 --- a/stdlib/@python2/optparse.pyi +++ b/stdlib/@python2/optparse.pyi @@ -1,7 +1,7 @@ from typing import IO, Any, AnyStr, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Type, Union, overload # See https://groups.google.com/forum/#!topic/python-ideas/gA1gdj3RZ5g -_Text = Union[str, unicode] +_Text = str | unicode NO_DEFAULT: Tuple[_Text, ...] SUPPRESS_HELP: _Text diff --git a/stdlib/@python2/os/__init__.pyi b/stdlib/@python2/os/__init__.pyi index 3b4f9698dd14..7f37ee837f90 100644 --- a/stdlib/@python2/os/__init__.pyi +++ b/stdlib/@python2/os/__init__.pyi @@ -187,9 +187,9 @@ if sys.platform != "win32": @overload def getenv(key: Text) -> Optional[str]: ... @overload -def getenv(key: Text, default: _T) -> Union[str, _T]: ... -def putenv(key: Union[bytes, Text], value: Union[bytes, Text]) -> None: ... -def unsetenv(key: Union[bytes, Text]) -> None: ... +def getenv(key: Text, default: _T) -> str | _T: ... +def putenv(key: bytes | Text, value: bytes | Text) -> None: ... +def unsetenv(key: bytes | Text) -> None: ... def fdopen(fd: int, *args, **kwargs) -> IO[Any]: ... def close(fd: int) -> None: ... def closerange(fd_low: int, fd_high: int) -> None: ... @@ -201,7 +201,7 @@ def lseek(fd: int, pos: int, how: int) -> int: ... def open(file: Text, flags: int, mode: int = ...) -> int: ... def pipe() -> Tuple[int, int]: ... def read(fd: int, n: int) -> bytes: ... -def write(fd: int, string: Union[bytes, buffer]) -> int: ... +def write(fd: int, string: bytes | buffer) -> int: ... def access(path: Text, mode: int) -> bool: ... def chdir(path: Text) -> None: ... def fchdir(fd: FileDescriptorLike) -> None: ... @@ -239,7 +239,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: ... def ftruncate(fd: int, length: int) -> None: ... def isatty(fd: int) -> bool: ... @@ -254,7 +254,7 @@ if sys.platform != "win32": def lchmod(path: Text, mode: int) -> None: ... def lchown(path: Text, uid: int, gid: int) -> None: ... def mkfifo(path: Text, mode: int = ...) -> None: ... - def pathconf(path: Text, name: Union[str, int]) -> int: ... + def pathconf(path: Text, name: str | int) -> int: ... def statvfs(path: Text) -> _StatVFS: ... def walk( @@ -263,16 +263,16 @@ def walk( def abort() -> NoReturn: ... # These are defined as execl(file, *args) but the first *arg is mandatory. -def execl(file: Text, __arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> NoReturn: ... -def execlp(file: Text, __arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> NoReturn: ... +def execl(file: Text, __arg0: bytes | Text, *args: bytes | Text) -> NoReturn: ... +def execlp(file: Text, __arg0: bytes | Text, *args: bytes | Text) -> NoReturn: ... # These are: execle(file, *args, env) but env is pulled from the last element of the args. -def execle(file: Text, __arg0: Union[bytes, Text], *args: Any) -> NoReturn: ... -def execlpe(file: Text, __arg0: Union[bytes, Text], *args: Any) -> NoReturn: ... +def execle(file: Text, __arg0: bytes | Text, *args: Any) -> NoReturn: ... +def execlpe(file: Text, __arg0: bytes | Text, *args: Any) -> NoReturn: ... # The docs say `args: tuple or list of strings` # The implementation enforces tuple or list so we can't use Sequence. -_ExecVArgs = Union[Tuple[Union[bytes, Text], ...], List[bytes], List[Text], List[Union[bytes, Text]]] +_ExecVArgs = Union[Tuple[bytes | Text, ...], List[bytes], List[Text], List[bytes | Text]] def execv(path: Text, args: _ExecVArgs) -> NoReturn: ... def execve(path: Text, args: _ExecVArgs, env: Mapping[str, str]) -> NoReturn: ... @@ -293,10 +293,10 @@ def popen(command: str, *args, **kwargs) -> IO[Any]: ... def popen2(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any]]: ... def popen3(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any], IO[Any]]: ... def popen4(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any]]: ... -def spawnl(mode: int, path: Text, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ... -def spawnle(mode: int, path: Text, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise sig -def spawnv(mode: int, path: Text, args: List[Union[bytes, Text]]) -> int: ... -def spawnve(mode: int, path: Text, args: List[Union[bytes, Text]], env: Mapping[str, str]) -> int: ... +def spawnl(mode: int, path: Text, arg0: bytes | Text, *args: bytes | Text) -> int: ... +def spawnle(mode: int, path: Text, arg0: bytes | Text, *args: Any) -> int: ... # Imprecise sig +def spawnv(mode: int, path: Text, args: List[bytes | Text]) -> int: ... +def spawnve(mode: int, path: Text, args: List[bytes | Text], env: Mapping[str, str]) -> int: ... def system(command: Text) -> int: ... def times() -> Tuple[float, float, float, float, float]: ... def waitpid(pid: int, options: int) -> Tuple[int, int]: ... @@ -307,10 +307,10 @@ if sys.platform == "win32": else: # Unix only - def spawnlp(mode: int, file: Text, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ... - def spawnlpe(mode: int, file: Text, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise signature - def spawnvp(mode: int, file: Text, args: List[Union[bytes, Text]]) -> int: ... - def spawnvpe(mode: int, file: Text, args: List[Union[bytes, Text]], env: Mapping[str, str]) -> int: ... + def spawnlp(mode: int, file: Text, arg0: bytes | Text, *args: bytes | Text) -> int: ... + def spawnlpe(mode: int, file: Text, arg0: bytes | Text, *args: Any) -> int: ... # Imprecise signature + def spawnvp(mode: int, file: Text, args: List[bytes | Text]) -> int: ... + def spawnvpe(mode: int, file: Text, args: List[bytes | Text], env: Mapping[str, str]) -> int: ... def wait() -> Tuple[int, int]: ... def wait3(options: int) -> Tuple[int, int, Any]: ... def wait4(pid: int, options: int) -> Tuple[int, int, Any]: ... @@ -322,9 +322,9 @@ else: def WEXITSTATUS(status: int) -> int: ... def WSTOPSIG(status: int) -> int: ... def WTERMSIG(status: int) -> int: ... - def confstr(name: Union[str, int]) -> Optional[str]: ... + def confstr(name: str | int) -> Optional[str]: ... def getloadavg() -> Tuple[float, float, float]: ... - def sysconf(name: Union[str, int]) -> int: ... + def sysconf(name: str | int) -> int: ... def tmpfile() -> IO[Any]: ... def tmpnam() -> str: ... diff --git a/stdlib/@python2/pickletools.pyi b/stdlib/@python2/pickletools.pyi index 154aaf174f5d..1f035886319e 100644 --- a/stdlib/@python2/pickletools.pyi +++ b/stdlib/@python2/pickletools.pyi @@ -25,7 +25,7 @@ def read_int4(f: IO[bytes]) -> int: ... int4: ArgumentDescriptor -def read_stringnl(f: IO[bytes], decode: bool = ..., stripquotes: bool = ...) -> Union[bytes, Text]: ... +def read_stringnl(f: IO[bytes], decode: bool = ..., stripquotes: bool = ...) -> bytes | Text: ... stringnl: ArgumentDescriptor diff --git a/stdlib/@python2/pkgutil.pyi b/stdlib/@python2/pkgutil.pyi index 5fefef39bd6b..6a630dc1e16a 100644 --- a/stdlib/@python2/pkgutil.pyi +++ b/stdlib/@python2/pkgutil.pyi @@ -5,7 +5,7 @@ Loader = Any MetaPathFinder = Any PathEntryFinder = Any -_ModuleInfoLike = Tuple[Union[MetaPathFinder, PathEntryFinder], str, bool] +_ModuleInfoLike = Tuple[MetaPathFinder | PathEntryFinder, str, bool] def extend_path(path: List[str], name: str) -> List[str]: ... @@ -18,7 +18,7 @@ class ImpLoader: def find_loader(fullname: str) -> Optional[Loader]: ... def get_importer(path_item: str) -> Optional[PathEntryFinder]: ... def get_loader(module_or_name: str) -> Loader: ... -def iter_importers(fullname: str = ...) -> Iterator[Union[MetaPathFinder, PathEntryFinder]]: ... +def iter_importers(fullname: str = ...) -> Iterator[MetaPathFinder | PathEntryFinder]: ... def iter_modules(path: Optional[Iterable[str]] = ..., prefix: str = ...) -> Iterator[_ModuleInfoLike]: ... def read_code(stream: SupportsRead[bytes]) -> Any: ... # undocumented def walk_packages( diff --git a/stdlib/@python2/plistlib.pyi b/stdlib/@python2/plistlib.pyi index 23115812ad69..44f91e5297ca 100644 --- a/stdlib/@python2/plistlib.pyi +++ b/stdlib/@python2/plistlib.pyi @@ -1,6 +1,6 @@ from typing import IO, Any, Dict as DictT, Mapping, Text, Union -_Path = Union[str, Text] +_Path = str | Text def readPlist(pathOrFile: Union[_Path, IO[bytes]]) -> Any: ... def writePlist(value: Mapping[str, Any], pathOrFile: Union[_Path, IO[bytes]]) -> None: ... diff --git a/stdlib/@python2/popen2.pyi b/stdlib/@python2/popen2.pyi index b37a71085bf4..8830533cb909 100644 --- a/stdlib/@python2/popen2.pyi +++ b/stdlib/@python2/popen2.pyi @@ -11,7 +11,7 @@ class Popen3: childerr: Optional[TextIO] def __init__(self, cmd: Iterable[Any] = ..., capturestderr: bool = ..., bufsize: int = ...) -> None: ... def __del__(self) -> None: ... - def poll(self, _deadstate: _T = ...) -> Union[int, _T]: ... + def poll(self, _deadstate: _T = ...) -> int | _T: ... def wait(self) -> int: ... class Popen4(Popen3): diff --git a/stdlib/@python2/posix.pyi b/stdlib/@python2/posix.pyi index ae79286ec50d..8a4bd5586938 100644 --- a/stdlib/@python2/posix.pyi +++ b/stdlib/@python2/posix.pyi @@ -100,7 +100,7 @@ def chown(path: unicode, uid: int, gid: int) -> None: ... def chroot(path: unicode) -> None: ... def close(fd: int) -> None: ... def closerange(fd_low: int, fd_high: int) -> None: ... -def confstr(name: Union[str, int]) -> str: ... +def confstr(name: str | int) -> str: ... def ctermid() -> str: ... def dup(fd: int) -> int: ... def dup2(fd: int, fd2: int) -> None: ... @@ -178,7 +178,7 @@ def statvfs(path: unicode) -> statvfs_result: ... def stat_float_times(fd: int) -> None: ... def strerror(code: int) -> str: ... def symlink(source: unicode, link_name: unicode) -> None: ... -def sysconf(name: Union[str, int]) -> int: ... +def sysconf(name: str | int) -> int: ... def system(command: unicode) -> int: ... def tcgetpgrp(fd: int) -> int: ... def tcsetpgrp(fd: int, pg: int) -> None: ... diff --git a/stdlib/@python2/profile.pyi b/stdlib/@python2/profile.pyi index e799c6b36e2f..215693a0c2d8 100644 --- a/stdlib/@python2/profile.pyi +++ b/stdlib/@python2/profile.pyi @@ -1,8 +1,8 @@ from typing import Any, Callable, Dict, Optional, Text, Tuple, TypeVar, Union -def run(statement: str, filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ... +def run(statement: str, filename: Optional[str] = ..., 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: Optional[str] = ..., sort: str | int = ... ) -> None: ... _SelfT = TypeVar("_SelfT", bound=Profile) @@ -16,7 +16,7 @@ class Profile: 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: Text) -> None: ... def create_stats(self) -> None: ... def snapshot_stats(self) -> None: ... diff --git a/stdlib/@python2/py_compile.pyi b/stdlib/@python2/py_compile.pyi index 94a8ace8e69a..1785aaaf7b99 100644 --- a/stdlib/@python2/py_compile.pyi +++ b/stdlib/@python2/py_compile.pyi @@ -1,6 +1,6 @@ from typing import List, Optional, Text, Type, Union -_EitherStr = Union[bytes, Text] +_EitherStr = bytes | Text class PyCompileError(Exception): exc_type_name: str diff --git a/stdlib/@python2/pyclbr.pyi b/stdlib/@python2/pyclbr.pyi index 855a2963c453..6a7451de720a 100644 --- a/stdlib/@python2/pyclbr.pyi +++ b/stdlib/@python2/pyclbr.pyi @@ -3,11 +3,11 @@ from typing import Dict, List, Optional, Sequence, Union class Class: module: str name: str - super: Optional[List[Union[Class, str]]] + super: Optional[List[Class | str]] methods: Dict[str, int] file: int lineno: int - 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: Optional[List[Class | str]], file: str, lineno: int) -> None: ... class Function: module: str diff --git a/stdlib/@python2/pydoc.pyi b/stdlib/@python2/pydoc.pyi index 857ed5a82c63..d2d853410cec 100644 --- a/stdlib/@python2/pydoc.pyi +++ b/stdlib/@python2/pydoc.pyi @@ -209,12 +209,12 @@ 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 = ...) -> Optional[Tuple[object, str]]: ... +def render_doc(thing: str | object, title: str = ..., forceload: bool = ..., renderer: Optional[Doc] = ...) -> str: ... def doc( - thing: Union[str, object], title: str = ..., forceload: bool = ..., output: Optional[SupportsWrite[str]] = ... + thing: str | object, title: str = ..., forceload: bool = ..., output: Optional[SupportsWrite[str]] = ... ) -> None: ... -def writedoc(thing: Union[str, object], forceload: bool = ...) -> None: ... +def writedoc(thing: str | object, forceload: bool = ...) -> None: ... def writedocs(dir: str, pkgpath: str = ..., done: Optional[Any] = ...) -> None: ... class Helper: diff --git a/stdlib/@python2/pyexpat/__init__.pyi b/stdlib/@python2/pyexpat/__init__.pyi index 65f6b0e9f7de..6fe73d1576a5 100644 --- a/stdlib/@python2/pyexpat/__init__.pyi +++ b/stdlib/@python2/pyexpat/__init__.pyi @@ -22,7 +22,7 @@ XML_PARAM_ENTITY_PARSING_ALWAYS: int _Model = Tuple[int, int, Optional[str], Tuple[Any, ...]] class XMLParserType(object): - def Parse(self, __data: Union[Text, bytes], __isfinal: bool = ...) -> int: ... + def Parse(self, __data: Text | bytes, __isfinal: bool = ...) -> int: ... def ParseFile(self, __file: SupportsRead[bytes]) -> int: ... def SetBase(self, __base: Text) -> None: ... def GetBase(self) -> Optional[str]: ... diff --git a/stdlib/@python2/re.pyi b/stdlib/@python2/re.pyi index aa770b6b64be..18a462298b05 100644 --- a/stdlib/@python2/re.pyi +++ b/stdlib/@python2/re.pyi @@ -24,21 +24,21 @@ def compile(pattern: AnyStr, flags: int = ...) -> Pattern[AnyStr]: ... @overload def compile(pattern: Pattern[AnyStr], flags: int = ...) -> Pattern[AnyStr]: ... @overload -def search(pattern: Union[str, unicode], string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... +def search(pattern: str | unicode, string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... @overload def search(pattern: Union[Pattern[str], Pattern[unicode]], string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... @overload -def match(pattern: Union[str, unicode], string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... +def match(pattern: str | unicode, string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... @overload def match(pattern: Union[Pattern[str], Pattern[unicode]], string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... @overload -def split(pattern: Union[str, unicode], string: AnyStr, maxsplit: int = ..., flags: int = ...) -> List[AnyStr]: ... +def split(pattern: str | unicode, string: AnyStr, maxsplit: int = ..., flags: int = ...) -> List[AnyStr]: ... @overload def split( pattern: Union[Pattern[str], Pattern[unicode]], string: AnyStr, maxsplit: int = ..., flags: int = ... ) -> List[AnyStr]: ... @overload -def findall(pattern: Union[str, unicode], string: AnyStr, flags: int = ...) -> List[Any]: ... +def findall(pattern: str | unicode, string: AnyStr, flags: int = ...) -> List[Any]: ... @overload def findall(pattern: Union[Pattern[str], Pattern[unicode]], string: AnyStr, flags: int = ...) -> List[Any]: ... @@ -47,14 +47,14 @@ def findall(pattern: Union[Pattern[str], Pattern[unicode]], string: AnyStr, flag # matches are returned in the order found. Empty matches are included in the # result unless they touch the beginning of another match. @overload -def finditer(pattern: Union[str, unicode], string: AnyStr, flags: int = ...) -> Iterator[Match[AnyStr]]: ... +def finditer(pattern: str | unicode, string: AnyStr, flags: int = ...) -> Iterator[Match[AnyStr]]: ... @overload def finditer(pattern: Union[Pattern[str], Pattern[unicode]], string: AnyStr, flags: int = ...) -> Iterator[Match[AnyStr]]: ... @overload -def sub(pattern: Union[str, unicode], repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ...) -> AnyStr: ... +def sub(pattern: str | unicode, repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ...) -> AnyStr: ... @overload def sub( - pattern: Union[str, unicode], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: int = ... + pattern: str | unicode, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: int = ... ) -> AnyStr: ... @overload def sub( @@ -70,11 +70,11 @@ def sub( ) -> AnyStr: ... @overload def subn( - pattern: Union[str, unicode], repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ... + pattern: str | unicode, repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ... ) -> Tuple[AnyStr, int]: ... @overload def subn( - pattern: Union[str, unicode], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: int = ... + pattern: str | unicode, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: int = ... ) -> Tuple[AnyStr, int]: ... @overload def subn( diff --git a/stdlib/@python2/rlcompleter.pyi b/stdlib/@python2/rlcompleter.pyi index a542c45c979b..b4ef2d1011d8 100644 --- a/stdlib/@python2/rlcompleter.pyi +++ b/stdlib/@python2/rlcompleter.pyi @@ -1,6 +1,6 @@ from typing import Any, Dict, Optional, Union -_Text = Union[str, unicode] +_Text = str | unicode class Completer: def __init__(self, namespace: Optional[Dict[str, Any]] = ...) -> None: ... diff --git a/stdlib/@python2/smtpd.pyi b/stdlib/@python2/smtpd.pyi index 33d84ffde4c8..dae5df22ade8 100644 --- a/stdlib/@python2/smtpd.pyi +++ b/stdlib/@python2/smtpd.pyi @@ -29,17 +29,17 @@ class SMTPServer(asyncore.dispatcher): def __init__(self, localaddr: _Address, remoteaddr: _Address, data_size_limit: int = ...) -> None: ... def handle_accepted(self, conn: socket.socket, addr: Any) -> None: ... def process_message( - self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: Union[bytes, str], **kwargs: Any + self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: bytes | str, **kwargs: Any ) -> Optional[str]: ... class DebuggingServer(SMTPServer): ... class PureProxy(SMTPServer): def process_message( # type: ignore - self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: Union[bytes, str] + self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: bytes | str ) -> Optional[str]: ... class MailmanProxy(PureProxy): def process_message( # type: ignore - self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: Union[bytes, str] + self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: bytes | str ) -> Optional[str]: ... diff --git a/stdlib/@python2/sndhdr.pyi b/stdlib/@python2/sndhdr.pyi index a5ae485c24a2..1c368591ca52 100644 --- a/stdlib/@python2/sndhdr.pyi +++ b/stdlib/@python2/sndhdr.pyi @@ -1,6 +1,6 @@ from typing import Optional, Text, Tuple, Union -_SndHeaders = Tuple[str, int, int, int, Union[int, str]] +_SndHeaders = Tuple[str, int, int, int, int | str] def what(filename: Text) -> Optional[_SndHeaders]: ... def whathdr(filename: Text) -> Optional[_SndHeaders]: ... diff --git a/stdlib/@python2/socket.pyi b/stdlib/@python2/socket.pyi index ea3d47757a77..373661980460 100644 --- a/stdlib/@python2/socket.pyi +++ b/stdlib/@python2/socket.pyi @@ -377,7 +377,7 @@ _Address = Union[Tuple[Any, ...], str] _RetAddress = Any # TODO Most methods allow bytes as address objects -_WriteBuffer = Union[bytearray, memoryview] +_WriteBuffer = bytearray | memoryview _CMSG = Tuple[int, int, bytes] _SelfT = TypeVar("_SelfT", bound=socket) @@ -389,10 +389,10 @@ class socket: def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ... # --- methods --- def accept(self) -> Tuple[socket, _RetAddress]: ... - def bind(self, address: Union[_Address, bytes]) -> None: ... + def bind(self, address: _Address | bytes) -> None: ... def close(self) -> None: ... - def connect(self, address: Union[_Address, bytes]) -> None: ... - def connect_ex(self, address: Union[_Address, bytes]) -> int: ... + def connect(self, address: _Address | bytes) -> None: ... + def connect_ex(self, address: _Address | bytes) -> int: ... def detach(self) -> int: ... def dup(self) -> socket: ... def fileno(self) -> int: ... @@ -420,7 +420,7 @@ class socket: def sendto(self, data: bytes, flags: int, address: _Address) -> int: ... def setblocking(self, flag: bool) -> None: ... def settimeout(self, value: Optional[float]) -> None: ... - def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ... + def setsockopt(self, level: int, optname: int, value: int | bytes) -> None: ... if sys.platform == "win32": def share(self, process_id: int) -> bytes: ... def shutdown(self, how: int) -> None: ... diff --git a/stdlib/@python2/sqlite3/dbapi2.pyi b/stdlib/@python2/sqlite3/dbapi2.pyi index e89ae080aed0..13c2cdf0a7df 100644 --- a/stdlib/@python2/sqlite3/dbapi2.pyi +++ b/stdlib/@python2/sqlite3/dbapi2.pyi @@ -62,7 +62,7 @@ version: str def adapt(obj, protocol, alternate): ... def complete_statement(sql: str) -> bool: ... def connect( - database: Union[bytes, Text], + database: bytes | Text, timeout: float = ..., detect_types: int = ..., isolation_level: Optional[str] = ..., @@ -110,7 +110,7 @@ class Connection(object): 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, Text]) -> Cursor: ... + def executescript(self, __sql_script: bytes | Text) -> 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: ... @@ -143,7 +143,7 @@ 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, Text]) -> Cursor: ... + def executescript(self, __sql_script: bytes | Text) -> Cursor: ... def fetchall(self) -> List[Any]: ... def fetchmany(self, size: Optional[int] = ...) -> List[Any]: ... def fetchone(self) -> Any: ... diff --git a/stdlib/@python2/sre_parse.pyi b/stdlib/@python2/sre_parse.pyi index e2a0be4e3bf1..3ec611bd9c0d 100644 --- a/stdlib/@python2/sre_parse.pyi +++ b/stdlib/@python2/sre_parse.pyi @@ -26,7 +26,7 @@ _OpGroupRefExistsType = Tuple[int, SubPattern, SubPattern] _OpInType = List[Tuple[str, int]] _OpBranchType = Tuple[None, List[SubPattern]] _AvType = Union[_OpInType, _OpBranchType, Iterable[SubPattern], _OpGroupRefExistsType, _OpSubpatternType] -_CodeType = Union[str, _AvType] +_CodeType = str | _AvType class SubPattern: pattern: str @@ -35,9 +35,9 @@ class SubPattern: def __init__(self, pattern, data: List[_CodeType] = ...) -> 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): ... + def __delitem__(self, index: int | slice) -> None: ... + def __getitem__(self, index: int | slice) -> SubPattern | _CodeType: ... + def __setitem__(self, index: int | slice, code: _CodeType): ... def insert(self, index, code: _CodeType) -> None: ... def append(self, code: _CodeType) -> None: ... def getwidth(self) -> int: ... diff --git a/stdlib/@python2/ssl.pyi b/stdlib/@python2/ssl.pyi index b9693fa89768..aa5e6af4d366 100644 --- a/stdlib/@python2/ssl.pyi +++ b/stdlib/@python2/ssl.pyi @@ -9,7 +9,7 @@ _PCTRTTT = Tuple[_PCTRTT, ...] _PeerCertRetDictType = Dict[str, Union[str, _PCTRTTT, _PCTRTT]] _PeerCertRetType = Union[_PeerCertRetDictType, bytes, None] _EnumRetType = List[Tuple[bytes, str, Union[Set[str], bool]]] -_PasswordType = Union[Callable[[], Union[str, bytes]], str, bytes] +_PasswordType = Union[Callable[[], str | bytes], str, bytes] _SC1ArgT = SSLSocket _SrvnmeCbType = Callable[[_SC1ArgT, Optional[str], SSLSocket], Optional[int]] @@ -179,8 +179,8 @@ class SSLSocket(socket.socket): _context: Optional[SSLContext] = ..., _session: Optional[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: socket._WriteBuffer, nbytes: Optional[int] = ..., flags: int = ...) -> int: ... def recvfrom(self, buflen: int = ..., flags: int = ...) -> tuple[bytes, socket._RetAddress]: ... @@ -190,7 +190,7 @@ class SSLSocket(socket.socket): @overload def sendto(self, data: bytes, flags_or_addr: socket._Address) -> int: ... @overload - def sendto(self, data: bytes, flags_or_addr: Union[int, socket._Address], addr: Optional[socket._Address] = ...) -> int: ... + def sendto(self, data: bytes, flags_or_addr: int | socket._Address, addr: Optional[socket._Address] = ...) -> int: ... def read(self, len: int = ..., buffer: Optional[bytearray] = ...) -> bytes: ... def write(self, data: bytes) -> int: ... def do_handshake(self, block: bool = ...) -> None: ... # block is undocumented diff --git a/stdlib/@python2/string.pyi b/stdlib/@python2/string.pyi index a2b0a9d25ddb..2341f720e867 100644 --- a/stdlib/@python2/string.pyi +++ b/stdlib/@python2/string.pyi @@ -62,7 +62,7 @@ class Formatter(object): def vformat(self, format_string: str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> str: ... def parse(self, format_string: str) -> Iterable[Tuple[str, str, str, str]]: ... 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/@python2/struct.pyi b/stdlib/@python2/struct.pyi index bf27d12783da..94858a3fce78 100644 --- a/stdlib/@python2/struct.pyi +++ b/stdlib/@python2/struct.pyi @@ -4,7 +4,7 @@ from typing import Any, Text, Tuple, Union class error(Exception): ... -_FmtType = Union[bytes, Text] +_FmtType = bytes | Text _BufferType = Union[array[int], bytes, bytearray, buffer, memoryview, mmap] _WriteBufferType = Union[array[Any], bytearray, buffer, memoryview, mmap] diff --git a/stdlib/@python2/subprocess.pyi b/stdlib/@python2/subprocess.pyi index 28a4c0574419..8b55295eb1c6 100644 --- a/stdlib/@python2/subprocess.pyi +++ b/stdlib/@python2/subprocess.pyi @@ -1,7 +1,7 @@ from typing import IO, Any, Callable, Generic, Mapping, Optional, Sequence, Text, Tuple, TypeVar, Union _FILE = Union[None, int, IO[Any]] -_TXT = Union[bytes, Text] +_TXT = bytes | Text _CMD = Union[_TXT, Sequence[_TXT]] _ENV = Union[Mapping[bytes, _TXT], Mapping[Text, _TXT]] diff --git a/stdlib/@python2/sys.pyi b/stdlib/@python2/sys.pyi index 7852911b6532..4285acd4d801 100644 --- a/stdlib/@python2/sys.pyi +++ b/stdlib/@python2/sys.pyi @@ -87,7 +87,7 @@ path_importer_cache: Dict[str, Any] displayhook: Callable[[object], Any] excepthook: Callable[[Type[BaseException], BaseException, TracebackType], Any] exc_type: Optional[type] -exc_value: Union[BaseException, ClassType] +exc_value: BaseException | ClassType exc_traceback: TracebackType class _WindowsVersionType: diff --git a/stdlib/@python2/tarfile.pyi b/stdlib/@python2/tarfile.pyi index 169d7d2c89f6..0b0a40215a02 100644 --- a/stdlib/@python2/tarfile.pyi +++ b/stdlib/@python2/tarfile.pyi @@ -200,8 +200,8 @@ class TarFile(Iterable[TarInfo]): def list(self, verbose: bool = ...) -> None: ... def next(self) -> Optional[TarInfo]: ... def extractall(self, path: Text = ..., members: Optional[Iterable[TarInfo]] = ...) -> None: ... - def extract(self, member: Union[str, TarInfo], path: Text = ...) -> None: ... - def extractfile(self, member: Union[str, TarInfo]) -> Optional[IO[bytes]]: ... + def extract(self, member: str | TarInfo, path: Text = ...) -> None: ... + def extractfile(self, member: str | TarInfo) -> Optional[IO[bytes]]: ... def makedir(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented def makefile(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented def makeunknown(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented diff --git a/stdlib/@python2/tempfile.pyi b/stdlib/@python2/tempfile.pyi index 687e10784585..c6b94da4befd 100644 --- a/stdlib/@python2/tempfile.pyi +++ b/stdlib/@python2/tempfile.pyi @@ -51,33 +51,33 @@ class _TemporaryFileWrapper(IO[str]): # TODO text files def TemporaryFile( - mode: Union[bytes, unicode] = ..., + mode: bytes | unicode = ..., bufsize: int = ..., - suffix: Union[bytes, unicode] = ..., - prefix: Union[bytes, unicode] = ..., - dir: Union[bytes, unicode] = ..., + suffix: bytes | unicode = ..., + prefix: bytes | unicode = ..., + dir: bytes | unicode = ..., ) -> _TemporaryFileWrapper: ... def NamedTemporaryFile( - mode: Union[bytes, unicode] = ..., + mode: bytes | unicode = ..., bufsize: int = ..., - suffix: Union[bytes, unicode] = ..., - prefix: Union[bytes, unicode] = ..., - dir: Union[bytes, unicode] = ..., + suffix: bytes | unicode = ..., + prefix: bytes | unicode = ..., + dir: bytes | unicode = ..., delete: bool = ..., ) -> _TemporaryFileWrapper: ... def SpooledTemporaryFile( max_size: int = ..., - mode: Union[bytes, unicode] = ..., + mode: bytes | unicode = ..., buffering: int = ..., - suffix: Union[bytes, unicode] = ..., - prefix: Union[bytes, unicode] = ..., - dir: Union[bytes, unicode] = ..., + suffix: bytes | unicode = ..., + prefix: bytes | unicode = ..., + dir: bytes | unicode = ..., ) -> _TemporaryFileWrapper: ... class TemporaryDirectory: name: Any def __init__( - self, suffix: Union[bytes, unicode] = ..., prefix: Union[bytes, unicode] = ..., dir: Union[bytes, unicode] = ... + self, suffix: bytes | unicode = ..., prefix: bytes | unicode = ..., dir: bytes | unicode = ... ) -> None: ... def cleanup(self) -> None: ... def __enter__(self) -> Any: ... # Can be str or unicode diff --git a/stdlib/@python2/termios.pyi b/stdlib/@python2/termios.pyi index 0c627f4b72bd..90dd8db9d318 100644 --- a/stdlib/@python2/termios.pyi +++ b/stdlib/@python2/termios.pyi @@ -1,7 +1,7 @@ from _typeshed import FileDescriptorLike from typing import Any, List, Union -_Attr = List[Union[int, List[Union[bytes, int]]]] +_Attr = List[Union[int, List[bytes | int]]] # TODO constants not really documented B0: int diff --git a/stdlib/@python2/time.pyi b/stdlib/@python2/time.pyi index 0a5353fca9c6..b2a916c454d0 100644 --- a/stdlib/@python2/time.pyi +++ b/stdlib/@python2/time.pyi @@ -30,14 +30,14 @@ class struct_time(_struct_time): def __init__(self, o: _TimeTuple, _arg: Any = ...) -> None: ... def __new__(cls, o: _TimeTuple, _arg: Any = ...) -> struct_time: ... -def asctime(t: Union[_TimeTuple, struct_time] = ...) -> str: ... +def asctime(t: _TimeTuple | struct_time = ...) -> str: ... 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 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/@python2/timeit.pyi b/stdlib/@python2/timeit.pyi index dfb6a7b731ae..2a377eb6564e 100644 --- a/stdlib/@python2/timeit.pyi +++ b/stdlib/@python2/timeit.pyi @@ -1,6 +1,6 @@ from typing import IO, Any, Callable, List, Optional, Sequence, Text, Union -_str = Union[str, Text] +_str = str | Text _Timer = Callable[[], float] _stmt = Union[_str, Callable[[], Any]] diff --git a/stdlib/@python2/trace.pyi b/stdlib/@python2/trace.pyi index 810639869e20..1e60b392e565 100644 --- a/stdlib/@python2/trace.pyi +++ b/stdlib/@python2/trace.pyi @@ -34,10 +34,10 @@ class Trace: outfile: Optional[StrPath] = ..., 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], + cmd: str | types.CodeType, globals: Optional[Mapping[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ..., ) -> None: ... diff --git a/stdlib/@python2/turtle.pyi b/stdlib/@python2/turtle.pyi index 6476c9de04ff..9ea800f0d5eb 100644 --- a/stdlib/@python2/turtle.pyi +++ b/stdlib/@python2/turtle.pyi @@ -14,7 +14,7 @@ _AnyColor = Any # TODO: Replace this with a TypedDict once it becomes standardized. _PenState = Dict[str, Any] -_Speed = Union[str, float] +_Speed = str | float _PolygonCoords = Sequence[Tuple[float, float]] # TODO: Type this more accurately @@ -255,8 +255,8 @@ 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] = ..., + width: int | float = ..., + height: int | float = ..., startx: Optional[int] = ..., starty: Optional[int] = ..., ) -> None: ... diff --git a/stdlib/@python2/types.pyi b/stdlib/@python2/types.pyi index cf57c6329665..5d87f75f9ef0 100644 --- a/stdlib/@python2/types.pyi +++ b/stdlib/@python2/types.pyi @@ -96,7 +96,7 @@ class GeneratorType: def send(self, __arg: Any) -> Any: ... @overload def throw( - self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... + self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: Optional[TracebackType] = ... ) -> Any: ... @overload def throw(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> Any: ... @@ -164,7 +164,7 @@ class DictProxyType: # TODO is it possible to have non-string keys? # no __init__ def copy(self) -> Dict[Any, Any]: ... - def get(self, key: str, default: _T = ...) -> Union[Any, _T]: ... + def get(self, key: str, default: _T = ...) -> Any | _T: ... def has_key(self, key: str) -> bool: ... def items(self) -> List[Tuple[str, Any]]: ... def iteritems(self) -> Iterator[Tuple[str, Any]]: ... diff --git a/stdlib/@python2/typing.pyi b/stdlib/@python2/typing.pyi index dfcac95197b0..ed598a0e0a8b 100644 --- a/stdlib/@python2/typing.pyi +++ b/stdlib/@python2/typing.pyi @@ -144,7 +144,7 @@ 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: Optional[TracebackType] = ... ) -> _T_co: ... @overload @abstractmethod @@ -218,9 +218,9 @@ class AbstractSet(Iterable[_T_co], Container[_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]: ... # TODO: argument can be any container? def isdisjoint(self, s: AbstractSet[Any]) -> bool: ... # Implement Sized (but don't have it as a base class). @@ -236,9 +236,9 @@ class MutableSet(AbstractSet[_T], Generic[_T]): def clear(self) -> None: ... def pop(self) -> _T: ... def remove(self, element: _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(object): @@ -278,7 +278,7 @@ class Mapping(Iterable[_KT], Container[_KT], Generic[_KT, _VT_co]): @overload def get(self, k: _KT) -> Optional[_VT_co]: ... @overload - def get(self, k: _KT, default: Union[_VT_co, _T]) -> Union[_VT_co, _T]: ... + def get(self, k: _KT, default: _VT_co | _T) -> _VT_co | _T: ... def keys(self) -> list[_KT]: ... def values(self) -> list[_VT_co]: ... def items(self) -> list[Tuple[_KT, _VT_co]]: ... @@ -299,7 +299,7 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]): @overload def pop(self, k: _KT) -> _VT: ... @overload - def pop(self, k: _KT, default: Union[_VT, _T] = ...) -> Union[_VT, _T]: ... + def pop(self, k: _KT, default: _VT | _T = ...) -> _VT | _T: ... def popitem(self) -> Tuple[_KT, _VT]: ... def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ... @overload @@ -405,7 +405,7 @@ class Match(Generic[AnyStr]): # Can be None if there are no groups or if the last group was unnamed; # otherwise matches the type of the pattern. lastgroup: Optional[Any] - def expand(self, template: Union[str, Text]) -> Any: ... + def expand(self, template: str | Text) -> Any: ... @overload def group(self, group1: int = ...) -> AnyStr: ... @overload @@ -416,9 +416,9 @@ class Match(Generic[AnyStr]): def group(self, group1: str, group2: str, *groups: str) -> Tuple[AnyStr, ...]: ... def groups(self, default: AnyStr = ...) -> Tuple[AnyStr, ...]: ... def groupdict(self, default: AnyStr = ...) -> Dict[str, AnyStr]: ... - 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 @@ -438,7 +438,7 @@ class Pattern(Generic[AnyStr]): def split(self, string: _AnyStr2, maxsplit: int = ...) -> List[_AnyStr2]: ... # Returns either a list of _AnyStr2 or a list of tuples, depending on # whether there are groups in the pattern. - def findall(self, string: Union[bytes, Text], pos: int = ..., endpos: int = ...) -> List[Any]: ... + def findall(self, string: bytes | Text, pos: int = ..., endpos: int = ...) -> List[Any]: ... def finditer(self, string: _AnyStr2, pos: int = ..., endpos: int = ...) -> Iterator[Match[_AnyStr2]]: ... @overload def sub(self, repl: _AnyStr2, string: _AnyStr2, count: int = ...) -> _AnyStr2: ... diff --git a/stdlib/@python2/unicodedata.pyi b/stdlib/@python2/unicodedata.pyi index 19c4a6781660..99747db5f31d 100644 --- a/stdlib/@python2/unicodedata.pyi +++ b/stdlib/@python2/unicodedata.pyi @@ -9,15 +9,15 @@ _T = TypeVar("_T") def bidirectional(__chr: Text) -> Text: ... def category(__chr: Text) -> Text: ... def combining(__chr: Text) -> int: ... -def decimal(__chr: Text, __default: _T = ...) -> Union[int, _T]: ... +def decimal(__chr: Text, __default: _T = ...) -> int | _T: ... def decomposition(__chr: Text) -> Text: ... -def digit(__chr: Text, __default: _T = ...) -> Union[int, _T]: ... +def digit(__chr: Text, __default: _T = ...) -> int | _T: ... def east_asian_width(__chr: Text) -> Text: ... -def lookup(__name: Union[Text, bytes]) -> Text: ... +def lookup(__name: Text | bytes) -> Text: ... def mirrored(__chr: Text) -> int: ... -def name(__chr: Text, __default: _T = ...) -> Union[Text, _T]: ... +def name(__chr: Text, __default: _T = ...) -> Text | _T: ... def normalize(__form: Text, __unistr: Text) -> Text: ... -def numeric(__chr: Text, __default: _T = ...) -> Union[float, _T]: ... +def numeric(__chr: Text, __default: _T = ...) -> float | _T: ... class UCD(object): # The methods below are constructed from the same array in C @@ -26,12 +26,12 @@ class UCD(object): def bidirectional(self, __chr: Text) -> str: ... def category(self, __chr: Text) -> str: ... def combining(self, __chr: Text) -> int: ... - def decimal(self, __chr: Text, __default: _T = ...) -> Union[int, _T]: ... + def decimal(self, __chr: Text, __default: _T = ...) -> int | _T: ... def decomposition(self, __chr: Text) -> str: ... - def digit(self, __chr: Text, __default: _T = ...) -> Union[int, _T]: ... + def digit(self, __chr: Text, __default: _T = ...) -> int | _T: ... def east_asian_width(self, __chr: Text) -> str: ... - def lookup(self, __name: Union[Text, bytes]) -> Text: ... + def lookup(self, __name: Text | bytes) -> Text: ... def mirrored(self, __chr: Text) -> int: ... - def name(self, __chr: Text, __default: _T = ...) -> Union[Text, _T]: ... + def name(self, __chr: Text, __default: _T = ...) -> Text | _T: ... def normalize(self, __form: Text, __unistr: Text) -> Text: ... - def numeric(self, __chr: Text, __default: _T = ...) -> Union[float, _T]: ... + def numeric(self, __chr: Text, __default: _T = ...) -> float | _T: ... diff --git a/stdlib/@python2/unittest.pyi b/stdlib/@python2/unittest.pyi index 57b73a762cfa..21b4c0a7498a 100644 --- a/stdlib/@python2/unittest.pyi +++ b/stdlib/@python2/unittest.pyi @@ -245,10 +245,10 @@ class TextTestRunner: class SkipTest(Exception): ... # TODO precise types -def skipUnless(condition: Any, reason: Union[str, unicode]) -> Any: ... -def skipIf(condition: Any, reason: Union[str, unicode]) -> Any: ... +def skipUnless(condition: Any, reason: str | unicode) -> Any: ... +def skipIf(condition: Any, reason: str | unicode) -> Any: ... def expectedFailure(func: _FT) -> _FT: ... -def skip(reason: Union[str, unicode]) -> Any: ... +def skip(reason: str | unicode) -> Any: ... # not really documented class TestProgram: diff --git a/stdlib/@python2/urllib2.pyi b/stdlib/@python2/urllib2.pyi index 8c355db46d75..fbc05a608fa9 100644 --- a/stdlib/@python2/urllib2.pyi +++ b/stdlib/@python2/urllib2.pyi @@ -3,10 +3,10 @@ from httplib import HTTPConnectionProtocol, HTTPResponse from typing import Any, AnyStr, Callable, Dict, List, Mapping, Optional, Sequence, Text, Tuple, Type, Union from urllib import addinfourl -_string = Union[str, unicode] +_string = str | unicode class URLError(IOError): - reason: Union[str, BaseException] + reason: str | BaseException class HTTPError(URLError, addinfourl): code: int @@ -54,14 +54,14 @@ class OpenerDirector(object): addheaders: List[Tuple[str, str]] def add_handler(self, handler: BaseHandler) -> None: ... def open( - self, fullurl: Union[Request, _string], data: Optional[_string] = ..., timeout: Optional[float] = ... + self, fullurl: Request | _string, data: Optional[_string] = ..., timeout: Optional[float] = ... ) -> Optional[addinfourl]: ... def error(self, proto: _string, *args: Any): ... # Note that this type is somewhat a lie. The return *can* be None if # a custom opener has been installed that fails to handle the request. def urlopen( - url: Union[Request, _string], + url: Request | _string, data: Optional[_string] = ..., timeout: Optional[float] = ..., cafile: Optional[_string] = ..., diff --git a/stdlib/@python2/urlparse.pyi b/stdlib/@python2/urlparse.pyi index 40691239a87b..9cd32b3f38fe 100644 --- a/stdlib/@python2/urlparse.pyi +++ b/stdlib/@python2/urlparse.pyi @@ -1,6 +1,6 @@ from typing import AnyStr, Dict, List, NamedTuple, Optional, Sequence, Tuple, Union, overload -_String = Union[str, unicode] +_String = str | unicode uses_relative: List[str] uses_netloc: List[str] diff --git a/stdlib/@python2/uu.pyi b/stdlib/@python2/uu.pyi index 69d5754bc216..5a04f9881700 100644 --- a/stdlib/@python2/uu.pyi +++ b/stdlib/@python2/uu.pyi @@ -1,6 +1,6 @@ from typing import BinaryIO, Optional, Text, Union -_File = Union[Text, BinaryIO] +_File = Text | BinaryIO class Error(Exception): ... diff --git a/stdlib/@python2/warnings.pyi b/stdlib/@python2/warnings.pyi index a94e9fc86d2e..3e65a337eca2 100644 --- a/stdlib/@python2/warnings.pyi +++ b/stdlib/@python2/warnings.pyi @@ -5,7 +5,7 @@ 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, @@ -13,7 +13,7 @@ def showwarning( line: Optional[str] = ..., ) -> 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: Optional[str] = ... ) -> str: ... def filterwarnings( action: str, message: str = ..., category: Type[Warning] = ..., module: str = ..., lineno: int = ..., append: bool = ... @@ -24,7 +24,7 @@ def resetwarnings() -> None: ... class _OptionError(Exception): ... class WarningMessage: - message: Union[Warning, str] + message: Warning | str category: Type[Warning] filename: str lineno: int @@ -32,7 +32,7 @@ class WarningMessage: line: Optional[str] def __init__( self, - message: Union[Warning, str], + message: Warning | str, category: Type[Warning], filename: str, lineno: int, diff --git a/stdlib/@python2/winsound.pyi b/stdlib/@python2/winsound.pyi index be9a8c660781..d6e72ac78d44 100644 --- a/stdlib/@python2/winsound.pyi +++ b/stdlib/@python2/winsound.pyi @@ -23,5 +23,5 @@ if sys.platform == "win32": @overload def PlaySound(sound: Optional[bytes], flags: Literal[4]) -> None: ... @overload - def PlaySound(sound: Optional[Union[str, bytes]], flags: int) -> None: ... + def PlaySound(sound: Optional[str | bytes], flags: int) -> None: ... def MessageBeep(type: int = ...) -> None: ... diff --git a/stdlib/@python2/xml/dom/minidom.pyi b/stdlib/@python2/xml/dom/minidom.pyi index 2f5988bf76e0..8a5126bb73eb 100644 --- a/stdlib/@python2/xml/dom/minidom.pyi +++ b/stdlib/@python2/xml/dom/minidom.pyi @@ -6,7 +6,7 @@ from xml.sax.xmlreader import XMLReader _T = TypeVar("_T") def parse(file: Union[str, IO[Any]], parser: Optional[XMLReader] = ..., bufsize: Optional[int] = ...): ... -def parseString(string: Union[bytes, _Text], parser: Optional[XMLReader] = ...): ... +def parseString(string: bytes | _Text, parser: Optional[XMLReader] = ...): ... def getDOMImplementation(features=...): ... class Node(xml.dom.Node): diff --git a/stdlib/@python2/xml/etree/ElementInclude.pyi b/stdlib/@python2/xml/etree/ElementInclude.pyi index c6144e40852a..97b8bdd8cc8b 100644 --- a/stdlib/@python2/xml/etree/ElementInclude.pyi +++ b/stdlib/@python2/xml/etree/ElementInclude.pyi @@ -7,9 +7,9 @@ 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: Union[str, bytes, int], parse: str, encoding: Optional[str] = ...) -> 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 # Which can't be represented using Callable... -def include(elem: Element, loader: Optional[Callable[..., Union[str, Element]]] = ...) -> None: ... +def include(elem: Element, loader: Optional[Callable[..., str | Element]] = ...) -> None: ... diff --git a/stdlib/@python2/xml/etree/ElementPath.pyi b/stdlib/@python2/xml/etree/ElementPath.pyi index de49ffcf1209..6e0674cb6e55 100644 --- a/stdlib/@python2/xml/etree/ElementPath.pyi +++ b/stdlib/@python2/xml/etree/ElementPath.pyi @@ -30,4 +30,4 @@ def find(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) - def findall(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) -> List[Element]: ... def findtext( elem: Element, path: str, default: Optional[_T] = ..., namespaces: Optional[Dict[str, str]] = ... -) -> Union[_T, str]: ... +) -> _T | str: ... diff --git a/stdlib/@python2/xml/etree/ElementTree.pyi b/stdlib/@python2/xml/etree/ElementTree.pyi index f7527fa5d890..4ce89452ec47 100644 --- a/stdlib/@python2/xml/etree/ElementTree.pyi +++ b/stdlib/@python2/xml/etree/ElementTree.pyi @@ -33,7 +33,7 @@ _T = TypeVar("_T") # Type for parser inputs. Parser will accept any unicode/str/bytes and coerce, # and this is true in py2 and py3 (even fromstringlist() in python3 can be # called with a heterogeneous list) -_parser_input_type = Union[bytes, Text] +_parser_input_type = bytes | Text # Type for individual tag/attr/ns/text values in args to most functions. # In py2, the library accepts str or unicode everywhere and coerces @@ -42,7 +42,7 @@ _parser_input_type = Union[bytes, Text] # so we exclude it. (why? the parser never produces bytes when it parses XML, # so e.g., element.get(b'name') will always return None for parsed XML, even if # there is a 'name' attribute.) -_str_argument_type = Union[str, Text] +_str_argument_type = str | Text # Type for return values from individual tag/attr/text values # in python2, if the tag/attribute/text wasn't decode-able as ascii, it @@ -82,11 +82,11 @@ class Element(MutableSequence[Element]): @overload def findtext( self, path: _str_argument_type, default: _T, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... - ) -> Union[_T, _str_result_type]: ... + ) -> _T | _str_result_type: ... @overload def get(self, key: _str_argument_type, default: None = ...) -> Optional[_str_result_type]: ... @overload - def get(self, key: _str_argument_type, default: _T) -> Union[_str_result_type, _T]: ... + def get(self, key: _str_argument_type, default: _T) -> _str_result_type | _T: ... def insert(self, __index: int, __element: Element) -> None: ... def items(self) -> ItemsView[_str_result_type, _str_result_type]: ... def iter(self, tag: Optional[_str_argument_type] = ...) -> Generator[Element, None, None]: ... @@ -98,7 +98,7 @@ class Element(MutableSequence[Element]): def makeelement(self, __tag: _str_argument_type, __attrib: Dict[_str_argument_type, _str_argument_type]) -> Element: ... def remove(self, __subelement: Element) -> None: ... def set(self, __key: _str_argument_type, __value: _str_argument_type) -> None: ... - def __delitem__(self, i: Union[int, slice]) -> None: ... + def __delitem__(self, i: int | slice) -> None: ... @overload def __getitem__(self, i: int) -> Element: ... @overload @@ -145,7 +145,7 @@ class ElementTree: @overload def findtext( self, path: _str_argument_type, default: _T, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... - ) -> Union[_T, _str_result_type]: ... + ) -> _T | _str_result_type: ... def findall( self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... ) -> List[Element]: ... diff --git a/stdlib/@python2/xml/sax/__init__.pyi b/stdlib/@python2/xml/sax/__init__.pyi index f4ad8ba34c89..32ef9706ed3e 100644 --- a/stdlib/@python2/xml/sax/__init__.pyi +++ b/stdlib/@python2/xml/sax/__init__.pyi @@ -23,5 +23,5 @@ default_parser_list: List[str] 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, Text], handler: ContentHandler, errorHandler: Optional[ErrorHandler] = ...) -> None: ... +def parseString(string: bytes | Text, handler: ContentHandler, errorHandler: Optional[ErrorHandler] = ...) -> None: ... def _create_parser(parser_name: str) -> XMLReader: ... diff --git a/stdlib/@python2/xmlrpclib.pyi b/stdlib/@python2/xmlrpclib.pyi index 868de39ee7f7..3d3a0a6b099e 100644 --- a/stdlib/@python2/xmlrpclib.pyi +++ b/stdlib/@python2/xmlrpclib.pyi @@ -187,7 +187,7 @@ class MultiCall: def __getattr__(self, name: str) -> _MultiCallMethod: ... def __call__(self) -> MultiCallIterator: ... -def getparser(use_datetime: bool = ...) -> Tuple[Union[ExpatParser, SlowParser], Unmarshaller]: ... +def getparser(use_datetime: bool = ...) -> Tuple[ExpatParser | SlowParser, Unmarshaller]: ... def dumps( params: Union[Tuple[Any, ...], Fault], methodname: Optional[str] = ..., @@ -217,7 +217,7 @@ class Transport: def request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> Tuple[Any, ...]: ... verbose: bool def single_request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> Tuple[Any, ...]: ... - def getparser(self) -> Tuple[Union[ExpatParser, SlowParser], Unmarshaller]: ... + def getparser(self) -> Tuple[ExpatParser | SlowParser, Unmarshaller]: ... def get_host_info(self, host: _hostDesc) -> Tuple[str, Optional[List[Tuple[str, str]]], Optional[Mapping[Any, Any]]]: ... def make_connection(self, host: _hostDesc) -> HTTPConnection: ... def close(self) -> None: ... diff --git a/stdlib/@python2/zipfile.pyi b/stdlib/@python2/zipfile.pyi index 043aa5e342c7..3dbfd035c85b 100644 --- a/stdlib/@python2/zipfile.pyi +++ b/stdlib/@python2/zipfile.pyi @@ -3,7 +3,7 @@ from _typeshed import StrPath from types import TracebackType from typing import IO, Any, Callable, Dict, Iterable, List, Optional, Pattern, Protocol, Sequence, Text, Tuple, Type, Union -_SZI = Union[Text, ZipInfo] +_SZI = Text | ZipInfo _DT = Tuple[int, int, int, int, int, int] class BadZipfile(Exception): ... diff --git a/stdlib/@python2/zipimport.pyi b/stdlib/@python2/zipimport.pyi index 14aa86bb90ad..61529f6d21c2 100644 --- a/stdlib/@python2/zipimport.pyi +++ b/stdlib/@python2/zipimport.pyi @@ -6,7 +6,7 @@ class ZipImportError(ImportError): ... class zipimporter(object): archive: str prefix: str - def __init__(self, path: Union[str, bytes]) -> None: ... + def __init__(self, path: str | bytes) -> None: ... def find_module(self, fullname: str, path: Optional[str] = ...) -> Optional[zipimporter]: ... def get_code(self, fullname: str) -> CodeType: ... def get_data(self, pathname: str) -> str: ... diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index 9d420af898e2..b62c2b0e34f8 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -20,19 +20,19 @@ 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_decode(__data: 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_decode(__data: 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 readbuffer_encode(__data: str | bytes, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... +def unicode_escape_decode(__data: str | bytes, __errors: Optional[str] = ...) -> Tuple[str, int]: ... def unicode_escape_encode(__str: str, __errors: Optional[str] = ...) -> 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: Optional[str] = ...) -> Tuple[str, int]: ... + def unicode_internal_encode(__obj: str | bytes, __errors: Optional[str] = ...) -> 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]: ... diff --git a/stdlib/_curses.pyi b/stdlib/_curses.pyi index b64fa66e08b5..9d5084902ce1 100644 --- a/stdlib/_curses.pyi +++ b/stdlib/_curses.pyi @@ -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/_msi.pyi b/stdlib/_msi.pyi index a8f9c60bbadd..a026d4259c1e 100644 --- a/stdlib/_msi.pyi +++ b/stdlib/_msi.pyi @@ -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) -> Optional[str | bytes]: ... 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..90d7015bb16e 100644 --- a/stdlib/_osx_support.pyi +++ b/stdlib/_osx_support.pyi @@ -30,4 +30,4 @@ def customize_config_vars(_config_vars: Dict[str, str]) -> Dict[str, str]: ... def customize_compiler(_config_vars: Dict[str, str]) -> Dict[str, str]: ... def get_platform_osx( _config_vars: Dict[str, str], osname: _T, release: _K, machine: _V -) -> Tuple[Union[str, _T], Union[str, _K], Union[str, _V]]: ... +) -> Tuple[str | _T, str | _K, str | _V]: ... diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index 60719553b46b..56ba4c635a19 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -131,7 +131,7 @@ class HasFileno(Protocol): def fileno(self) -> int: ... FileDescriptor = int # stable -FileDescriptorLike = Union[int, HasFileno] # stable +FileDescriptorLike = int | HasFileno # stable # stable class SupportsRead(Protocol[_T_co]): diff --git a/stdlib/_weakrefset.pyi b/stdlib/_weakrefset.pyi index c369584aa243..2d0d3eaf74c1 100644 --- a/stdlib/_weakrefset.pyi +++ b/stdlib/_weakrefset.pyi @@ -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..2457d65d2715 100644 --- a/stdlib/_winapi.pyi +++ b/stdlib/_winapi.pyi @@ -112,7 +112,7 @@ def ReadFile(handle: int, size: int, overlapped: Literal[True]) -> Tuple[Overlap @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] ) -> None: ... @@ -125,7 +125,7 @@ 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 = ... diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index 2d5efdf4e98a..c8df032fce67 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -65,7 +65,7 @@ class _ActionsContainer: self, *name_or_flags: str, action: Union[str, Type[Action]] = ..., - nargs: Union[int, str] = ..., + nargs: int | str = ..., const: Any = ..., default: Any = ..., type: Union[Callable[[str], _T], Callable[[str], _T], FileType] = ..., @@ -269,7 +269,7 @@ class MetavarTypeHelpFormatter(HelpFormatter): ... class Action(_AttributeHolder): option_strings: Sequence[str] dest: str - nargs: Optional[Union[int, str]] + nargs: Optional[int | str] const: Any default: Any type: Union[Callable[[str], Any], FileType, None] @@ -281,7 +281,7 @@ class Action(_AttributeHolder): self, option_strings: Sequence[str], dest: str, - nargs: Optional[Union[int, str]] = ..., + nargs: Optional[int | str] = ..., const: Optional[_T] = ..., default: Union[_T, str, None] = ..., type: Optional[Union[Callable[[str], _T], Callable[[str], _T], FileType]] = ..., diff --git a/stdlib/array.pyi b/stdlib/array.pyi index a215494d2ff0..9e2676d15fc3 100644 --- a/stdlib/array.pyi +++ b/stdlib/array.pyi @@ -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..06a493dd7295 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -158,8 +158,8 @@ _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 = ..., @@ -167,8 +167,8 @@ if sys.version_info >= (3, 8): ) -> Module: ... @overload def parse( - source: Union[str, bytes], - filename: Union[str, bytes] = ..., + source: str | bytes, + filename: str | bytes = ..., mode: str = ..., *, type_comments: bool = ..., @@ -177,9 +177,9 @@ if sys.version_info >= (3, 8): 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: ... @@ -199,7 +199,7 @@ 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: 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]: ... diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index a0848da5b250..de460300d789 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -322,7 +322,7 @@ 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] = ..., diff --git a/stdlib/asyncio/base_subprocess.pyi b/stdlib/asyncio/base_subprocess.pyi index acdf985205ab..392313fed57d 100644 --- a/stdlib/asyncio/base_subprocess.pyi +++ b/stdlib/asyncio/base_subprocess.pyi @@ -21,7 +21,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport): self, loop: events.AbstractEventLoop, protocol: protocols.SubprocessProtocol, - args: Union[str, bytes, Sequence[Union[str, bytes]]], + args: Union[str, bytes, Sequence[str | bytes]], shell: bool, stdin: _File, stdout: _File, @@ -33,7 +33,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport): ) -> None: ... def _start( self, - args: Union[str, bytes, Sequence[Union[str, bytes]]], + args: Union[str, bytes, Sequence[str | bytes]], shell: bool, stdin: _File, stdout: _File, diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 98bae9f40c18..e4f80b607019 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -397,7 +397,7 @@ 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] = ..., diff --git a/stdlib/asyncio/format_helpers.pyi b/stdlib/asyncio/format_helpers.pyi index 5c075a910931..2afbe5593e7b 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]] diff --git a/stdlib/asyncio/futures.pyi b/stdlib/asyncio/futures.pyi index 1252c02cb58d..4700cf16c185 100644 --- a/stdlib/asyncio/futures.pyi +++ b/stdlib/asyncio/futures.pyi @@ -54,7 +54,7 @@ class Future(Awaitable[_T], Iterable[_T]): def exception(self) -> Optional[BaseException]: ... 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 diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index 7480c3394e70..bfe5d75cff94 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -9,7 +9,7 @@ _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] @@ -17,11 +17,11 @@ if sys.version_info >= (3, 9): 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: ... diff --git a/stdlib/asyncio/streams.pyi b/stdlib/asyncio/streams.pyi index f0879b8daa33..fd47e8ac00ee 100644 --- a/stdlib/asyncio/streams.pyi +++ b/stdlib/asyncio/streams.pyi @@ -17,7 +17,7 @@ if sys.version_info < (3, 8): async def open_connection( host: Optional[str] = ..., - port: Optional[Union[int, str]] = ..., + port: Optional[int | str] = ..., *, loop: Optional[events.AbstractEventLoop] = ..., limit: int = ..., @@ -27,7 +27,7 @@ async def open_connection( async def start_server( client_connected_cb: _ClientConnectedCallback, host: Optional[str] = ..., - port: Optional[Union[int, str]] = ..., + port: Optional[int | str] = ..., *, loop: Optional[events.AbstractEventLoop] = ..., limit: int = ..., diff --git a/stdlib/asyncio/subprocess.pyi b/stdlib/asyncio/subprocess.pyi index 9d28d9e2bc4b..d07b6ed0e573 100644 --- a/stdlib/asyncio/subprocess.pyi +++ b/stdlib/asyncio/subprocess.pyi @@ -8,7 +8,7 @@ from typing_extensions import Literal if sys.version_info >= (3, 8): _ExecArg = StrOrBytesPath else: - _ExecArg = Union[str, bytes] + _ExecArg = str | bytes PIPE: int STDOUT: int @@ -20,7 +20,7 @@ class SubprocessStreamProtocol(streams.FlowControlMixin, protocols.SubprocessPro stderr: Optional[streams.StreamReader] 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_data_received(self, fd: int, data: bytes | str) -> None: ... def pipe_connection_lost(self, fd: int, exc: Optional[Exception]) -> None: ... def process_exited(self) -> None: ... @@ -42,7 +42,7 @@ class Process: if sys.version_info >= (3, 10): async def create_subprocess_shell( - cmd: Union[str, bytes], + cmd: str | bytes, stdin: Union[int, IO[Any], None] = ..., stdout: Union[int, IO[Any], None] = ..., stderr: Union[int, IO[Any], None] = ..., @@ -96,7 +96,7 @@ if sys.version_info >= (3, 10): else: async def create_subprocess_shell( - cmd: Union[str, bytes], + cmd: str | bytes, stdin: Union[int, IO[Any], None] = ..., stdout: Union[int, IO[Any], None] = ..., stderr: Union[int, IO[Any], None] = ..., diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index c306e9655daa..09ab3c49b166 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -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,11 +126,11 @@ 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, ] ]: ... @@ -192,7 +192,7 @@ else: @overload def gather( coro_or_future1: _FutureT[_T1], *, loop: Optional[AbstractEventLoop] = ..., return_exceptions: bool = ... - ) -> Future[Tuple[Union[_T1, BaseException]]]: ... + ) -> Future[Tuple[_T1 | BaseException]]: ... @overload def gather( coro_or_future1: _FutureT[_T1], @@ -200,7 +200,7 @@ else: *, loop: Optional[AbstractEventLoop] = ..., 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], @@ -209,7 +209,7 @@ else: *, loop: Optional[AbstractEventLoop] = ..., 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], @@ -220,7 +220,7 @@ else: loop: Optional[AbstractEventLoop] = ..., 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( @@ -234,11 +234,11 @@ else: 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, ] ]: ... diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index 0bd3f0adb142..c77c8613b803 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -7,7 +7,7 @@ if sys.version_info >= (3, 8): # These are based in socket, maybe move them out into _typeshed.pyi or such _Address = Union[Tuple[Any, ...], str] _RetAddress = Any - _WriteBuffer = Union[bytearray, memoryview] + _WriteBuffer = bytearray | memoryview _CMSG = Tuple[int, int, bytes] class TransportSocket: def __init__(self, sock: socket.socket) -> None: ... @@ -28,16 +28,16 @@ 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: ... else: diff --git a/stdlib/base64.pyi b/stdlib/base64.pyi index 47118516ca82..f01846e5db2b 100644 --- a/stdlib/base64.pyi +++ b/stdlib/base64.pyi @@ -2,26 +2,26 @@ 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 b64decode(s: str | bytes, altchars: Optional[bytes] = ..., 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: Optional[bytes] = ...) -> 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..7a586b0666fd 100644 --- a/stdlib/bdb.pyi +++ b/stdlib/bdb.pyi @@ -59,11 +59,11 @@ class Bdb: def get_stack(self, f: Optional[FrameType], t: Optional[TracebackType]) -> 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: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ... ) -> None: ... def runeval(self, expr: str, globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ...) -> None: ... def runctx( - self, cmd: Union[str, CodeType], globals: Optional[Dict[str, Any]], locals: Optional[Mapping[str, Any]] + self, cmd: str | CodeType, globals: Optional[Dict[str, Any]], locals: Optional[Mapping[str, Any]] ) -> None: ... def runcall(self, __func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ... 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 76130795690b..8489e15442ab 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -386,16 +386,16 @@ class str(Sequence[str]): def zfill(self, __width: int) -> str: ... @staticmethod @overload - def maketrans(__x: Union[Dict[int, _T], Dict[str, _T], Dict[Union[str, int], _T]]) -> Dict[int, _T]: ... + def maketrans(__x: Union[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: Optional[str] = ...) -> 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]: ... @@ -424,7 +424,7 @@ class bytes(ByteString): def capitalize(self) -> bytes: ... def center(self, __width: int, __fillchar: bytes = ...) -> bytes: ... def count( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... ) -> int: ... def decode(self, encoding: str = ..., errors: str = ...) -> str: ... def endswith( @@ -435,14 +435,14 @@ class bytes(ByteString): ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> bytes: ... def find( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... ) -> int: ... if sys.version_info >= (3, 8): - def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: int = ...) -> str: ... + def hex(self, sep: str | bytes = ..., bytes_per_sep: int = ...) -> str: ... else: def hex(self) -> str: ... def index( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... ) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... @@ -453,7 +453,7 @@ 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: int, __fillchar: bytes = ...) -> bytes: ... def lower(self) -> bytes: ... def lstrip(self, __bytes: Optional[bytes] = ...) -> bytes: ... @@ -463,10 +463,10 @@ class bytes(ByteString): def removeprefix(self, __prefix: bytes) -> bytes: ... def removesuffix(self, __suffix: bytes) -> bytes: ... def rfind( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... ) -> int: ... def rindex( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... ) -> int: ... def rjust(self, __width: int, __fillchar: bytes = ...) -> bytes: ... def rpartition(self, __sep: bytes) -> Tuple[bytes, bytes, bytes]: ... @@ -504,7 +504,7 @@ class bytes(ByteString): def __rmul__(self, n: int) -> bytes: ... def __mod__(self, value: Any) -> bytes: ... # Incompatible with Sequence.__contains__ - def __contains__(self, o: Union[int, bytes]) -> bool: ... # type: ignore + def __contains__(self, o: int | bytes) -> bool: ... # type: ignore def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... def __lt__(self, x: bytes) -> bool: ... @@ -526,7 +526,7 @@ class bytearray(MutableSequence[int], ByteString): def capitalize(self) -> bytearray: ... def center(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... def count( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... ) -> int: ... def copy(self) -> bytearray: ... def decode(self, encoding: str = ..., errors: str = ...) -> str: ... @@ -539,14 +539,14 @@ class bytearray(MutableSequence[int], ByteString): def expandtabs(self, tabsize: int = ...) -> bytearray: ... def extend(self, __iterable_of_ints: Iterable[int]) -> None: ... def find( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... ) -> int: ... if sys.version_info >= (3, 8): - def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: int = ...) -> str: ... + def hex(self, sep: str | bytes = ..., bytes_per_sep: int = ...) -> str: ... else: def hex(self) -> str: ... def index( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... ) -> int: ... def insert(self, __index: int, __item: int) -> None: ... def isalnum(self) -> bool: ... @@ -558,7 +558,7 @@ 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: int, __fillchar: bytes = ...) -> bytearray: ... def lower(self) -> bytearray: ... def lstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... @@ -568,10 +568,10 @@ class bytearray(MutableSequence[int], ByteString): def removesuffix(self, __suffix: bytes) -> bytearray: ... def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytearray: ... def rfind( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... ) -> int: ... def rindex( - self, __sub: Union[bytes, int], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... ) -> int: ... def rjust(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... def rpartition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... @@ -608,7 +608,7 @@ class bytearray(MutableSequence[int], ByteString): def __setitem__(self, i: int, x: int) -> None: ... @overload def __setitem__(self, s: slice, x: Union[Iterable[int], bytes]) -> None: ... - def __delitem__(self, i: Union[int, slice]) -> None: ... + def __delitem__(self, i: int | slice) -> None: ... def __add__(self, s: bytes) -> bytearray: ... def __iadd__(self, s: Iterable[int]) -> bytearray: ... def __mul__(self, n: int) -> bytearray: ... @@ -616,7 +616,7 @@ class bytearray(MutableSequence[int], ByteString): def __imul__(self, n: int) -> bytearray: ... def __mod__(self, value: Any) -> bytes: ... # Incompatible with Sequence.__contains__ - def __contains__(self, o: Union[int, bytes]) -> bool: ... # type: ignore + def __contains__(self, o: int | bytes) -> bool: ... # type: ignore def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... def __lt__(self, x: bytes) -> bool: ... @@ -633,7 +633,7 @@ class memoryview(Sized, Sequence[int]): readonly: bool ndim: int - obj: Union[bytes, bytearray] + obj: bytes | bytearray c_contiguous: bool f_contiguous: bool contiguous: bool @@ -664,7 +664,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: int = ...) -> str: ... + def hex(self, sep: str | bytes = ..., bytes_per_sep: int = ...) -> str: ... else: def hex(self) -> str: ... @@ -724,7 +724,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: int) -> Tuple[_T_co, ...]: ... def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ... def count(self, __value: Any) -> int: ... @@ -771,7 +771,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: int) -> List[_T]: ... @@ -855,12 +855,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 __or__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... + def __ior__(self, s: AbstractSet[_S]) -> Set[_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 __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: ... @@ -884,9 +884,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: ... @@ -950,7 +950,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: ... @@ -970,7 +970,7 @@ 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( @@ -1027,14 +1027,14 @@ def getattr(__o: Any, name: str) -> Any: ... @overload def getattr(__o: Any, name: str, __default: None) -> Optional[Any]: ... @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 @@ -1114,9 +1114,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 = ... @@ -1128,16 +1128,16 @@ 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] +_OpenFile = StrOrBytesPath | int _Opener = Callable[[str, int], int] # Text mode: always returns a TextIOWrapper @@ -1226,7 +1226,7 @@ def open( closefd: bool = ..., opener: Optional[_Opener] = ..., ) -> IO[Any]: ... -def ord(__c: Union[str, bytes]) -> int: ... +def ord(__c: str | bytes) -> int: ... def print( *values: object, sep: Optional[str] = ..., @@ -1295,15 +1295,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]: ... diff --git a/stdlib/bz2.pyi b/stdlib/bz2.pyi index acbbbbbf507a..1def08a50c5c 100644 --- a/stdlib/bz2.pyi +++ b/stdlib/bz2.pyi @@ -65,7 +65,7 @@ def open( @overload def open( filename: StrOrBytesPath, - mode: Union[_ReadBinaryMode, _WriteBinaryMode] = ..., + mode: _ReadBinaryMode | _WriteBinaryMode = ..., compresslevel: int = ..., encoding: None = ..., errors: None = ..., @@ -74,7 +74,7 @@ def open( @overload def open( filename: StrOrBytesPath, - mode: Union[_ReadTextMode, _WriteTextMode], + mode: _ReadTextMode | _WriteTextMode, compresslevel: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ..., @@ -90,7 +90,7 @@ 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 @@ -109,7 +109,7 @@ class BZ2File(BaseStream, IO[bytes]): def __init__( self, filename: StrOrBytesPath, - mode: Union[_ReadBinaryMode, _WriteBinaryMode] = ..., + mode: _ReadBinaryMode | _WriteBinaryMode = ..., buffering: Optional[Any] = ..., compresslevel: int = ..., ) -> None: ... diff --git a/stdlib/cProfile.pyi b/stdlib/cProfile.pyi index 6648ed5b94a3..a887a1016d01 100644 --- a/stdlib/cProfile.pyi +++ b/stdlib/cProfile.pyi @@ -3,9 +3,9 @@ from _typeshed import 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: Optional[str] = ..., 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: Optional[str] = ..., sort: str | int = ... ) -> None: ... _SelfT = TypeVar("_SelfT", bound=Profile) @@ -19,7 +19,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: ... @@ -30,4 +30,4 @@ class Profile: def __enter__(self: _SelfT) -> _SelfT: ... 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/codecs.pyi b/stdlib/codecs.pyi index ab83caf18848..b4327040f001 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -140,13 +140,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. @@ -161,8 +161,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 diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 635d32ebd294..8d78b035d48e 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -74,7 +74,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: ... @@ -100,28 +100,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: ... 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 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: ... @@ -142,19 +142,19 @@ class UserString(Sequence[str]): def lstrip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ... @staticmethod @overload - def maketrans(x: Union[Dict[int, _T], Dict[str, _T], Dict[Union[str, int], _T]]) -> Dict[int, _T]: ... + def maketrans(x: Union[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: ... diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 46e5201a10bb..8d9392c5739c 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -116,19 +116,19 @@ class RawConfigParser(_parser): @overload def getint( self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T = ... - ) -> Union[int, _T]: ... + ) -> int | _T: ... @overload def getfloat(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> float: ... @overload def getfloat( self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T = ... - ) -> Union[float, _T]: ... + ) -> float | _T: ... @overload def getboolean(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> bool: ... @overload def getboolean( self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T = ... - ) -> Union[bool, _T]: ... + ) -> bool | _T: ... def _get_conv( self, section: str, @@ -145,7 +145,7 @@ class RawConfigParser(_parser): @overload def get( self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T - ) -> Union[str, _T]: ... + ) -> str | _T: ... @overload def items(self, *, raw: bool = ..., vars: Optional[_section] = ...) -> AbstractSet[Tuple[str, SectionProxy]]: ... @overload @@ -177,19 +177,19 @@ class SectionProxy(MutableMapping[str, str]): @overload def getint(self, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> 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: Optional[_section] = ...) -> int | _T: ... @overload def getfloat(self, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> float: ... @overload def getfloat( self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: Optional[_section] = ... - ) -> Union[float, _T]: ... + ) -> float | _T: ... @overload def getboolean(self, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> bool: ... @overload def getboolean( self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: Optional[_section] = ... - ) -> Union[bool, _T]: ... + ) -> bool | _T: ... # SectionProxy can have arbitrary attributes when custom converters are used def __getattr__(self, key: str) -> Callable[..., Any]: ... diff --git a/stdlib/contextvars.pyi b/stdlib/contextvars.pyi index 069a6786688e..b29decbef2b8 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): diff --git a/stdlib/crypt.pyi b/stdlib/crypt.pyi index d8db0ffb4cea..155666ab1555 100644 --- a/stdlib/crypt.pyi +++ b/stdlib/crypt.pyi @@ -18,4 +18,4 @@ if sys.version_info >= (3, 7): else: def mksalt(method: Optional[_Method] = ...) -> str: ... -def crypt(word: str, salt: Optional[Union[str, _Method]] = ...) -> str: ... +def crypt(word: str, salt: Optional[str | _Method] = ...) -> str: ... 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..679741937fba 100644 --- a/stdlib/curses/textpad.pyi +++ b/stdlib/curses/textpad.pyi @@ -7,5 +7,5 @@ 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 do_command(self, ch: str | int) -> None: ... def gather(self) -> str: ... diff --git a/stdlib/dbm/__init__.pyi b/stdlib/dbm/__init__.pyi index f2d64446a6a2..c48dbf977d64 100644 --- a/stdlib/dbm/__init__.pyi +++ b/stdlib/dbm/__init__.pyi @@ -2,8 +2,8 @@ from types import TracebackType from typing import Iterator, MutableMapping, Optional, Tuple, Type, Union from typing_extensions import Literal -_KeyType = Union[str, bytes] -_ValueType = Union[str, bytes] +_KeyType = str | bytes +_ValueType = str | bytes _TFlags = Literal[ "r", "w", diff --git a/stdlib/dbm/dumb.pyi b/stdlib/dbm/dumb.pyi index 0b8ee50a79b7..fe0ff19ec35b 100644 --- a/stdlib/dbm/dumb.pyi +++ b/stdlib/dbm/dumb.pyi @@ -1,8 +1,8 @@ from types import TracebackType from typing import Iterator, MutableMapping, Optional, Type, Union -_KeyType = Union[str, bytes] -_ValueType = Union[str, bytes] +_KeyType = str | bytes +_ValueType = str | bytes error = OSError diff --git a/stdlib/dbm/gnu.pyi b/stdlib/dbm/gnu.pyi index 20033ded6373..985d238c426a 100644 --- a/stdlib/dbm/gnu.pyi +++ b/stdlib/dbm/gnu.pyi @@ -2,8 +2,8 @@ from types import TracebackType from typing import List, Optional, Type, TypeVar, Union, overload _T = TypeVar("_T") -_KeyType = Union[str, bytes] -_ValueType = Union[str, bytes] +_KeyType = str | bytes +_ValueType = str | bytes class error(OSError): ... @@ -26,7 +26,7 @@ class _gdbm: @overload def get(self, k: _KeyType) -> Optional[bytes]: ... @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 020131543e13..3fce371b74f4 100644 --- a/stdlib/dbm/ndbm.pyi +++ b/stdlib/dbm/ndbm.pyi @@ -2,8 +2,8 @@ from types import TracebackType from typing import List, Optional, Type, TypeVar, Union, overload _T = TypeVar("_T") -_KeyType = Union[str, bytes] -_ValueType = Union[str, bytes] +_KeyType = str | bytes +_ValueType = str | bytes class error(OSError): ... @@ -24,7 +24,7 @@ class _dbm: @overload def get(self, k: _KeyType) -> Optional[bytes]: ... @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..41bb90eaef21 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -2,7 +2,7 @@ import numbers from types import TracebackType from typing import Any, Container, Dict, List, NamedTuple, Optional, Sequence, Tuple, Type, TypeVar, Union, overload -_Decimal = Union[Decimal, int] +_Decimal = Decimal | int _DecimalNew = Union[Decimal, float, str, Tuple[int, Sequence[int], int]] _ComparableNum = Union[Decimal, float, numbers.Rational] _DecimalT = TypeVar("_DecimalT", bound=Decimal) diff --git a/stdlib/distutils/cmd.pyi b/stdlib/distutils/cmd.pyi index 93bfc7c9dbb5..26bf3bf1b1a5 100644 --- a/stdlib/distutils/cmd.pyi +++ b/stdlib/distutils/cmd.pyi @@ -20,7 +20,7 @@ class Command: 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: ... diff --git a/stdlib/distutils/command/config.pyi b/stdlib/distutils/command/config.pyi index 6b57a64b48b1..592de5e0cf5b 100644 --- a/stdlib/distutils/command/config.pyi +++ b/stdlib/distutils/command/config.pyi @@ -11,7 +11,7 @@ class config(Command): description: str = ... # Tuple is full name, short name, description user_options: Sequence[Tuple[str, Optional[str], str]] = ... - compiler: Optional[Union[str, CCompiler]] = ... + compiler: Optional[str | CCompiler] = ... cc: Optional[str] = ... include_dirs: Optional[Sequence[str]] = ... libraries: Optional[Sequence[str]] = ... diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index 8655371adfaa..80347c843209 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -3,7 +3,7 @@ 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: ... + def __init__(self, path: Optional[int | StrOrBytesPath] = ...) -> None: ... name: Optional[str] version: Optional[str] author: Optional[str] diff --git a/stdlib/distutils/filelist.pyi b/stdlib/distutils/filelist.pyi index 99e26218f171..6bd392b7d616 100644 --- a/stdlib/distutils/filelist.pyi +++ b/stdlib/distutils/filelist.pyi @@ -16,7 +16,7 @@ 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: Optional[str] = ..., is_regex: Literal[0, False] = ... ) -> bool: ... @overload def include_pattern(self, pattern: Union[str, Pattern[str]], *, is_regex: Literal[True, 1] = ...) -> bool: ... @@ -24,13 +24,13 @@ class FileList: def include_pattern( self, pattern: Union[str, Pattern[str]], - anchor: Union[int, bool] = ..., + anchor: int | bool = ..., prefix: Optional[str] = ..., - is_regex: Union[int, bool] = ..., + 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: Optional[str] = ..., is_regex: Literal[0, False] = ... ) -> bool: ... @overload def exclude_pattern(self, pattern: Union[str, Pattern[str]], *, is_regex: Literal[True, 1] = ...) -> bool: ... @@ -38,23 +38,23 @@ class FileList: def exclude_pattern( self, pattern: Union[str, Pattern[str]], - anchor: Union[int, bool] = ..., + anchor: int | bool = ..., prefix: Optional[str] = ..., - is_regex: Union[int, bool] = ..., + 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: Optional[str] = ..., is_regex: Literal[False, 0] = ... ) -> Pattern[str]: ... @overload def translate_pattern(pattern: Union[str, Pattern[str]], *, is_regex: Literal[True, 1] = ...) -> Pattern[str]: ... @overload def translate_pattern( pattern: Union[str, Pattern[str]], - anchor: Union[int, bool] = ..., + anchor: int | bool = ..., prefix: Optional[str] = ..., - is_regex: Union[int, bool] = ..., + is_regex: int | bool = ..., ) -> Pattern[str]: ... diff --git a/stdlib/distutils/sysconfig.pyi b/stdlib/distutils/sysconfig.pyi index 4b4baf416ffa..a75ae9db7aa5 100644 --- a/stdlib/distutils/sysconfig.pyi +++ b/stdlib/distutils/sysconfig.pyi @@ -5,7 +5,7 @@ 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_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: ... diff --git a/stdlib/distutils/version.pyi b/stdlib/distutils/version.pyi index 311b0bead960..6af86f2564d1 100644 --- a/stdlib/distutils/version.pyi +++ b/stdlib/distutils/version.pyi @@ -6,10 +6,10 @@ _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: ... @abstractmethod @@ -17,7 +17,7 @@ class Version: @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] @@ -26,13 +26,13 @@ class StrictVersion(Version): def __init__(self, vstring: Optional[str] = ...) -> 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], ...] + version: Tuple[str | int, ...] def __init__(self, vstring: Optional[str] = ...) -> 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..b263199a3a6d 100644 --- a/stdlib/doctest.pyi +++ b/stdlib/doctest.pyi @@ -68,7 +68,7 @@ class DocTest: 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] ) -> DocTest: ... diff --git a/stdlib/email/_header_value_parser.pyi b/stdlib/email/_header_value_parser.pyi index 22a2a643ed1b..eba7278b2b84 100644 --- a/stdlib/email/_header_value_parser.pyi +++ b/stdlib/email/_header_value_parser.pyi @@ -23,7 +23,7 @@ def quote_string(value: Any) -> str: ... if sys.version_info >= (3, 7): rfc2047_matcher: Pattern[str] -class TokenList(List[Union[TokenList, Terminal]]): +class TokenList(List[TokenList | Terminal]): token_type: Optional[str] = ... syntactic_break: bool = ... ew_combine_allowed: bool = ... diff --git a/stdlib/email/header.pyi b/stdlib/email/header.pyi index 1a5e1a2e4853..a877827af63a 100644 --- a/stdlib/email/header.pyi +++ b/stdlib/email/header.pyi @@ -11,13 +11,13 @@ class Header: continuation_ws: str = ..., errors: str = ..., ) -> None: ... - def append(self, s: Union[bytes, str], charset: Union[Charset, str, None] = ..., errors: str = ...) -> None: ... + def append(self, s: bytes | str, charset: Union[Charset, str, None] = ..., errors: str = ...) -> None: ... def encode(self, splitchars: str = ..., maxlinelen: Optional[int] = ..., 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, Optional[str]]]: ... def make_header( decoded_seq: List[Tuple[bytes, Optional[str]]], maxlinelen: Optional[int] = ..., diff --git a/stdlib/email/headerregistry.pyi b/stdlib/email/headerregistry.pyi index b661496b9b62..7b8ae7fac6af 100644 --- a/stdlib/email/headerregistry.pyi +++ b/stdlib/email/headerregistry.pyi @@ -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): ... diff --git a/stdlib/email/message.pyi b/stdlib/email/message.pyi index 37c9caffa916..8c22c8459d09 100644 --- a/stdlib/email/message.pyi +++ b/stdlib/email/message.pyi @@ -34,7 +34,7 @@ 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(self, name: str, failobj: _T = ...) -> _HeaderType | _T: ... def get_all(self, name: str, failobj: _T = ...) -> Union[List[_HeaderType], _T]: ... def add_header(self, _name: str, _value: str, **_params: _ParamsType) -> None: ... def replace_header(self, _name: str, _value: _HeaderType) -> None: ... @@ -44,13 +44,13 @@ class Message: 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_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_content_charset(self, failobj: _T = ...) -> _T | str: ... def get_charsets(self, failobj: _T = ...) -> Union[_T, List[str]]: ... def walk(self) -> Generator[Message, None, None]: ... def get_content_disposition(self) -> Optional[str]: ... diff --git a/stdlib/email/mime/application.pyi b/stdlib/email/mime/application.pyi index d1b2f1dad6b4..5acee4b3cf25 100644 --- a/stdlib/email/mime/application.pyi +++ b/stdlib/email/mime/application.pyi @@ -7,7 +7,7 @@ _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] = ..., *, diff --git a/stdlib/email/mime/audio.pyi b/stdlib/email/mime/audio.pyi index 9bd5b5ca57b0..261992e9caf4 100644 --- a/stdlib/email/mime/audio.pyi +++ b/stdlib/email/mime/audio.pyi @@ -7,7 +7,7 @@ _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] class MIMEAudio(MIMENonMultipart): def __init__( self, - _audiodata: Union[str, bytes], + _audiodata: str | bytes, _subtype: Optional[str] = ..., _encoder: Callable[[MIMEAudio], None] = ..., *, diff --git a/stdlib/email/mime/image.pyi b/stdlib/email/mime/image.pyi index f192494ec74c..b0044aa627c1 100644 --- a/stdlib/email/mime/image.pyi +++ b/stdlib/email/mime/image.pyi @@ -7,7 +7,7 @@ _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] class MIMEImage(MIMENonMultipart): def __init__( self, - _imagedata: Union[str, bytes], + _imagedata: str | bytes, _subtype: Optional[str] = ..., _encoder: Callable[[MIMEImage], None] = ..., *, diff --git a/stdlib/email/policy.pyi b/stdlib/email/policy.pyi index d0906ebf1cf5..0095395b1080 100644 --- a/stdlib/email/policy.pyi +++ b/stdlib/email/policy.pyi @@ -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..a2829d776704 100644 --- a/stdlib/email/utils.pyi +++ b/stdlib/email/utils.pyi @@ -9,7 +9,7 @@ _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 formataddr(pair: Tuple[Optional[str], str], charset: str | Charset = ...) -> str: ... def getaddresses(fieldvalues: List[str]) -> List[Tuple[str, str]]: ... @overload def parsedate(data: None) -> None: ... diff --git a/stdlib/encodings/__init__.pyi b/stdlib/encodings/__init__.pyi index 951a53f1c786..1f85fc0ef4b6 100644 --- a/stdlib/encodings/__init__.pyi +++ b/stdlib/encodings/__init__.pyi @@ -3,7 +3,7 @@ from typing import Any, Optional, Union class CodecRegistryError(LookupError, SystemError): ... -def normalize_encoding(encoding: Union[str, bytes]) -> str: ... +def normalize_encoding(encoding: str | bytes) -> str: ... def search_function(encoding: str) -> Optional[CodecInfo]: ... # Needed for submodules diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index b5549253afc7..fdddd12bf9a2 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -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: ... @@ -68,17 +68,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, 10): 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..a56a4f7c9dcb 100644 --- a/stdlib/filecmp.pyi +++ b/stdlib/filecmp.pyi @@ -8,12 +8,12 @@ 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]], common: Iterable[AnyStr], - shallow: Union[int, bool] = ..., + 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 a59683c6b39f..22c48cbddaed 100644 --- a/stdlib/fractions.pyi +++ b/stdlib/fractions.pyi @@ -21,8 +21,8 @@ class Fraction(Rational): @overload def __new__( cls: Type[_T], - numerator: Union[int, Rational] = ..., - denominator: Optional[Union[int, Rational]] = ..., + numerator: int | Rational = ..., + denominator: Optional[int | Rational] = ..., *, _normalize: bool = ..., ) -> _T: ... @@ -40,81 +40,81 @@ 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 diff --git a/stdlib/ftplib.pyi b/stdlib/ftplib.pyi index c474da2e3a37..59520e5b9b2f 100644 --- a/stdlib/ftplib.pyi +++ b/stdlib/ftplib.pyi @@ -54,7 +54,7 @@ class FTP: 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: ... @@ -71,10 +71,10 @@ 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: Optional[int | str] = ...) -> Tuple[socket, int]: ... + def transfercmd(self, cmd: str, rest: Optional[int | str] = ...) -> 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: Optional[int | str] = ... ) -> str: ... def storbinary( self, @@ -82,7 +82,7 @@ class FTP: fp: SupportsRead[bytes], blocksize: int = ..., callback: Optional[Callable[[bytes], Any]] = ..., - rest: Optional[Union[int, str]] = ..., + rest: Optional[int | str] = ..., ) -> 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: ... diff --git a/stdlib/glob.pyi b/stdlib/glob.pyi index 33582d15f2d0..616362bdbb60 100644 --- a/stdlib/glob.pyi +++ b/stdlib/glob.pyi @@ -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/gzip.pyi b/stdlib/gzip.pyi index efba70703d8d..ed3c2c237952 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 = ..., @@ -64,7 +64,7 @@ def open( encoding: Optional[str] = ..., errors: Optional[str] = ..., newline: Optional[str] = ..., -) -> Union[GzipFile, TextIO]: ... +) -> GzipFile | TextIO: ... class _PaddedFile: file: _ReadableFileobj @@ -82,7 +82,7 @@ class GzipFile(_compression.BaseStream): mode: Literal[1, 2] name: str compress: zlib._Compress - fileobj: Union[_ReadableFileobj, _WritableFileobj] + fileobj: _ReadableFileobj | _WritableFileobj @overload def __init__( self, diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index c35228928d77..569c30ff8f51 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -110,7 +110,7 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO): @overload def getheader(self, name: str) -> Optional[str]: ... @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: ... diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index 094cebe49ca0..6bbbffd09822 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -144,6 +144,6 @@ class Cookie: @overload def get_nonstandard_attr(self, name: str) -> Optional[str]: ... @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: ... diff --git a/stdlib/http/server.pyi b/stdlib/http/server.pyi index 5d06bd5c700f..a39d9d2e300f 100644 --- a/stdlib/http/server.pyi +++ b/stdlib/http/server.pyi @@ -40,7 +40,7 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler): def send_response_only(self, code: int, message: Optional[str] = ...) -> 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: ... diff --git a/stdlib/imghdr.pyi b/stdlib/imghdr.pyi index 2b28b718a649..cabcd9031f63 100644 --- a/stdlib/imghdr.pyi +++ b/stdlib/imghdr.pyi @@ -7,7 +7,7 @@ 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 = ...) -> Optional[str]: ... @overload def what(file: Any, h: bytes) -> Optional[str]: ... diff --git a/stdlib/imp.pyi b/stdlib/imp.pyi index c6049c38ee18..9fbce4c7a26f 100644 --- a/stdlib/imp.pyi +++ b/stdlib/imp.pyi @@ -44,7 +44,7 @@ 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: ... diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index 69b03567bb22..69a3b2a57ff1 100644 --- a/stdlib/importlib/abc.pyi +++ b/stdlib/importlib/abc.pyi @@ -6,7 +6,7 @@ from importlib.machinery import ModuleSpec from typing import IO, Any, Iterator, Mapping, Optional, Protocol, Sequence, Tuple, Union from typing_extensions import Literal, runtime_checkable -_Path = Union[bytes, str] +_Path = bytes | str class Finder(metaclass=ABCMeta): ... @@ -22,7 +22,7 @@ class InspectLoader(Loader): def get_source(self, fullname: str) -> Optional[str]: ... 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 diff --git a/stdlib/importlib/machinery.pyi b/stdlib/importlib/machinery.pyi index beae43bd3937..5a9a639bf724 100644 --- a/stdlib/importlib/machinery.pyi +++ b/stdlib/importlib/machinery.pyi @@ -91,10 +91,10 @@ class PathFinder: def invalidate_caches(cls) -> None: ... @classmethod def find_spec( - cls, fullname: str, path: Optional[Sequence[Union[bytes, str]]] = ..., target: Optional[types.ModuleType] = ... + cls, fullname: str, path: Optional[Sequence[bytes | str]] = ..., target: Optional[types.ModuleType] = ... ) -> Optional[ModuleSpec]: ... @classmethod - def find_module(cls, fullname: str, path: Optional[Sequence[Union[bytes, str]]] = ...) -> Optional[importlib.abc.Loader]: ... + def find_module(cls, fullname: str, path: Optional[Sequence[bytes | str]] = ...) -> Optional[importlib.abc.Loader]: ... SOURCE_SUFFIXES: List[str] DEBUG_BYTECODE_SUFFIXES: List[str] diff --git a/stdlib/importlib/resources.pyi b/stdlib/importlib/resources.pyi index 075761abf9da..10f15da519ec 100644 --- a/stdlib/importlib/resources.pyi +++ b/stdlib/importlib/resources.pyi @@ -8,7 +8,7 @@ if sys.version_info >= (3, 7): from types import ModuleType from typing import BinaryIO, ContextManager, Iterator, TextIO, Union - Package = Union[str, ModuleType] + Package = str | ModuleType Resource = Union[str, os.PathLike[Any]] def open_binary(package: Package, resource: Resource) -> BinaryIO: ... def open_text(package: Package, resource: Resource, encoding: str = ..., errors: str = ...) -> TextIO: ... diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index f662a2da6aff..7e5024fe1d03 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -289,7 +289,7 @@ class FrameInfo(NamedTuple): code_context: Optional[list[str]] index: Optional[int] # 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: ... diff --git a/stdlib/io.pyi b/stdlib/io.pyi index f03a9a8740fe..40e619608e65 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -67,13 +67,13 @@ class BufferedIOBase(IOBase): class FileIO(RawIOBase, BinaryIO): mode: str # Technically this is whatever is passed in as file, either a str, a bytes, or an int. - name: Union[int, str] # type: ignore + name: int | str # type: ignore def __init__( self, file: Union[str, bytes, int], mode: str = ..., closefd: bool = ..., - opener: Optional[Callable[[Union[int, str], str], int]] = ..., + opener: Optional[Callable[[int | str, str], int]] = ..., ) -> None: ... @property def closefd(self) -> bool: ... @@ -183,6 +183,6 @@ class StringIO(TextIOWrapper): 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 decode(self, input: bytes | str, final: bool = ...) -> str: ... @property def newlines(self) -> Optional[Union[str, Tuple[str, ...]]]: ... diff --git a/stdlib/ipaddress.pyi b/stdlib/ipaddress.pyi index b4e2b2c4b3f9..7d0e1e6249c8 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: ... diff --git a/stdlib/json/__init__.pyi b/stdlib/json/__init__.pyi index 7b7a89ae20e2..1a6f7e51422d 100644 --- a/stdlib/json/__init__.pyi +++ b/stdlib/json/__init__.pyi @@ -34,7 +34,7 @@ def dump( **kwds: Any, ) -> None: ... def loads( - s: Union[str, bytes], + s: str | bytes, *, cls: Optional[Type[JSONDecoder]] = ..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ..., @@ -45,7 +45,7 @@ def loads( **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]] = ..., diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index 8d90ee39b76b..215b5bc5b1ff 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -2,7 +2,7 @@ from lib2to3.pgen2.grammar import Grammar from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, TypeVar, Union _P = TypeVar("_P") -_NL = Union[Node, Leaf] +_NL = Node | Leaf _Context = Tuple[str, int, int] _Results = Dict[str, _NL] _RawNode = Tuple[int, str, _Context, Optional[List[_NL]]] diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index 1e575a64856a..d64eef740ef2 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -87,7 +87,7 @@ 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: ... diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 1cce244e5798..b9cc629d847d 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -11,7 +11,7 @@ _SysExcInfoType = Union[Tuple[Type[BaseException], BaseException, Optional[Trace _ExcInfoType = Union[None, bool, _SysExcInfoType, BaseException] _ArgsType = Union[Tuple[Any, ...], Mapping[str, Any]] _FilterType = Union[Filter, Callable[[LogRecord], int]] -_Level = Union[int, str] +_Level = int | str raiseExceptions: bool logThreads: bool @@ -35,7 +35,7 @@ class Manager(object): # undocumented root: RootLogger disable: int emittedNoHandlerWarning: bool - loggerDict: dict[str, Union[Logger, PlaceHolder]] + loggerDict: dict[str, Logger | PlaceHolder] loggerClass: Optional[Type[Logger]] logRecordFactory: Optional[Callable[..., LogRecord]] def __init__(self, rootnode: RootLogger) -> None: ... diff --git a/stdlib/logging/handlers.pyi b/stdlib/logging/handlers.pyi index 9f0755c2a966..8a1f73f62db4 100644 --- a/stdlib/logging/handlers.pyi +++ b/stdlib/logging/handlers.pyi @@ -183,7 +183,7 @@ class SysLogHandler(Handler): def __init__( self, address: Union[tuple[str, int], str] = ..., facility: int = ..., socktype: Optional[SocketKind] = ... ) -> 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): diff --git a/stdlib/lzma.pyi b/stdlib/lzma.pyi index 0228b9d12d55..86664ee3d66a 100644 --- a/stdlib/lzma.pyi +++ b/stdlib/lzma.pyi @@ -156,7 +156,7 @@ def open( encoding: Optional[str] = ..., errors: Optional[str] = ..., newline: Optional[str] = ..., -) -> Union[LZMAFile, TextIO]: ... +) -> LZMAFile | TextIO: ... def compress( data: bytes, format: int = ..., check: int = ..., preset: Optional[int] = ..., filters: Optional[_FilterChain] = ... ) -> bytes: ... 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 1abe616fdc18..87349050c339 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -41,7 +41,7 @@ linesep: bytes class Mailbox(Generic[_MessageT]): - _path: Union[bytes, str] # undocumented + _path: bytes | str # undocumented _factory: Optional[Callable[[IO[Any]], _MessageT]] # undocumented def __init__( self, path: StrOrBytesPath, factory: Optional[Callable[[IO[Any]], _MessageT]] = ..., create: bool = ... @@ -54,7 +54,7 @@ class Mailbox(Generic[_MessageT]): @overload def get(self, key: str, default: None = ...) -> Optional[_MessageT]: ... @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: ... @@ -74,7 +74,7 @@ class Mailbox(Generic[_MessageT]): @overload def pop(self, key: str, default: None = ...) -> Optional[_MessageT]: ... @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 flush(self) -> None: ... diff --git a/stdlib/mailcap.pyi b/stdlib/mailcap.pyi index a65cc3a329d3..8a721168e06b 100644 --- a/stdlib/mailcap.pyi +++ b/stdlib/mailcap.pyi @@ -1,6 +1,6 @@ from typing import Dict, List, Mapping, Optional, Sequence, Tuple, Union -_Cap = Dict[str, Union[str, int]] +_Cap = Dict[str, str | int] def findmatch( caps: Mapping[str, List[_Cap]], MIMEtype: str, key: str = ..., filename: str = ..., plist: Sequence[str] = ... diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index 691d4f621a1b..78736bf3cf0f 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -60,7 +60,7 @@ class mmap(_mmap[bytes], ContextManager[mmap], Iterable[bytes], Sized): def __getitem__(self, index: int) -> int: ... @overload def __getitem__(self, index: slice) -> bytes: ... - def __delitem__(self, index: Union[int, slice]) -> None: ... + def __delitem__(self, index: int | slice) -> None: ... @overload def __setitem__(self, index: int, object: int) -> None: ... @overload diff --git a/stdlib/multiprocessing/__init__.pyi b/stdlib/multiprocessing/__init__.pyi index c8f9e2c654bc..0afd4b55c78f 100644 --- a/stdlib/multiprocessing/__init__.pyi +++ b/stdlib/multiprocessing/__init__.pyi @@ -54,7 +54,7 @@ _SemaphoreType = synchronize.Semaphore # be identical (modulo self). # Sychronization primitives -_LockLike = Union[synchronize.Lock, synchronize.RLock] +_LockLike = synchronize.Lock | synchronize.RLock RawValue = context._default_context.RawValue RawArray = context._default_context.RawArray Value = context._default_context.Value @@ -79,7 +79,7 @@ def Pool( 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: Optional[str | int] = ...) -> Logger: ... def Manager() -> SyncManager: ... def set_executable(executable: str) -> None: ... def set_forkserver_preload(module_names: list[str]) -> None: ... diff --git a/stdlib/multiprocessing/context.pyi b/stdlib/multiprocessing/context.pyi index e02bacc0a243..2df089841ebb 100644 --- a/stdlib/multiprocessing/context.pyi +++ b/stdlib/multiprocessing/context.pyi @@ -10,7 +10,7 @@ from multiprocessing.sharedctypes import SynchronizedArray, SynchronizedBase from typing import Any, Optional, Type, TypeVar, Union, overload from typing_extensions import Literal -_LockLike = Union[synchronize.Lock, synchronize.RLock] +_LockLike = synchronize.Lock | synchronize.RLock _CT = TypeVar("_CT", bound=_CData) class ProcessError(Exception): ... @@ -73,7 +73,7 @@ class BaseContext(object): @overload def Value(self, typecode_or_type: str, *args: Any, lock: Union[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: Union[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] @@ -96,7 +96,7 @@ class BaseContext(object): typecode_or_type: Union[str, Type[_CData]], size_or_initializer: Union[int, Sequence[Any]], *, - lock: Union[bool, _LockLike] = ..., + lock: bool | _LockLike = ..., ) -> Any: ... def freeze_support(self) -> None: ... def get_logger(self) -> Logger: ... diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index 9cc671363f0b..cb26c579c042 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] + typeid: Optional[str | bytes] + address: Tuple[str | bytes, int] id: Optional[Union[str, bytes, int]] def __init__( - self, typeid: Optional[Union[bytes, str]], address: Tuple[Union[str, bytes], int], id: Optional[Union[str, bytes, int]] + self, typeid: Optional[bytes | str], address: Tuple[str | bytes, int], id: Optional[Union[str, bytes, int]] ) -> None: ... def __repr__(self) -> str: ... def __getstate__( self, - ) -> Tuple[Optional[Union[str, bytes]], Tuple[Union[str, bytes], int], Optional[Union[str, bytes, int]]]: ... + ) -> Tuple[Optional[str | bytes], Tuple[str | bytes, int], Optional[Union[str, bytes, int]]]: ... def __setstate__( - self, state: Tuple[Optional[Union[str, bytes]], Tuple[Union[str, bytes], int], Optional[Union[str, bytes, int]]] + self, state: Tuple[Optional[str | bytes], Tuple[str | bytes, int], Optional[Union[str, bytes, int]]] ) -> None: ... class BaseProxy(object): diff --git a/stdlib/multiprocessing/sharedctypes.pyi b/stdlib/multiprocessing/sharedctypes.pyi index 0dc5977decd7..f6785e0880c3 100644 --- a/stdlib/multiprocessing/sharedctypes.pyi +++ b/stdlib/multiprocessing/sharedctypes.pyi @@ -29,7 +29,7 @@ def Value( ) -> SynchronizedBase[Any]: ... @overload def Value( - typecode_or_type: Union[str, Type[_CData]], *args: Any, lock: Union[bool, _LockLike] = ..., ctx: Optional[BaseContext] = ... + typecode_or_type: Union[str, Type[_CData]], *args: Any, lock: bool | _LockLike = ..., ctx: Optional[BaseContext] = ... ) -> Any: ... @overload def Array( @@ -60,7 +60,7 @@ def Array( typecode_or_type: Union[str, Type[_CData]], size_or_initializer: Union[int, Sequence[Any]], *, - lock: Union[bool, _LockLike] = ..., + lock: bool | _LockLike = ..., ctx: Optional[BaseContext] = ..., ) -> Any: ... def copy(obj: _CT) -> _CT: ... diff --git a/stdlib/multiprocessing/synchronize.pyi b/stdlib/multiprocessing/synchronize.pyi index 7eefc7676b66..70bd6ccb0cb4 100644 --- a/stdlib/multiprocessing/synchronize.pyi +++ b/stdlib/multiprocessing/synchronize.pyi @@ -3,7 +3,7 @@ import threading from multiprocessing.context import BaseContext from typing import Any, Callable, ContextManager, Optional, Union -_LockLike = Union[Lock, RLock] +_LockLike = Lock | RLock class Barrier(threading.Barrier): def __init__( diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index 36fe063c8486..00e83e9452aa 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -53,9 +53,9 @@ 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 description(self, group: str) -> str: ... diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 5de46ca031d7..e409fbaefdd0 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -311,7 +311,7 @@ class stat_result: class PathLike(Protocol[_AnyStr_co]): def __fspath__(self) -> _AnyStr_co: ... -_FdOrAnyPath = Union[int, StrOrBytesPath] +_FdOrAnyPath = int | StrOrBytesPath class DirEntry(Generic[AnyStr]): # This is what the scandir interator yields @@ -334,7 +334,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 @@ -422,18 +422,18 @@ if sys.platform != "win32": @overload def getenv(key: str) -> Optional[str]: ... @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]: ... @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] @@ -538,7 +538,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: ... @@ -628,7 +628,7 @@ if sys.platform != "win32": 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: ... @@ -752,12 +752,12 @@ _ExecVArgs = Union[ List[bytes], List[str], List[PathLike[Any]], - List[Union[bytes, str]], + List[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]]] +_ExecEnv = Union[Mapping[bytes, bytes | str], Mapping[str, bytes | str]] def execv(__path: StrOrBytesPath, __argv: _ExecVArgs) -> NoReturn: ... def execve(path: _FdOrAnyPath, argv: _ExecVArgs, env: _ExecEnv) -> NoReturn: ... @@ -837,9 +837,9 @@ def cpu_count() -> Optional[int]: ... if sys.platform != "win32": # Unix only - def confstr(__name: Union[str, int]) -> Optional[str]: ... + def confstr(__name: str | int) -> Optional[str]: ... 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: ... diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index b4624c3bea73..0027f28a0f8b 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -141,15 +141,15 @@ class Path(PurePath): 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: ... @@ -165,7 +165,7 @@ class Path(PurePath): def write_bytes(self, data: bytes) -> int: ... def write_text(self, data: str, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> 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/pickletools.pyi b/stdlib/pickletools.pyi index 59c06624a6d5..8638485f776b 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 diff --git a/stdlib/pkgutil.pyi b/stdlib/pkgutil.pyi index 583b262d44a2..02d723574ac5 100644 --- a/stdlib/pkgutil.pyi +++ b/stdlib/pkgutil.pyi @@ -4,7 +4,7 @@ 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 @@ -19,7 +19,7 @@ class ImpLoader: def find_loader(fullname: str) -> Optional[Loader]: ... def get_importer(path_item: str) -> Optional[PathEntryFinder]: ... def get_loader(module_or_name: str) -> Loader: ... -def iter_importers(fullname: str = ...) -> Iterator[Union[MetaPathFinder, PathEntryFinder]]: ... +def iter_importers(fullname: str = ...) -> Iterator[MetaPathFinder | PathEntryFinder]: ... def iter_modules(path: Optional[Iterable[str]] = ..., prefix: str = ...) -> Iterator[ModuleInfo]: ... def read_code(stream: SupportsRead[bytes]) -> Any: ... # undocumented def walk_packages( diff --git a/stdlib/profile.pyi b/stdlib/profile.pyi index 8052ede76aaf..3f8fa0151d75 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: Optional[str] = ..., 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: Optional[str] = ..., sort: str | int = ... ) -> None: ... _SelfT = TypeVar("_SelfT", bound=Profile) @@ -17,7 +17,7 @@ class Profile: 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/pyclbr.pyi b/stdlib/pyclbr.pyi index 665ea43c0d4a..38bd25aa9267 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: Optional[List[Class | str]] 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: Optional[List[Class | str]], file: str, lineno: int, parent: Optional[Class] = ..., ) -> 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: Optional[List[Class | str]], file: str, lineno: int) -> None: ... class Function: module: str diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index b41bef54304f..24fb80398113 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -207,12 +207,12 @@ 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 = ...) -> Optional[Tuple[object, str]]: ... +def render_doc(thing: str | object, title: str = ..., forceload: bool = ..., renderer: Optional[Doc] = ...) -> str: ... def doc( - thing: Union[str, object], title: str = ..., forceload: bool = ..., output: Optional[SupportsWrite[str]] = ... + thing: str | object, title: str = ..., forceload: bool = ..., output: Optional[SupportsWrite[str]] = ... ) -> None: ... -def writedoc(thing: Union[str, object], forceload: bool = ...) -> None: ... +def writedoc(thing: str | object, forceload: bool = ...) -> None: ... def writedocs(dir: str, pkgpath: str = ..., done: Optional[Any] = ...) -> None: ... class Helper: diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index c58958d15085..3d852212e877 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -22,7 +22,7 @@ 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]: ... diff --git a/stdlib/random.pyi b/stdlib/random.pyi index 0f1e280490ac..ea3801ed11cd 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -54,7 +54,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): diff --git a/stdlib/re.pyi b/stdlib/re.pyi index 3f2490ae4e11..6a651eca6641 100644 --- a/stdlib/re.pyi +++ b/stdlib/re.pyi @@ -45,7 +45,7 @@ U = RegexFlag.U UNICODE = RegexFlag.UNICODE T = RegexFlag.T TEMPLATE = RegexFlag.TEMPLATE -_FlagsType = Union[int, RegexFlag] +_FlagsType = int | RegexFlag if sys.version_info < (3, 7): # undocumented @@ -70,9 +70,9 @@ def fullmatch(pattern: AnyStr, string: AnyStr, flags: _FlagsType = ...) -> Optio @overload def fullmatch(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType = ...) -> Optional[Match[AnyStr]]: ... @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 diff --git a/stdlib/shlex.pyi b/stdlib/shlex.pyi index 741f516dcfdc..3373cb3ca6aa 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]] = ..., + instream: Optional[str | TextIO] = ..., infile: Optional[str] = ..., posix: bool = ..., - punctuation_chars: Union[bool, str] = ..., + punctuation_chars: bool | str = ..., ) -> None: ... def get_token(self) -> str: ... def push_token(self, tok: str) -> None: ... diff --git a/stdlib/shutil.pyi b/stdlib/shutil.pyi index ad077df80d07..53f907b97a77 100644 --- a/stdlib/shutil.pyi +++ b/stdlib/shutil.pyi @@ -45,7 +45,7 @@ else: ) -> _PathReturn: ... def rmtree( - path: Union[bytes, StrPath], ignore_errors: bool = ..., onerror: Optional[Callable[[Any, Any, Any], Any]] = ... + path: bytes | StrPath, ignore_errors: bool = ..., onerror: Optional[Callable[[Any, Any, Any], Any]] = ... ) -> None: ... _CopyFn = Union[Callable[[str, str], None], Callable[[StrPath, StrPath], None]] @@ -63,7 +63,7 @@ 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: Optional[str | int] = ..., group: Optional[str | int] = ...) -> None: ... if sys.version_info >= (3, 8): @overload diff --git a/stdlib/signal.pyi b/stdlib/signal.pyi index aa0bbf2bffd1..2ac96a539b37 100644 --- a/stdlib/signal.pyi +++ b/stdlib/signal.pyi @@ -79,7 +79,7 @@ if sys.platform != "win32": SIG_UNBLOCK = Sigmasks.SIG_UNBLOCK SIG_SETMASK = Sigmasks.SIG_SETMASK -_SIGNUM = Union[int, Signals] +_SIGNUM = int | Signals _HANDLER = Union[Callable[[Signals, FrameType], Any], int, Handlers, None] SIGABRT: Signals diff --git a/stdlib/smtpd.pyi b/stdlib/smtpd.pyi index 313e722163c0..822994f9f55f 100644 --- a/stdlib/smtpd.pyi +++ b/stdlib/smtpd.pyi @@ -70,17 +70,17 @@ class SMTPServer(asyncore.dispatcher): ) -> 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 + self, peer: _Address, mailfrom: str, rcpttos: List[str], data: bytes | str, **kwargs: Any ) -> Optional[str]: ... class DebuggingServer(SMTPServer): ... class PureProxy(SMTPServer): def process_message( # type: ignore - self, peer: _Address, mailfrom: str, rcpttos: List[str], data: Union[bytes, str] + self, peer: _Address, mailfrom: str, rcpttos: List[str], data: bytes | str ) -> Optional[str]: ... class MailmanProxy(PureProxy): def process_message( # type: ignore - self, peer: _Address, mailfrom: str, rcpttos: List[str], data: Union[bytes, str] + self, peer: _Address, mailfrom: str, rcpttos: List[str], data: bytes | str ) -> Optional[str]: ... diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index 48a35f8e3b67..55aca0b506c2 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -22,9 +22,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: Union[Tuple[int, bytes | str], Tuple[int, bytes, str]] + def __init__(self, code: int, msg: bytes | str) -> None: ... class SMTPSenderRefused(SMTPResponseException): smtp_code: int @@ -81,7 +81,7 @@ class SMTP: ) -> 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 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: ... @@ -93,7 +93,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: ... @@ -115,7 +115,7 @@ class SMTP: self, from_addr: str, to_addrs: Union[str, Sequence[str]], - msg: Union[bytes, str], + msg: bytes | str, mail_options: Sequence[str] = ..., rcpt_options: Sequence[str] = ..., ) -> _SendErrs: ... diff --git a/stdlib/sndhdr.pyi b/stdlib/sndhdr.pyi index 4f8ab2652b93..b4f23b05ba0b 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]: ... diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index 139152a2f8a5..67853ebd7b48 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -540,8 +540,8 @@ 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] = ..., ) -> None: ... @@ -597,7 +597,7 @@ if sys.platform == "win32": else: def socketpair( # type: ignore - family: Union[int, AddressFamily, None] = ..., type: Union[SocketType, int] = ..., proto: int = ... + family: Union[int, AddressFamily, None] = ..., type: SocketType | int = ..., proto: int = ... ) -> tuple[socket, socket]: ... class SocketIO(RawIOBase): diff --git a/stdlib/socketserver.pyi b/stdlib/socketserver.pyi index 74bba86c554f..932f4607d5f4 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -72,14 +72,14 @@ 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: ... diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index c53141856ca8..01fb2fa80695 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -78,7 +78,7 @@ if sys.version_info >= (3, 7): else: def connect( - database: Union[bytes, str], + database: bytes | str, timeout: float = ..., detect_types: int = ..., isolation_level: Optional[str] = ..., @@ -132,7 +132,7 @@ class Connection(object): 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: ... @@ -175,7 +175,7 @@ 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 fetchone(self) -> Any: ... diff --git a/stdlib/sre_constants.pyi b/stdlib/sre_constants.pyi index 07a308e6f67b..bd7bf6033239 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]] + pattern: Optional[str | bytes] pos: Optional[int] lineno: int colno: int - def __init__(self, msg: str, pattern: Optional[Union[str, bytes]] = ..., pos: Optional[int] = ...) -> None: ... + def __init__(self, msg: str, pattern: Optional[str | bytes] = ..., pos: Optional[int] = ...) -> None: ... class _NamedIntConstant(int): name: Any diff --git a/stdlib/sre_parse.pyi b/stdlib/sre_parse.pyi index 4c7b6157d8a9..06af6201c47e 100644 --- a/stdlib/sre_parse.pyi +++ b/stdlib/sre_parse.pyi @@ -53,9 +53,9 @@ class SubPattern: def __init__(self, pattern: Pattern, data: Optional[List[_CodeType]] = ...) -> 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: ... @@ -80,7 +80,7 @@ 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]]] diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index bfc368291766..665168bf2f1b 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -10,9 +10,9 @@ _PCTRTTT = Tuple[_PCTRTT, ...] _PeerCertRetDictType = Dict[str, Union[str, _PCTRTTT, _PCTRTT]] _PeerCertRetType = Union[_PeerCertRetDictType, bytes, None] _EnumRetType = List[Tuple[bytes, str, Union[Set[str], bool]]] -_PasswordType = Union[Callable[[], Union[str, bytes]], str, bytes] +_PasswordType = Union[Callable[[], str | bytes], str, bytes] -_SrvnmeCbType = Callable[[Union[SSLSocket, SSLObject], Optional[str], SSLSocket], Optional[int]] +_SrvnmeCbType = Callable[[SSLSocket | SSLObject, Optional[str], SSLSocket], Optional[int]] class SSLError(OSError): library: str @@ -244,8 +244,8 @@ class SSLSocket(socket.socket): ) -> 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 recvfrom(self, buflen: int = ..., flags: int = ...) -> tuple[bytes, socket._RetAddress]: ... @@ -257,7 +257,7 @@ class SSLSocket(socket.socket): @overload def sendto(self, data: bytes, flags_or_addr: socket._Address) -> int: ... @overload - def sendto(self, data: bytes, flags_or_addr: Union[int, socket._Address], addr: Optional[socket._Address] = ...) -> int: ... + def sendto(self, data: bytes, flags_or_addr: int | socket._Address, addr: Optional[socket._Address] = ...) -> int: ... def shutdown(self, how: int) -> None: ... def read(self, len: int = ..., buffer: Optional[bytearray] = ...) -> bytes: ... def write(self, data: bytes) -> int: ... @@ -315,7 +315,7 @@ class SSLContext: def set_ciphers(self, __cipherlist: str) -> None: ... def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ... if sys.version_info >= (3, 7): - sni_callback: Optional[Callable[[SSLObject, str, SSLContext], Union[None, int]]] + sni_callback: Optional[Callable[[SSLObject, str, SSLContext], None | int]] sslobject_class: Type[SSLObject] def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ... if sys.version_info >= (3, 7): @@ -357,7 +357,7 @@ class SSLObject: 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: Optional[SSLSocket | SSLObject] = ..., session: Optional[Any] = ... ) -> None: ... def read(self, len: int = ..., buffer: Optional[bytearray] = ...) -> bytes: ... def write(self, data: bytes) -> int: ... diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index 4435bf8a001b..a74a5b5d09f5 100644 --- a/stdlib/statistics.pyi +++ b/stdlib/statistics.pyi @@ -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..9d4157e86a94 100644 --- a/stdlib/string.pyi +++ b/stdlib/string.pyi @@ -24,7 +24,7 @@ class Formatter: 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 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 9a431f082c37..953e23125461 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -22,7 +22,7 @@ if sys.version_info >= (3, 9): # except TimeoutError as e: # reveal_type(e.cmd) # Any, but morally is _CMD _FILE = Union[None, int, IO[Any]] -_TXT = Union[bytes, str] +_TXT = bytes | str if sys.version_info >= (3, 8): _CMD = Union[StrOrBytesPath, Sequence[StrOrBytesPath]] else: diff --git a/stdlib/sys.pyi b/stdlib/sys.pyi index 8370f0b29477..c11605a9c1c0 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -27,7 +27,7 @@ _T = TypeVar("_T") # The following type alias are stub-only and do not exist during runtime _ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType] _OptExcInfo = Union[_ExcInfo, Tuple[None, None, None]] -_PathSequence = Sequence[Union[bytes, str]] +_PathSequence = Sequence[bytes | str] # Unlike importlib.abc.MetaPathFinder, invalidate_caches() might not exist (see python docs) class _MetaPathFinder(Protocol): diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index 958ba19da2ea..c18ec18ce454 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -260,9 +260,9 @@ class TarFile: self, path: StrOrBytesPath = ..., members: Optional[Iterable[TarInfo]] = ..., *, 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 extractfile(self, member: Union[str, TarInfo]) -> Optional[IO[bytes]]: ... + def extractfile(self, member: str | TarInfo) -> Optional[IO[bytes]]: ... 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 diff --git a/stdlib/termios.pyi b/stdlib/termios.pyi index 0c627f4b72bd..90dd8db9d318 100644 --- a/stdlib/termios.pyi +++ b/stdlib/termios.pyi @@ -1,7 +1,7 @@ from _typeshed import FileDescriptorLike from typing import Any, List, Union -_Attr = List[Union[int, List[Union[bytes, int]]]] +_Attr = List[Union[int, List[bytes | int]]] # TODO constants not really documented B0: int diff --git a/stdlib/time.pyi b/stdlib/time.pyi index 48111fba1f79..1701e27ebe49 100644 --- a/stdlib/time.pyi +++ b/stdlib/time.pyi @@ -72,7 +72,7 @@ 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: ... @@ -80,9 +80,9 @@ if sys.version_info < (3, 8): 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 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/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 8d328abae4d5..586d858535a3 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -112,7 +112,7 @@ _Cursor = Union[str, Tuple[str], Tuple[str, str], Tuple[str, str, str], Tuple[st _EntryValidateCommand = Union[ Callable[[], bool], str, _TkinterSequence[str] ] # example when it's sequence: entry['invalidcommand'] = [entry.register(print), '%P'] -_ImageSpec = Union[_Image, str] # str can be from e.g. tkinter.image_names() +_ImageSpec = _Image | str # str can be from e.g. tkinter.image_names() _Padding = Union[ _ScreenUnits, Tuple[_ScreenUnits], @@ -121,7 +121,7 @@ _Padding = Union[ Tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits], ] _Relief = Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] # manual page: Tk_GetRelief -_ScreenUnits = Union[str, float] # manual page: Tk_GetPixels +_ScreenUnits = str | float # manual page: Tk_GetPixels _XYScrollCommand = Union[str, Callable[[float, float], Any]] # -xscrollcommand and -yscrollcommand in 'options' manual page _TakeFocusValue = Union[int, Literal[""], Callable[[str], Optional[bool]]] # -takefocus in manual page named 'options' @@ -174,7 +174,7 @@ class Event(Generic[_W]): height: int width: int keycode: int - state: Union[int, str] + state: int | str time: int x: int y: int @@ -245,7 +245,7 @@ class Misc: def tk_strictMotif(self, boolean: Optional[Any] = ...): ... 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: ... @@ -329,7 +329,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: ... @@ -424,7 +424,7 @@ class Misc: self, sequence: str, *, - above: Union[Misc, int] = ..., + above: Misc | int = ..., borderwidth: _ScreenUnits = ..., button: int = ..., count: int = ..., @@ -438,13 +438,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 = ..., @@ -589,7 +589,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 @@ -749,10 +749,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: ... @@ -940,7 +940,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. @@ -985,7 +985,7 @@ 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 = ..., @@ -1091,16 +1091,16 @@ class Canvas(Widget, XView, YView): @overload def tag_bind( self, - tagOrId: Union[str, int], + tagOrId: str | int, sequence: Optional[str] = ..., func: Optional[Callable[[Event[Canvas]], Any]] = ..., add: Optional[bool] = ..., ) -> 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: Optional[str], func: str, add: Optional[bool] = ...) -> 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 tag_bind(self, tagOrId: str | int, *, func: str, add: Optional[bool] = ...) -> None: ... + def tag_unbind(self, tagOrId: str | int, sequence: str, funcid: Optional[str] = ...) -> None: ... def canvasx(self, screenx, gridspacing: Optional[Any] = ...): ... def canvasy(self, screeny, gridspacing: Optional[Any] = ...): ... def coords(self, *args): ... @@ -1250,7 +1250,7 @@ class Canvas(Widget, XView, YView): state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., tags: Union[str, Tuple[str, ...]] = ..., - text: Union[float, str] = ..., + text: float | str = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... def create_window( @@ -1266,16 +1266,16 @@ 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: ... def dtag(self, *args): ... 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_below(self, tagOrId: str | _CanvasItemId): ... def find_closest(self, x, y, halo: Optional[Any] = ..., start: Optional[Any] = ...): ... 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, *args): ... def icursor(self, *args): ... @@ -1289,7 +1289,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: Union[Literal[""], float] = ..., y: Union[Literal[""], float] = ... ) -> None: ... def postscript(self, cnf=..., **kw): ... def tag_raise(self, *args): ... @@ -1355,7 +1355,7 @@ 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 = ..., @@ -1403,7 +1403,7 @@ 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 = ..., @@ -1617,7 +1617,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 = ..., @@ -1654,7 +1654,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 = ..., @@ -1777,7 +1777,7 @@ class Listbox(Widget, XView, YView): def itemconfigure(self, index, cnf: Optional[Any] = ..., **kw): ... itemconfig: Any -_MenuIndex = Union[str, int] +_MenuIndex = str | int class Menu(Widget): def __init__( @@ -2083,7 +2083,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 = ..., @@ -2123,7 +2123,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 = ..., @@ -2159,7 +2159,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 = ..., @@ -2188,7 +2188,7 @@ 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]]]: ... @@ -2235,7 +2235,7 @@ 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 = ..., @@ -2282,7 +2282,7 @@ 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 = ..., @@ -2340,7 +2340,7 @@ class Scale(Widget): tickinterval: float = ..., to: float = ..., troughcolor: _Color = ..., - variable: Union[IntVar, DoubleVar] = ..., + variable: IntVar | DoubleVar = ..., width: _ScreenUnits = ..., ) -> None: ... @overload @@ -2380,7 +2380,7 @@ 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]]]: ... @overload @@ -2511,7 +2511,7 @@ class Text(Widget, XView, YView): startline: Union[int, Literal[""]] = ..., state: Literal["normal", "disabled"] = ..., # Literal inside Tuple doesn't actually work - tabs: Union[_ScreenUnits, str, Tuple[Union[_ScreenUnits, str], ...]] = ..., + tabs: Union[_ScreenUnits, str, Tuple[_ScreenUnits | str, ...]] = ..., tabstyle: Literal["tabular", "wordprocessor"] = ..., takefocus: _TakeFocusValue = ..., undo: bool = ..., @@ -2562,7 +2562,7 @@ class Text(Widget, XView, YView): spacing3: _ScreenUnits = ..., startline: Union[int, Literal[""]] = ..., state: Literal["normal", "disabled"] = ..., - tabs: Union[_ScreenUnits, str, Tuple[Union[_ScreenUnits, str], ...]] = ..., + tabs: Union[_ScreenUnits, str, Tuple[_ScreenUnits | str, ...]] = ..., tabstyle: Literal["tabular", "wordprocessor"] = ..., takefocus: _TakeFocusValue = ..., undo: bool = ..., @@ -2652,7 +2652,7 @@ class Text(Widget, XView, YView): def mark_next(self, index: _TextIndex) -> Optional[str]: ... def mark_previous(self, index: _TextIndex) -> Optional[str]: ... # **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 scan_mark(self, x: int, y: int) -> None: ... @@ -2771,7 +2771,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: Optional[Any] = ..., cnf=..., master: Optional[Misc | _tkinter.TkappType] = ..., **kw ): ... def __del__(self): ... def __setitem__(self, key, value): ... @@ -2787,25 +2787,25 @@ class PhotoImage(Image): self, name: Optional[str] = ..., cnf: Dict[str, Any] = ..., - master: Optional[Union[Misc, _tkinter.TkappType]] = ..., + master: Optional[Misc | _tkinter.TkappType] = ..., *, - 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 @@ -2831,10 +2831,10 @@ class BitmapImage(Image): self, name: Optional[Any] = ..., cnf: Dict[str, Any] = ..., - master: Optional[Union[Misc, _tkinter.TkappType]] = ..., + master: Optional[Misc | _tkinter.TkappType] = ..., *, background: _Color = ..., - data: Union[str, bytes] = ..., + data: str | bytes = ..., file: StrOrBytesPath = ..., foreground: _Color = ..., maskdata: str = ..., @@ -3013,7 +3013,7 @@ class LabelFrame(Widget): pady: _ScreenUnits = ..., relief: _Relief = ..., takefocus: _TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., visual: Union[str, Tuple[str, int]] = ..., width: _ScreenUnits = ..., ) -> None: ... @@ -3041,7 +3041,7 @@ 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]]]: ... @overload diff --git a/stdlib/tkinter/colorchooser.pyi b/stdlib/tkinter/colorchooser.pyi index c99c16f0e3bf..d5adf27f294f 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 + color: Optional[str | bytes] = ..., **options: Any ) -> Union[Tuple[None, None], Tuple[Tuple[float, float, float], str]]: ... diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index af3c75142598..ad646fd1c58c 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -49,7 +49,7 @@ 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[""]] = ..., @@ -68,7 +68,7 @@ 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[""]] = ..., @@ -95,7 +95,7 @@ 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 @@ -119,7 +119,7 @@ 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 = ..., @@ -351,7 +351,7 @@ 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[""]] = ..., @@ -377,7 +377,7 @@ 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[""]] = ..., @@ -404,7 +404,7 @@ 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: ... @@ -423,7 +423,7 @@ 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]]]: ... @@ -449,7 +449,7 @@ 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[""]] = ..., @@ -468,7 +468,7 @@ 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[""]] = ..., @@ -582,7 +582,7 @@ 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( @@ -598,7 +598,7 @@ class Progressbar(Widget): style: str = ..., takefocus: tkinter._TakeFocusValue = ..., value: float = ..., - variable: Union[tkinter.IntVar, tkinter.DoubleVar] = ..., + variable: tkinter.IntVar | tkinter.DoubleVar = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... @@ -622,7 +622,7 @@ class Radiobutton(Widget): state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., value: Any = ..., @@ -642,7 +642,7 @@ class Radiobutton(Widget): state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., - text: Union[float, str] = ..., + text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., value: Any = ..., @@ -671,7 +671,7 @@ 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( @@ -688,7 +688,7 @@ class Scale(Widget, tkinter.Scale): takefocus: tkinter._TakeFocusValue = ..., to: float = ..., value: float = ..., - variable: Union[tkinter.IntVar, tkinter.DoubleVar] = ..., + variable: tkinter.IntVar | tkinter.DoubleVar = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... @@ -708,7 +708,7 @@ class Scale(Widget, tkinter.Scale): takefocus: tkinter._TakeFocusValue = ..., to: float = ..., value: float = ..., - variable: Union[tkinter.IntVar, tkinter.DoubleVar] = ..., + variable: tkinter.IntVar | tkinter.DoubleVar = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... @@ -966,7 +966,7 @@ class LabeledScale(Frame): def __init__( self, master: Optional[tkinter.Misc] = ..., - variable: Optional[Union[tkinter.IntVar, tkinter.DoubleVar]] = ..., + variable: Optional[tkinter.IntVar | tkinter.DoubleVar] = ..., from_: float = ..., to: float = ..., *, diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index a6e6abae5037..1ce130a752ed 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -54,7 +54,7 @@ class Untokenizer: 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 810639869e20..1e60b392e565 100644 --- a/stdlib/trace.pyi +++ b/stdlib/trace.pyi @@ -34,10 +34,10 @@ class Trace: outfile: Optional[StrPath] = ..., 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], + cmd: str | types.CodeType, globals: Optional[Mapping[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ..., ) -> None: ... diff --git a/stdlib/tracemalloc.pyi b/stdlib/tracemalloc.pyi index 593c4edaec65..7ef1d4eb0500 100644 --- a/stdlib/tracemalloc.pyi +++ b/stdlib/tracemalloc.pyi @@ -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..d3d9358a2d8a 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -11,7 +11,7 @@ _AnyColor = Any # TODO: Replace this with a TypedDict once it becomes standardized. _PenState = Dict[str, Any] -_Speed = Union[str, float] +_Speed = str | float _PolygonCoords = Sequence[Tuple[float, float]] # TODO: Type this more accurately @@ -276,8 +276,8 @@ 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] = ..., + width: int | float = ..., + height: int | float = ..., startx: Optional[int] = ..., starty: Optional[int] = ..., ) -> None: ... diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 741d41d4ab79..dec474fd3db7 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -170,7 +170,7 @@ class GeneratorType(Generator[_T_co, _T_contra, _V_co]): def send(self, __arg: _T_contra) -> _T_co: ... @overload def throw( - self, __typ: Type[BaseException], __val: typing.Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... + self, __typ: Type[BaseException], __val: typing.BaseException | object = ..., __tb: Optional[TracebackType] = ... ) -> _T_co: ... @overload def throw(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> _T_co: ... @@ -185,7 +185,7 @@ class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]): def asend(self, __val: _T_contra) -> Awaitable[_T_co]: ... @overload def athrow( - self, __typ: Type[BaseException], __val: typing.Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... + self, __typ: Type[BaseException], __val: typing.BaseException | object = ..., __tb: Optional[TracebackType] = ... ) -> Awaitable[_T_co]: ... @overload def athrow(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> Awaitable[_T_co]: ... @@ -200,7 +200,7 @@ 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: Optional[TracebackType] = ... ) -> Any: ... @overload def throw(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> Any: ... @@ -230,7 +230,7 @@ class MethodType: def __call__(self, *args: Any, **kwargs: Any) -> Any: ... class BuiltinFunctionType: - __self__: typing.Union[object, ModuleType] + __self__: typing.object | ModuleType __name__: str __qualname__: str def __call__(self, *args: Any, **kwargs: Any) -> Any: ... diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index aafb1fbdf1b3..2df93a19a7fe 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -203,7 +203,7 @@ 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: Optional[TracebackType] = ... ) -> _T_co: ... @overload @abstractmethod @@ -240,7 +240,7 @@ 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: Optional[TracebackType] = ... ) -> _T_co: ... @overload @abstractmethod @@ -273,7 +273,7 @@ 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: Optional[TracebackType] = ... ) -> Awaitable[_T_co]: ... @overload @abstractmethod @@ -357,9 +357,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]): @@ -371,9 +371,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): @@ -403,12 +403,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 @@ -443,7 +443,7 @@ class Mapping(_Collection[_KT], Generic[_KT, _VT_co]): @overload def get(self, key: _KT) -> Optional[_VT_co]: ... @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]: ... @@ -458,7 +458,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. @@ -565,17 +565,17 @@ class Match(Generic[AnyStr]): def expand(self, template: AnyStr) -> AnyStr: ... # TODO: The return for a group may be None, except if __group is 0 or not given. @overload - def group(self, __group: Union[str, int] = ...) -> AnyStr: ... + def group(self, __group: str | int = ...) -> AnyStr: ... @overload - def group(self, __group1: Union[str, int], __group2: Union[str, int], *groups: Union[str, int]) -> Tuple[AnyStr, ...]: ... + def group(self, __group1: str | int, __group2: str | int, *groups: str | int) -> Tuple[AnyStr, ...]: ... def groups(self, default: AnyStr = ...) -> Sequence[AnyStr]: ... def groupdict(self, default: AnyStr = ...) -> dict[str, AnyStr]: ... - 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 - def __getitem__(self, g: Union[int, str]) -> AnyStr: ... + def __getitem__(self, g: int | str) -> AnyStr: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... 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/case.pyi b/stdlib/unittest/case.pyi index 16036264af11..c685e84234ce 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -138,7 +138,7 @@ class TestCase: msg: Any = ..., ) -> _AssertWarnsContext: ... def assertLogs( - self, logger: Optional[Union[str, logging.Logger]] = ..., level: Union[int, str, None] = ... + self, logger: Optional[str | logging.Logger] = ..., level: Union[int, str, None] = ... ) -> _AssertLogsContext: ... @overload def assertAlmostEqual( diff --git a/stdlib/unittest/main.pyi b/stdlib/unittest/main.pyi index 5e6151eda3dd..637b90e3d9f6 100644 --- a/stdlib/unittest/main.pyi +++ b/stdlib/unittest/main.pyi @@ -7,7 +7,7 @@ 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: diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index 40cb7743362a..c95886a46282 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -230,7 +230,7 @@ class _patcher: autospec: Optional[Any] = ..., new_callable: Optional[Any] = ..., **kwargs: Any, - ) -> _patch[Union[MagicMock, AsyncMock]]: ... + ) -> _patch[MagicMock | AsyncMock]: ... else: @overload def __call__( # type: ignore @@ -282,7 +282,7 @@ class _patcher: autospec: Optional[Any] = ..., new_callable: Optional[Any] = ..., **kwargs: Any, - ) -> _patch[Union[MagicMock, AsyncMock]]: ... + ) -> _patch[MagicMock | AsyncMock]: ... else: @overload def object( # type: ignore diff --git a/stdlib/unittest/runner.pyi b/stdlib/unittest/runner.pyi index adb5fc50442a..3c8991c08786 100644 --- a/stdlib/unittest/runner.pyi +++ b/stdlib/unittest/runner.pyi @@ -32,4 +32,4 @@ class TextTestRunner(object): 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/unittest/suite.pyi b/stdlib/unittest/suite.pyi index 62869d2305d6..496d3fa442ba 100644 --- a/stdlib/unittest/suite.pyi +++ b/stdlib/unittest/suite.pyi @@ -2,7 +2,7 @@ import unittest.case import unittest.result from typing import Iterable, Iterator, List, Union -_TestType = Union[unittest.case.TestCase, TestSuite] +_TestType = unittest.case.TestCase | TestSuite class BaseTestSuite(Iterable[_TestType]): _tests: List[unittest.case.TestCase] diff --git a/stdlib/urllib/error.pyi b/stdlib/urllib/error.pyi index d6ef9ff5f94f..18f4109d4fa7 100644 --- a/stdlib/urllib/error.pyi +++ b/stdlib/urllib/error.pyi @@ -5,8 +5,8 @@ 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: Optional[str] = ...) -> None: ... class HTTPError(URLError, addinfourl): code: int diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 00bdb5109044..242022e4957c 100644 --- a/stdlib/urllib/parse.pyi +++ b/stdlib/urllib/parse.pyi @@ -4,7 +4,7 @@ from typing import Any, AnyStr, Callable, Dict, Generic, List, Mapping, NamedTup if sys.version_info >= (3, 9): from types import GenericAlias -_Str = Union[bytes, str] +_Str = bytes | str uses_relative: List[str] uses_netloc: List[str] diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 60ccdf2dd90c..1dbebb26a00a 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -28,7 +28,7 @@ _T = TypeVar("_T") _UrlopenRet = Any def urlopen( - url: Union[str, Request], + url: str | Request, data: Optional[bytes] = ..., timeout: Optional[float] = ..., *, @@ -92,14 +92,14 @@ class Request: @overload def get_header(self, header_name: str) -> Optional[str]: ... @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: Optional[bytes] = ..., timeout: Optional[float] = ...) -> _UrlopenRet: ... def error(self, proto: str, *args: Any) -> _UrlopenRet: ... def close(self) -> None: ... @@ -311,16 +311,16 @@ class FancyURLopener(URLopener): 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[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: Optional[bytes] = ... - ) -> Optional[Union[_UrlopenRet, addinfourl]]: ... # undocumented + ) -> Optional[_UrlopenRet | addinfourl]: ... # undocumented def http_error_302( self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: Optional[bytes] = ... - ) -> Optional[Union[_UrlopenRet, addinfourl]]: ... # undocumented + ) -> Optional[_UrlopenRet | addinfourl]: ... # undocumented def http_error_303( self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: Optional[bytes] = ... - ) -> Optional[Union[_UrlopenRet, addinfourl]]: ... # undocumented + ) -> Optional[_UrlopenRet | addinfourl]: ... # undocumented def http_error_307( self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: Optional[bytes] = ... - ) -> Optional[Union[_UrlopenRet, addinfourl]]: ... # undocumented + ) -> Optional[_UrlopenRet | addinfourl]: ... # undocumented def http_error_401( self, url: str, diff --git a/stdlib/uu.pyi b/stdlib/uu.pyi index 91ce210ae96d..9304720ada09 100644 --- a/stdlib/uu.pyi +++ b/stdlib/uu.pyi @@ -1,7 +1,7 @@ import sys from typing import BinaryIO, Optional, Union -_File = Union[str, BinaryIO] +_File = str | BinaryIO class Error(Exception): ... diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index f3f606267892..aaa61c5645dc 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -5,7 +5,7 @@ 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, @@ -13,7 +13,7 @@ def showwarning( line: Optional[str] = ..., ) -> 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: Optional[str] = ... ) -> str: ... def filterwarnings( action: str, message: str = ..., category: Type[Warning] = ..., module: str = ..., lineno: int = ..., append: bool = ... @@ -24,7 +24,7 @@ def resetwarnings() -> None: ... class _OptionError(Exception): ... class WarningMessage: - message: Union[Warning, str] + message: Warning | str category: Type[Warning] filename: str lineno: int @@ -33,7 +33,7 @@ class WarningMessage: source: Optional[Any] def __init__( self, - message: Union[Warning, str], + message: Warning | str, category: Type[Warning], filename: str, lineno: int, diff --git a/stdlib/winreg.pyi b/stdlib/winreg.pyi index 8f25dd61a092..192f55f1a2b7 100644 --- a/stdlib/winreg.pyi +++ b/stdlib/winreg.pyi @@ -1,7 +1,7 @@ from types import TracebackType from typing import Any, Optional, Tuple, Type, Union -_KeyType = Union[HKEYType, int] +_KeyType = HKEYType | int def CloseKey(__hkey: _KeyType) -> None: ... def ConnectRegistry(__computer_name: Optional[str], __key: _KeyType) -> HKEYType: ... @@ -23,7 +23,7 @@ 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: Optional[str], __reserved: Any, __type: int, __value: str | int ) -> None: ... # reserved is ignored def DisableReflectionKey(__key: _KeyType) -> None: ... def EnableReflectionKey(__key: _KeyType) -> None: ... diff --git a/stdlib/winsound.pyi b/stdlib/winsound.pyi index be9a8c660781..d6e72ac78d44 100644 --- a/stdlib/winsound.pyi +++ b/stdlib/winsound.pyi @@ -23,5 +23,5 @@ if sys.platform == "win32": @overload def PlaySound(sound: Optional[bytes], flags: Literal[4]) -> None: ... @overload - def PlaySound(sound: Optional[Union[str, bytes]], flags: int) -> None: ... + def PlaySound(sound: Optional[str | bytes], flags: int) -> None: ... def MessageBeep(type: int = ...) -> None: ... diff --git a/stdlib/xml/dom/minidom.pyi b/stdlib/xml/dom/minidom.pyi index 90396299effc..168b76d40f68 100644 --- a/stdlib/xml/dom/minidom.pyi +++ b/stdlib/xml/dom/minidom.pyi @@ -7,7 +7,7 @@ from xml.sax.xmlreader import XMLReader _T = TypeVar("_T") def parse(file: Union[str, IO[Any]], parser: Optional[XMLReader] = ..., bufsize: Optional[int] = ...): ... -def parseString(string: Union[str, bytes], parser: Optional[XMLReader] = ...): ... +def parseString(string: str | bytes, parser: Optional[XMLReader] = ...): ... def getDOMImplementation(features=...): ... class Node(xml.dom.Node): diff --git a/stdlib/xml/etree/ElementInclude.pyi b/stdlib/xml/etree/ElementInclude.pyi index 4aa0173fa82f..36bd76379a99 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: Union[str, bytes, int], parse: str, encoding: Optional[str] = ...) -> 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]]] = ..., + loader: Optional[Callable[..., str | Element]] = ..., base_url: Optional[str] = ..., max_depth: Optional[int] = ..., ) -> None: ... else: - def include(elem: Element, loader: Optional[Callable[..., Union[str, Element]]] = ...) -> None: ... + def include(elem: Element, loader: Optional[Callable[..., str | Element]] = ...) -> None: ... diff --git a/stdlib/xml/etree/ElementPath.pyi b/stdlib/xml/etree/ElementPath.pyi index de49ffcf1209..6e0674cb6e55 100644 --- a/stdlib/xml/etree/ElementPath.pyi +++ b/stdlib/xml/etree/ElementPath.pyi @@ -30,4 +30,4 @@ def find(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) - def findall(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) -> List[Element]: ... def findtext( elem: Element, path: str, default: Optional[_T] = ..., namespaces: Optional[Dict[str, str]] = ... -) -> Union[_T, str]: ... +) -> _T | str: ... diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index 8251071e833a..10bbe9919963 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -35,7 +35,7 @@ def iselement(element: object) -> bool: ... if sys.version_info >= (3, 8): @overload def canonicalize( - xml_data: Optional[Union[str, bytes]] = ..., + xml_data: Optional[str | bytes] = ..., *, out: None = ..., from_file: Optional[_File] = ..., @@ -49,7 +49,7 @@ if sys.version_info >= (3, 8): ) -> str: ... @overload def canonicalize( - xml_data: Optional[Union[str, bytes]] = ..., + xml_data: Optional[str | bytes] = ..., *, out: SupportsWrite[str], from_file: Optional[_File] = ..., @@ -76,11 +76,11 @@ class Element(MutableSequence[Element]): @overload def findtext(self, path: str, default: None = ..., namespaces: Optional[Dict[str, str]] = ...) -> Optional[str]: ... @overload - def findtext(self, path: str, default: _T, namespaces: Optional[Dict[str, str]] = ...) -> Union[_T, str]: ... + def findtext(self, path: str, default: _T, namespaces: Optional[Dict[str, str]] = ...) -> _T | str: ... @overload def get(self, key: str, default: None = ...) -> Optional[str]: ... @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]: ... @@ -90,7 +90,7 @@ class Element(MutableSequence[Element]): 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 @@ -125,7 +125,7 @@ class ElementTree: @overload def findtext(self, path: str, default: None = ..., namespaces: Optional[Dict[str, str]] = ...) -> Optional[str]: ... @overload - def findtext(self, path: str, default: _T, namespaces: Optional[Dict[str, str]] = ...) -> Union[_T, str]: ... + def findtext(self, path: str, default: _T, namespaces: Optional[Dict[str, str]] = ...) -> _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 write( @@ -231,7 +231,7 @@ else: 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 iterparse( @@ -244,13 +244,13 @@ class XMLPullParser: 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: Optional[XMLParser] = ...) -> Element: ... +def XMLID(text: str | bytes, parser: Optional[XMLParser] = ...) -> 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: Optional[XMLParser] = ...) -> 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 @@ -266,9 +266,9 @@ _ElementFactory = Callable[[Any, Dict[Any, Any]], Element] class TreeBuilder: def __init__(self, element_factory: Optional[_ElementFactory] = ...) -> 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: @@ -297,4 +297,4 @@ class XMLParser: def __init__(self, html: int = ..., target: Any = ..., encoding: Optional[str] = ...) -> 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..5c45410910f8 100644 --- a/stdlib/xml/sax/__init__.pyi +++ b/stdlib/xml/sax/__init__.pyi @@ -29,5 +29,5 @@ 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 parseString(string: bytes | str, handler: ContentHandler, errorHandler: Optional[ErrorHandler] = ...) -> None: ... def _create_parser(parser_name: str) -> XMLReader: ... diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index b0c615063729..20d5ccc8a384 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -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: diff --git a/stdlib/xmlrpc/server.pyi b/stdlib/xmlrpc/server.pyi index f6a097d91d06..a4497fe68b35 100644 --- a/stdlib/xmlrpc/server.pyi +++ b/stdlib/xmlrpc/server.pyi @@ -77,7 +77,7 @@ class SimpleXMLRPCRequestHandler(http.server.BaseHTTPRequestHandler): def do_POST(self) -> None: ... def decode_request_content(self, data: bytes) -> Optional[bytes]: ... 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): diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index b43ff218c062..51a1327ed1dd 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -137,15 +137,15 @@ class ZipFile: def infolist(self) -> List[ZipInfo]: ... def namelist(self) -> List[str]: ... def open( - self, name: Union[str, ZipInfo], mode: str = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ... + self, name: str | ZipInfo, mode: str = ..., pwd: Optional[bytes] = ..., *, 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: Optional[StrPath] = ..., pwd: Optional[bytes] = ...) -> str: ... def extractall( self, path: Optional[StrPath] = ..., members: Optional[Iterable[str]] = ..., pwd: Optional[bytes] = ... ) -> None: ... def printdir(self, file: Optional[_Writer] = ...) -> None: ... def setpassword(self, pwd: bytes) -> None: ... - def read(self, name: Union[str, ZipInfo], pwd: Optional[bytes] = ...) -> bytes: ... + def read(self, name: str | ZipInfo, pwd: Optional[bytes] = ...) -> bytes: ... def testzip(self) -> Optional[str]: ... if sys.version_info >= (3, 7): def write( @@ -160,14 +160,14 @@ class ZipFile: if sys.version_info >= (3, 7): def writestr( self, - zinfo_or_arcname: Union[str, ZipInfo], - data: Union[bytes, str], + zinfo_or_arcname: str | ZipInfo, + data: bytes | str, compress_type: Optional[int] = ..., compresslevel: Optional[int] = ..., ) -> 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: Optional[int] = ... ) -> None: ... class PyZipFile(ZipFile): From 2be1154370a5fe8ca707d353d3441ea0deba76aa Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:41:51 -0700 Subject: [PATCH 02/16] fastmod -d stdlib --accept-all '\bUnion\[([\w\.]+), ([\w\.]+), ([\w\.]+)\]' '$1 | $2 | $3' --- stdlib/@python2/__builtin__.pyi | 6 +++--- stdlib/@python2/_codecs.pyi | 2 +- stdlib/@python2/_curses.pyi | 2 +- stdlib/@python2/_dummy_threading.pyi | 2 +- stdlib/@python2/_io.pyi | 4 ++-- stdlib/@python2/_typeshed/__init__.pyi | 4 ++-- stdlib/@python2/argparse.pyi | 2 +- stdlib/@python2/array.pyi | 2 +- stdlib/@python2/ast.pyi | 2 +- stdlib/@python2/asynchat.pyi | 4 ++-- stdlib/@python2/builtins.pyi | 6 +++--- stdlib/@python2/cmath.pyi | 2 +- stdlib/@python2/dis.pyi | 2 +- stdlib/@python2/distutils/sysconfig.pyi | 2 +- stdlib/@python2/doctest.pyi | 12 ++++++------ stdlib/@python2/fractions.pyi | 4 ++-- stdlib/@python2/imaplib.pyi | 2 +- stdlib/@python2/io.pyi | 2 +- stdlib/@python2/locale.pyi | 2 +- stdlib/@python2/logging/__init__.pyi | 2 +- stdlib/@python2/pstats.pyi | 2 +- stdlib/@python2/pydoc.pyi | 2 +- stdlib/@python2/socket.pyi | 6 +++--- stdlib/@python2/sre_compile.pyi | 2 +- stdlib/@python2/ssl.pyi | 10 +++++----- stdlib/@python2/threading.pyi | 2 +- stdlib/@python2/turtle.pyi | 8 ++++---- stdlib/@python2/unittest.pyi | 2 +- stdlib/@python2/xml/etree/ElementInclude.pyi | 2 +- stdlib/@python2/xmlrpclib.pyi | 2 +- stdlib/_curses.pyi | 2 +- stdlib/_dummy_threading.pyi | 2 +- stdlib/_typeshed/__init__.pyi | 4 ++-- stdlib/argparse.pyi | 4 ++-- stdlib/array.pyi | 2 +- stdlib/ast.pyi | 2 +- stdlib/asynchat.pyi | 4 ++-- stdlib/asyncio/base_events.pyi | 4 ++-- stdlib/asyncio/events.pyi | 4 ++-- stdlib/builtins.pyi | 12 ++++++------ stdlib/cmath.pyi | 2 +- stdlib/decimal.pyi | 2 +- stdlib/dis.pyi | 2 +- stdlib/distutils/sysconfig.pyi | 2 +- stdlib/doctest.pyi | 12 ++++++------ stdlib/email/header.pyi | 6 +++--- stdlib/email/message.pyi | 2 +- stdlib/fractions.pyi | 4 ++-- stdlib/gzip.pyi | 4 ++-- stdlib/imaplib.pyi | 2 +- stdlib/io.pyi | 2 +- stdlib/json/__init__.pyi | 4 ++-- stdlib/locale.pyi | 2 +- stdlib/multiprocessing/connection.pyi | 4 ++-- stdlib/multiprocessing/managers.pyi | 8 ++++---- stdlib/pstats.pyi | 2 +- stdlib/pydoc.pyi | 2 +- stdlib/smtplib.pyi | 2 +- stdlib/socket.pyi | 8 ++++---- stdlib/sre_compile.pyi | 2 +- stdlib/ssl.pyi | 12 ++++++------ stdlib/statistics.pyi | 2 +- stdlib/threading.pyi | 2 +- stdlib/tkinter/__init__.pyi | 2 +- stdlib/tokenize.pyi | 2 +- stdlib/turtle.pyi | 8 ++++---- stdlib/unittest/case.pyi | 2 +- stdlib/unittest/main.pyi | 4 ++-- stdlib/xml/etree/ElementInclude.pyi | 2 +- stdlib/zipapp.pyi | 2 +- 70 files changed, 128 insertions(+), 128 deletions(-) diff --git a/stdlib/@python2/__builtin__.pyi b/stdlib/@python2/__builtin__.pyi index ff1dfbf0c56d..ff5e5ca57c86 100644 --- a/stdlib/@python2/__builtin__.pyi +++ b/stdlib/@python2/__builtin__.pyi @@ -139,7 +139,7 @@ class int: @overload def __new__(cls: Type[_T], x: Union[Text, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc] = ...) -> _T: ... @overload - def __new__(cls: Type[_T], x: Union[Text, bytes, bytearray], base: int) -> _T: ... + def __new__(cls: Type[_T], x: Text | bytes | bytearray, base: int) -> _T: ... @property def real(self) -> int: ... @property @@ -253,7 +253,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]) -> _T: ... + def __new__(cls: Type[_T], real: str | SupportsComplex | _SupportsIndex) -> _T: ... @property def real(self) -> float: ... @property @@ -846,7 +846,7 @@ _N2 = TypeVar("_N2", int, float) def divmod(__x: _N2, __y: _N2) -> Tuple[_N2, _N2]: ... def eval( - __source: Union[Text, bytes, CodeType], __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ... + __source: Text | bytes | CodeType, __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ... ) -> Any: ... def execfile(__filename: str, __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Dict[str, Any]] = ...) -> None: ... def exit(code: object = ...) -> NoReturn: ... diff --git a/stdlib/@python2/_codecs.pyi b/stdlib/@python2/_codecs.pyi index 0a368a71db34..3dd4479ad333 100644 --- a/stdlib/@python2/_codecs.pyi +++ b/stdlib/@python2/_codecs.pyi @@ -5,7 +5,7 @@ from typing import Any, Callable, Dict, Optional, Text, Tuple, Union # For convenience: _Handler = Callable[[Exception], Tuple[Text, int]] _String = bytes | str -_Errors = Union[str, Text, None] +_Errors = str | Text | None _Decodable = bytes | Text _Encodable = bytes | Text diff --git a/stdlib/@python2/_curses.pyi b/stdlib/@python2/_curses.pyi index d6c286e37d13..373ad94d01d6 100644 --- a/stdlib/@python2/_curses.pyi +++ b/stdlib/@python2/_curses.pyi @@ -1,6 +1,6 @@ from typing import IO, Any, BinaryIO, Optional, Tuple, Union, overload -_chtype = Union[str, bytes, int] +_chtype = str | bytes | int # ACS codes are only initialized after initscr is called ACS_BBSS: int diff --git a/stdlib/@python2/_dummy_threading.pyi b/stdlib/@python2/_dummy_threading.pyi index bab2acdc84cd..06392616484e 100644 --- a/stdlib/@python2/_dummy_threading.pyi +++ b/stdlib/@python2/_dummy_threading.pyi @@ -71,7 +71,7 @@ class _RLock: 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] diff --git a/stdlib/@python2/_io.pyi b/stdlib/@python2/_io.pyi index 23778e445044..369a53bc9f27 100644 --- a/stdlib/@python2/_io.pyi +++ b/stdlib/@python2/_io.pyi @@ -115,7 +115,7 @@ class IncrementalNewlineDecoder(object): class _TextIOBase(TextIO): errors: Optional[str] # TODO: On _TextIOBase, this is always None. But it's unicode/bytes in subclasses. - newlines: Union[None, unicode, bytes] + newlines: None | unicode | bytes encoding: str @property def closed(self) -> bool: ... @@ -173,7 +173,7 @@ class TextIOWrapper(_TextIOBase): ) -> None: ... def open( - file: Union[str, unicode, int], + file: str | unicode | int, mode: Text = ..., buffering: int = ..., encoding: Optional[Text] = ..., diff --git a/stdlib/@python2/_typeshed/__init__.pyi b/stdlib/@python2/_typeshed/__init__.pyi index e8f0d708e70f..4e9f2abb152c 100644 --- a/stdlib/@python2/_typeshed/__init__.pyi +++ b/stdlib/@python2/_typeshed/__init__.pyi @@ -100,7 +100,7 @@ OpenTextModeUpdating = Literal[ ] OpenTextModeWriting = Literal["w", "wt", "tw", "a", "at", "ta", "x", "xt", "tx"] OpenTextModeReading = Literal["r", "rt", "tr", "U", "rU", "Ur", "rtU", "rUt", "Urt", "trU", "tUr", "Utr"] -OpenTextMode = Union[OpenTextModeUpdating, OpenTextModeWriting, OpenTextModeReading] +OpenTextMode = OpenTextModeUpdating | OpenTextModeWriting | OpenTextModeReading OpenBinaryModeUpdating = Literal[ "rb+", "r+b", @@ -129,7 +129,7 @@ OpenBinaryModeUpdating = Literal[ ] OpenBinaryModeWriting = Literal["wb", "bw", "ab", "ba", "xb", "bx"] OpenBinaryModeReading = Literal["rb", "br", "rbU", "rUb", "Urb", "brU", "bUr", "Ubr"] -OpenBinaryMode = Union[OpenBinaryModeUpdating, OpenBinaryModeReading, OpenBinaryModeWriting] +OpenBinaryMode = OpenBinaryModeUpdating | OpenBinaryModeReading | OpenBinaryModeWriting class HasFileno(Protocol): def fileno(self) -> int: ... diff --git a/stdlib/@python2/argparse.pyi b/stdlib/@python2/argparse.pyi index 15bad69607d1..28241cd7174e 100644 --- a/stdlib/@python2/argparse.pyi +++ b/stdlib/@python2/argparse.pyi @@ -242,7 +242,7 @@ class Action(_AttributeHolder): dest: Text, nargs: Optional[int | Text] = ..., const: Optional[_T] = ..., - default: Union[_T, str, None] = ..., + default: _T | str | None = ..., type: Optional[Union[Callable[[Text], _T], Callable[[str], _T], FileType]] = ..., choices: Optional[Iterable[_T]] = ..., required: bool = ..., diff --git a/stdlib/@python2/array.pyi b/stdlib/@python2/array.pyi index 76b35956a4db..964d992c95e5 100644 --- a/stdlib/@python2/array.pyi +++ b/stdlib/@python2/array.pyi @@ -4,7 +4,7 @@ from typing_extensions import Literal _IntTypeCode = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"] _FloatTypeCode = Literal["f", "d"] _UnicodeTypeCode = Literal["u"] -_TypeCode = Union[_IntTypeCode, _FloatTypeCode, _UnicodeTypeCode] +_TypeCode = _IntTypeCode | _FloatTypeCode | _UnicodeTypeCode _T = TypeVar("_T", int, float, Text) diff --git a/stdlib/@python2/ast.pyi b/stdlib/@python2/ast.pyi index c04cecac6738..ea0899c442c5 100644 --- a/stdlib/@python2/ast.pyi +++ b/stdlib/@python2/ast.pyi @@ -17,7 +17,7 @@ def get_docstring(node: AST, clean: bool = ...) -> 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: Union[str, unicode, AST]) -> Any: ... +def literal_eval(node_or_string: str | unicode | AST) -> Any: ... def walk(node: AST) -> Iterator[AST]: ... class NodeVisitor: diff --git a/stdlib/@python2/asynchat.pyi b/stdlib/@python2/asynchat.pyi index ec548a417cfb..7effb73d9a26 100644 --- a/stdlib/@python2/asynchat.pyi +++ b/stdlib/@python2/asynchat.pyi @@ -15,8 +15,8 @@ class async_chat(asyncore.dispatcher): 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/@python2/builtins.pyi b/stdlib/@python2/builtins.pyi index ff1dfbf0c56d..ff5e5ca57c86 100644 --- a/stdlib/@python2/builtins.pyi +++ b/stdlib/@python2/builtins.pyi @@ -139,7 +139,7 @@ class int: @overload def __new__(cls: Type[_T], x: Union[Text, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc] = ...) -> _T: ... @overload - def __new__(cls: Type[_T], x: Union[Text, bytes, bytearray], base: int) -> _T: ... + def __new__(cls: Type[_T], x: Text | bytes | bytearray, base: int) -> _T: ... @property def real(self) -> int: ... @property @@ -253,7 +253,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]) -> _T: ... + def __new__(cls: Type[_T], real: str | SupportsComplex | _SupportsIndex) -> _T: ... @property def real(self) -> float: ... @property @@ -846,7 +846,7 @@ _N2 = TypeVar("_N2", int, float) def divmod(__x: _N2, __y: _N2) -> Tuple[_N2, _N2]: ... def eval( - __source: Union[Text, bytes, CodeType], __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ... + __source: Text | bytes | CodeType, __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ... ) -> Any: ... def execfile(__filename: str, __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Dict[str, Any]] = ...) -> None: ... def exit(code: object = ...) -> NoReturn: ... diff --git a/stdlib/@python2/cmath.pyi b/stdlib/@python2/cmath.pyi index 1e19687b4885..9f2bf4a66347 100644 --- a/stdlib/@python2/cmath.pyi +++ b/stdlib/@python2/cmath.pyi @@ -2,7 +2,7 @@ from typing import SupportsComplex, SupportsFloat, Tuple, Union e: float pi: float -_C = Union[SupportsFloat, SupportsComplex, complex] +_C = SupportsFloat | SupportsComplex | complex def acos(__z: _C) -> complex: ... def acosh(__z: _C) -> complex: ... diff --git a/stdlib/@python2/dis.pyi b/stdlib/@python2/dis.pyi index 1d6537667a60..abf4ee44698f 100644 --- a/stdlib/@python2/dis.pyi +++ b/stdlib/@python2/dis.pyi @@ -18,7 +18,7 @@ from typing import Any, Callable, Dict, Iterator, List, Tuple, Union # Strictly this should not have to include Callable, but mypy doesn't use FunctionType # for functions (python/mypy#3171) _have_code = Union[types.MethodType, types.FunctionType, types.CodeType, type, Callable[..., Any]] -_have_code_or_string = Union[_have_code, str, bytes] +_have_code_or_string = _have_code | str | bytes COMPILER_FLAG_NAMES: Dict[int, str] diff --git a/stdlib/@python2/distutils/sysconfig.pyi b/stdlib/@python2/distutils/sysconfig.pyi index 2a7af45b9c27..34add92533b9 100644 --- a/stdlib/@python2/distutils/sysconfig.pyi +++ b/stdlib/@python2/distutils/sysconfig.pyi @@ -4,7 +4,7 @@ from typing import Mapping, Optional, Union PREFIX: str EXEC_PREFIX: str -def get_config_var(name: str) -> Union[int, str, None]: ... +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: ... diff --git a/stdlib/@python2/doctest.pyi b/stdlib/@python2/doctest.pyi index 35762bba5528..cd6a99ab31a5 100644 --- a/stdlib/@python2/doctest.pyi +++ b/stdlib/@python2/doctest.pyi @@ -80,7 +80,7 @@ class DocTestFinder: self, obj: object, name: Optional[str] = ..., - module: Union[None, bool, types.ModuleType] = ..., + module: None | bool | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., extraglobs: Optional[Dict[str, Any]] = ..., ) -> List[DocTest]: ... @@ -141,7 +141,7 @@ def testfile( filename: str, module_relative: bool = ..., name: Optional[str] = ..., - package: Union[None, str, types.ModuleType] = ..., + package: None | str | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., verbose: Optional[bool] = ..., report: bool = ..., @@ -188,7 +188,7 @@ class SkipDocTestCase(DocTestCase): _DocTestSuite = unittest.TestSuite def DocTestSuite( - module: Union[None, str, types.ModuleType] = ..., + module: None | str | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., extraglobs: Optional[Dict[str, Any]] = ..., test_finder: Optional[DocTestFinder] = ..., @@ -202,7 +202,7 @@ class DocFileCase(DocTestCase): def DocFileTest( path: str, module_relative: bool = ..., - package: Union[None, str, types.ModuleType] = ..., + package: None | str | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., parser: DocTestParser = ..., encoding: Optional[str] = ..., @@ -210,7 +210,7 @@ def DocFileTest( ) -> 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 testsource(module: 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 debug(module: None | str | types.ModuleType, name: str, pm: bool = ...) -> None: ... diff --git a/stdlib/@python2/fractions.pyi b/stdlib/@python2/fractions.pyi index 71a09ce1f1ec..3687c2761bc2 100644 --- a/stdlib/@python2/fractions.pyi +++ b/stdlib/@python2/fractions.pyi @@ -25,7 +25,7 @@ class Fraction(Rational): _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 @@ -126,7 +126,7 @@ class Fraction(Rational): @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/@python2/imaplib.pyi b/stdlib/@python2/imaplib.pyi index 73063629295a..18f21ef137e5 100644 --- a/stdlib/@python2/imaplib.pyi +++ b/stdlib/@python2/imaplib.pyi @@ -127,4 +127,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/@python2/io.pyi b/stdlib/@python2/io.pyi index 1e29cc67369f..04b6da2a2cc4 100644 --- a/stdlib/@python2/io.pyi +++ b/stdlib/@python2/io.pyi @@ -18,7 +18,7 @@ from _io import ( ) def _OpenWrapper( - file: Union[str, unicode, int], + file: str | unicode | int, mode: unicode = ..., buffering: int = ..., encoding: unicode = ..., diff --git a/stdlib/@python2/locale.pyi b/stdlib/@python2/locale.pyi index 44dd2f5f6436..9fca89e986a2 100644 --- a/stdlib/@python2/locale.pyi +++ b/stdlib/@python2/locale.pyi @@ -86,7 +86,7 @@ def strcoll(string1: _str, string2: _str) -> int: ... def strxfrm(string: _str) -> _str: ... def format(percent: _str, value: float | Decimal, grouping: bool = ..., monetary: bool = ..., *additional: Any) -> _str: ... 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 atof(string: _str, func: Callable[[_str], float] = ...) -> float: ... def atoi(string: _str) -> int: ... def str(val: float) -> _str: ... diff --git a/stdlib/@python2/logging/__init__.pyi b/stdlib/@python2/logging/__init__.pyi index d41e1055f4e6..68524da772ff 100644 --- a/stdlib/@python2/logging/__init__.pyi +++ b/stdlib/@python2/logging/__init__.pyi @@ -5,7 +5,7 @@ from types import FrameType, TracebackType from typing import IO, Any, Callable, Dict, List, Mapping, MutableMapping, Optional, Sequence, Text, Tuple, Union, overload _SysExcInfoType = Union[Tuple[type, BaseException, Optional[TracebackType]], Tuple[None, None, None]] -_ExcInfoType = Union[None, bool, _SysExcInfoType] +_ExcInfoType = None | bool | _SysExcInfoType _ArgsType = Union[Tuple[Any, ...], Mapping[str, Any]] _FilterType = Union[Filter, Callable[[LogRecord], int]] _Level = int | Text diff --git a/stdlib/@python2/pstats.pyi b/stdlib/@python2/pstats.pyi index d1404dc7c01a..c8cd53367b3b 100644 --- a/stdlib/@python2/pstats.pyi +++ b/stdlib/@python2/pstats.pyi @@ -2,7 +2,7 @@ from cProfile import Profile as _cProfile from profile import Profile from typing import IO, Any, Dict, Iterable, List, Optional, Text, Tuple, TypeVar, Union, overload -_Selector = Union[str, float, int] +_Selector = str | float | int _T = TypeVar("_T", bound=Stats) class Stats: diff --git a/stdlib/@python2/pydoc.pyi b/stdlib/@python2/pydoc.pyi index d2d853410cec..081fd2723adc 100644 --- a/stdlib/@python2/pydoc.pyi +++ b/stdlib/@python2/pydoc.pyi @@ -224,7 +224,7 @@ class Helper: def __init__(self, input: Optional[IO[str]] = ..., output: Optional[IO[str]] = ...) -> 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: ... diff --git a/stdlib/@python2/socket.pyi b/stdlib/@python2/socket.pyi index 373661980460..2a5b924a9f45 100644 --- a/stdlib/@python2/socket.pyi +++ b/stdlib/@python2/socket.pyi @@ -430,14 +430,14 @@ class socket: def create_connection( address: Tuple[Optional[str], int], timeout: Optional[float] = ..., - source_address: Optional[Tuple[Union[bytearray, bytes, Text], int]] = ..., + source_address: Optional[Tuple[bytearray | bytes | Text, int]] = ..., ) -> socket: ... def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ... # the 5th tuple item is an address def getaddrinfo( - host: Optional[Union[bytearray, bytes, Text]], - port: Union[str, int, None], + host: Optional[bytearray | bytes | Text], + port: str | int | None, family: int = ..., socktype: int = ..., proto: int = ..., diff --git a/stdlib/@python2/sre_compile.pyi b/stdlib/@python2/sre_compile.pyi index 23317a918dad..2d526d039ca8 100644 --- a/stdlib/@python2/sre_compile.pyi +++ b/stdlib/@python2/sre_compile.pyi @@ -19,4 +19,4 @@ STRING_TYPES: Tuple[Type[str], Type[unicode]] _IsStringType = int def isstring(obj: Any) -> _IsStringType: ... -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/@python2/ssl.pyi b/stdlib/@python2/ssl.pyi index aa5e6af4d366..1a4133983d52 100644 --- a/stdlib/@python2/ssl.pyi +++ b/stdlib/@python2/ssl.pyi @@ -6,8 +6,8 @@ from typing_extensions import Literal _PCTRTT = Tuple[Tuple[str, str], ...] _PCTRTTT = Tuple[_PCTRTT, ...] -_PeerCertRetDictType = Dict[str, Union[str, _PCTRTTT, _PCTRTT]] -_PeerCertRetType = Union[_PeerCertRetDictType, bytes, None] +_PeerCertRetDictType = Dict[str, str | _PCTRTTT | _PCTRTT] +_PeerCertRetType = _PeerCertRetDictType | bytes | None _EnumRetType = List[Tuple[bytes, str, Union[Set[str], bool]]] _PasswordType = Union[Callable[[], str | bytes], str, bytes] @@ -38,7 +38,7 @@ def wrap_socket( ciphers: Optional[str] = ..., ) -> SSLSocket: ... def create_default_context( - purpose: Any = ..., *, cafile: Optional[str] = ..., capath: Optional[str] = ..., cadata: Union[Text, bytes, None] = ... + purpose: Any = ..., *, cafile: Optional[str] = ..., capath: Optional[str] = ..., cadata: Text | bytes | None = ... ) -> SSLContext: ... def _create_unverified_context( protocol: int = ..., @@ -50,7 +50,7 @@ def _create_unverified_context( keyfile: Optional[str] = ..., cafile: Optional[str] = ..., capath: Optional[str] = ..., - cadata: Union[Text, bytes, None] = ..., + cadata: Text | bytes | None = ..., ) -> SSLContext: ... _create_default_https_context: Callable[..., SSLContext] @@ -225,7 +225,7 @@ class SSLContext: ) -> None: ... def load_default_certs(self, purpose: Purpose = ...) -> None: ... def load_verify_locations( - self, cafile: Optional[StrPath] = ..., capath: Optional[StrPath] = ..., cadata: Union[Text, bytes, None] = ... + self, cafile: Optional[StrPath] = ..., capath: Optional[StrPath] = ..., cadata: Text | bytes | None = ... ) -> None: ... def get_ca_certs(self, binary_form: bool = ...) -> Union[List[_PeerCertRetDictType], List[bytes]]: ... def set_default_verify_paths(self) -> None: ... diff --git a/stdlib/@python2/threading.pyi b/stdlib/@python2/threading.pyi index bab2acdc84cd..06392616484e 100644 --- a/stdlib/@python2/threading.pyi +++ b/stdlib/@python2/threading.pyi @@ -71,7 +71,7 @@ class _RLock: 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] diff --git a/stdlib/@python2/turtle.pyi b/stdlib/@python2/turtle.pyi index 9ea800f0d5eb..87c60c3235b9 100644 --- a/stdlib/@python2/turtle.pyi +++ b/stdlib/@python2/turtle.pyi @@ -33,7 +33,7 @@ class Terminator(Exception): ... class TurtleGraphicsError(Exception): ... class Shape(object): - def __init__(self, type_: str, data: Union[_PolygonCoords, PhotoImage, None] = ...) -> None: ... + def __init__(self, type_: str, data: _PolygonCoords | PhotoImage | None = ...) -> None: ... def addcomponent(self, poly: _PolygonCoords, fill: _Color, outline: Optional[_Color] = ...) -> None: ... class TurtleScreen(TurtleScreenBase): @@ -44,7 +44,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 @@ -203,7 +203,7 @@ _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: ... @@ -295,7 +295,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 diff --git a/stdlib/@python2/unittest.pyi b/stdlib/@python2/unittest.pyi index 21b4c0a7498a..8d46e5b8d244 100644 --- a/stdlib/@python2/unittest.pyi +++ b/stdlib/@python2/unittest.pyi @@ -256,7 +256,7 @@ class TestProgram: def runTests(self) -> None: ... # undocumented def main( - module: Union[None, Text, types.ModuleType] = ..., + module: None | Text | types.ModuleType = ..., defaultTest: Optional[str] = ..., argv: Optional[Sequence[str]] = ..., testRunner: Union[Type[TextTestRunner], TextTestRunner, None] = ..., diff --git a/stdlib/@python2/xml/etree/ElementInclude.pyi b/stdlib/@python2/xml/etree/ElementInclude.pyi index 97b8bdd8cc8b..43ac953ba00b 100644 --- a/stdlib/@python2/xml/etree/ElementInclude.pyi +++ b/stdlib/@python2/xml/etree/ElementInclude.pyi @@ -7,7 +7,7 @@ XINCLUDE_FALLBACK: str class FatalIncludeError(SyntaxError): ... -def default_loader(href: Union[str, bytes, int], parse: str, encoding: Optional[str] = ...) -> str | Element: ... +def default_loader(href: str | bytes | int, parse: str, encoding: Optional[str] = ...) -> 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 diff --git a/stdlib/@python2/xmlrpclib.pyi b/stdlib/@python2/xmlrpclib.pyi index 3d3a0a6b099e..c1d8b8c966f9 100644 --- a/stdlib/@python2/xmlrpclib.pyi +++ b/stdlib/@python2/xmlrpclib.pyi @@ -10,7 +10,7 @@ from typing import IO, Any, AnyStr, Callable, Iterable, List, Mapping, MutableMa _Unmarshaller = Any _timeTuple = Tuple[int, int, int, int, int, int, int, int, int] # Represents types that can be compared against a DateTime object -_dateTimeComp = Union[unicode, DateTime, datetime] +_dateTimeComp = unicode | DateTime | datetime # A "host description" used by Transport factories _hostDesc = Union[str, Tuple[str, Mapping[Any, Any]]] diff --git a/stdlib/_curses.pyi b/stdlib/_curses.pyi index 9d5084902ce1..7c54e2de56ab 100644 --- a/stdlib/_curses.pyi +++ b/stdlib/_curses.pyi @@ -1,7 +1,7 @@ import sys from typing import IO, Any, BinaryIO, NamedTuple, Optional, Tuple, Union, overload -_chtype = Union[str, bytes, int] +_chtype = str | bytes | int # ACS codes are only initialized after initscr is called ACS_BBSS: int diff --git a/stdlib/_dummy_threading.pyi b/stdlib/_dummy_threading.pyi index de75375056e0..5d59eecc64e0 100644 --- a/stdlib/_dummy_threading.pyi +++ b/stdlib/_dummy_threading.pyi @@ -85,7 +85,7 @@ class _RLock: 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] diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index 56ba4c635a19..49402963d8dc 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -95,7 +95,7 @@ OpenTextModeUpdating = Literal[ ] OpenTextModeWriting = Literal["w", "wt", "tw", "a", "at", "ta", "x", "xt", "tx"] OpenTextModeReading = Literal["r", "rt", "tr", "U", "rU", "Ur", "rtU", "rUt", "Urt", "trU", "tUr", "Utr"] -OpenTextMode = Union[OpenTextModeUpdating, OpenTextModeWriting, OpenTextModeReading] +OpenTextMode = OpenTextModeUpdating | OpenTextModeWriting | OpenTextModeReading OpenBinaryModeUpdating = Literal[ "rb+", "r+b", @@ -124,7 +124,7 @@ OpenBinaryModeUpdating = Literal[ ] OpenBinaryModeWriting = Literal["wb", "bw", "ab", "ba", "xb", "bx"] OpenBinaryModeReading = Literal["rb", "br", "rbU", "rUb", "Urb", "brU", "bUr", "Ubr"] -OpenBinaryMode = Union[OpenBinaryModeUpdating, OpenBinaryModeReading, OpenBinaryModeWriting] +OpenBinaryMode = OpenBinaryModeUpdating | OpenBinaryModeReading | OpenBinaryModeWriting # stable class HasFileno(Protocol): diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index c8df032fce67..cede7ae295a8 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -283,7 +283,7 @@ class Action(_AttributeHolder): dest: str, nargs: Optional[int | str] = ..., const: Optional[_T] = ..., - default: Union[_T, str, None] = ..., + default: _T | str | None = ..., type: Optional[Union[Callable[[str], _T], Callable[[str], _T], FileType]] = ..., choices: Optional[Iterable[_T]] = ..., required: bool = ..., @@ -306,7 +306,7 @@ if sys.version_info >= (3, 9): self, option_strings: Sequence[str], dest: str, - default: Union[_T, str, None] = ..., + default: _T | str | None = ..., type: Optional[Union[Callable[[str], _T], Callable[[str], _T], FileType]] = ..., choices: Optional[Iterable[_T]] = ..., required: bool = ..., diff --git a/stdlib/array.pyi b/stdlib/array.pyi index 9e2676d15fc3..cc8d56d7b6e5 100644 --- a/stdlib/array.pyi +++ b/stdlib/array.pyi @@ -5,7 +5,7 @@ from typing_extensions import Literal _IntTypeCode = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"] _FloatTypeCode = Literal["f", "d"] _UnicodeTypeCode = Literal["u"] -_TypeCode = Union[_IntTypeCode, _FloatTypeCode, _UnicodeTypeCode] +_TypeCode = _IntTypeCode | _FloatTypeCode | _UnicodeTypeCode _T = TypeVar("_T", int, float, str) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 06a493dd7295..ee6f18a74b3a 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -188,7 +188,7 @@ 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: diff --git a/stdlib/asynchat.pyi b/stdlib/asynchat.pyi index 94637d04a264..7cb08c363b30 100644 --- a/stdlib/asynchat.pyi +++ b/stdlib/asynchat.pyi @@ -15,8 +15,8 @@ class async_chat(asyncore.dispatcher): 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 de460300d789..a4f3b1f89b7f 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -19,7 +19,7 @@ _T = TypeVar("_T") _Context = Dict[str, Any] _ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any] _ProtocolFactory = Callable[[], BaseProtocol] -_SSLContext = Union[bool, None, ssl.SSLContext] +_SSLContext = bool | None | ssl.SSLContext _TransProtPair = Tuple[BaseTransport, BaseProtocol] class Server(AbstractServer): @@ -92,7 +92,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): async def getaddrinfo( self, host: Optional[str], - port: Union[str, int, None], + port: str | int | None, *, family: int = ..., type: int = ..., diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index e4f80b607019..ad5fe08f6380 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -18,7 +18,7 @@ _T = TypeVar("_T") _Context = Dict[str, Any] _ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any] _ProtocolFactory = Callable[[], BaseProtocol] -_SSLContext = Union[bool, None, ssl.SSLContext] +_SSLContext = bool | None | ssl.SSLContext _TransProtPair = Tuple[BaseTransport, BaseProtocol] class Handle: @@ -121,7 +121,7 @@ class AbstractEventLoop(metaclass=ABCMeta): async def getaddrinfo( self, host: Optional[str], - port: Union[str, int, None], + port: str | int | None, *, family: int = ..., type: int = ..., diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 8489e15442ab..ea9ab7704a46 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -170,7 +170,7 @@ class int: @overload def __new__(cls: Type[_T], x: Union[str, bytes, SupportsInt, SupportsIndex, _SupportsTrunc] = ...) -> _T: ... @overload - def __new__(cls: Type[_T], x: Union[str, bytes, bytearray], base: int) -> _T: ... + def __new__(cls: Type[_T], x: str | bytes | bytearray, base: int) -> _T: ... if sys.version_info >= (3, 8): def as_integer_ratio(self) -> Tuple[int, Literal[1]]: ... @property @@ -299,7 +299,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]) -> _T: ... + def __new__(cls: Type[_T], real: str | SupportsComplex | SupportsIndex) -> _T: ... @property def real(self) -> float: ... @property @@ -381,7 +381,7 @@ class str(Sequence[str]): def strip(self, __chars: Optional[str] = ...) -> 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: Union[Mapping[int, int | str | None], Sequence[int | str | None]]) -> str: ... def upper(self) -> str: ... def zfill(self, __width: int) -> str: ... @staticmethod @@ -1003,10 +1003,10 @@ 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: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ... ) -> Any: ... def exec( - __source: Union[str, bytes, CodeType], __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ... + __source: str | bytes | CodeType, __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ... ) -> Any: ... def exit(code: object = ...) -> NoReturn: ... @@ -1382,7 +1382,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": diff --git a/stdlib/cmath.pyi b/stdlib/cmath.pyi index 8d67e6c47bb4..7e6290664aba 100644 --- a/stdlib/cmath.pyi +++ b/stdlib/cmath.pyi @@ -8,7 +8,7 @@ nan: float nanj: complex tau: float -_C = Union[SupportsFloat, SupportsComplex, complex] +_C = SupportsFloat | SupportsComplex | complex def acos(__z: _C) -> complex: ... def acosh(__z: _C) -> complex: ... diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 41bb90eaef21..496f717576cb 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -4,7 +4,7 @@ from typing import Any, Container, Dict, List, NamedTuple, Optional, Sequence, T _Decimal = Decimal | int _DecimalNew = Union[Decimal, float, str, Tuple[int, Sequence[int], int]] -_ComparableNum = Union[Decimal, float, numbers.Rational] +_ComparableNum = Decimal | float | numbers.Rational _DecimalT = TypeVar("_DecimalT", bound=Decimal) class DecimalTuple(NamedTuple): diff --git a/stdlib/dis.pyi b/stdlib/dis.pyi index 60fa845d0206..a236082ebde6 100644 --- a/stdlib/dis.pyi +++ b/stdlib/dis.pyi @@ -21,7 +21,7 @@ from typing import IO, Any, Callable, Dict, Iterator, List, NamedTuple, Optional # Strictly this should not have to include Callable, but mypy doesn't use FunctionType # for functions (python/mypy#3171) _have_code = Union[types.MethodType, types.FunctionType, types.CodeType, type, Callable[..., Any]] -_have_code_or_string = Union[_have_code, str, bytes] +_have_code_or_string = _have_code | str | bytes class Instruction(NamedTuple): opname: str diff --git a/stdlib/distutils/sysconfig.pyi b/stdlib/distutils/sysconfig.pyi index a75ae9db7aa5..c9827f347eb0 100644 --- a/stdlib/distutils/sysconfig.pyi +++ b/stdlib/distutils/sysconfig.pyi @@ -4,7 +4,7 @@ from typing import Mapping, Optional, Union PREFIX: str EXEC_PREFIX: str -def get_config_var(name: str) -> Union[int, str, None]: ... +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: ... diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index b263199a3a6d..fc42f13a286c 100644 --- a/stdlib/doctest.pyi +++ b/stdlib/doctest.pyi @@ -82,7 +82,7 @@ class DocTestFinder: self, obj: object, name: Optional[str] = ..., - module: Union[None, bool, types.ModuleType] = ..., + module: None | bool | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., extraglobs: Optional[Dict[str, Any]] = ..., ) -> List[DocTest]: ... @@ -143,7 +143,7 @@ def testfile( filename: str, module_relative: bool = ..., name: Optional[str] = ..., - package: Union[None, str, types.ModuleType] = ..., + package: None | str | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., verbose: Optional[bool] = ..., report: bool = ..., @@ -190,7 +190,7 @@ class SkipDocTestCase(DocTestCase): class _DocTestSuite(unittest.TestSuite): ... def DocTestSuite( - module: Union[None, str, types.ModuleType] = ..., + module: None | str | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., extraglobs: Optional[Dict[str, Any]] = ..., test_finder: Optional[DocTestFinder] = ..., @@ -204,7 +204,7 @@ class DocFileCase(DocTestCase): def DocFileTest( path: str, module_relative: bool = ..., - package: Union[None, str, types.ModuleType] = ..., + package: None | str | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., parser: DocTestParser = ..., encoding: Optional[str] = ..., @@ -212,7 +212,7 @@ def DocFileTest( ) -> 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 testsource(module: 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 debug(module: None | str | types.ModuleType, name: str, pm: bool = ...) -> None: ... diff --git a/stdlib/email/header.pyi b/stdlib/email/header.pyi index a877827af63a..962086bcf4f3 100644 --- a/stdlib/email/header.pyi +++ b/stdlib/email/header.pyi @@ -4,14 +4,14 @@ from typing import Any, List, Optional, Tuple, Union class Header: def __init__( self, - s: Union[bytes, str, None] = ..., - charset: Union[Charset, str, None] = ..., + s: bytes | str | None = ..., + charset: Charset | str | None = ..., maxlinelen: Optional[int] = ..., header_name: Optional[str] = ..., continuation_ws: str = ..., errors: str = ..., ) -> None: ... - def append(self, s: bytes | str, charset: Union[Charset, str, None] = ..., errors: str = ...) -> None: ... + def append(self, s: bytes | str, charset: Charset | str | None = ..., errors: str = ...) -> None: ... def encode(self, splitchars: str = ..., maxlinelen: Optional[int] = ..., linesep: str = ...) -> str: ... def __str__(self) -> str: ... def __eq__(self, other: Any) -> bool: ... diff --git a/stdlib/email/message.pyi b/stdlib/email/message.pyi index 8c22c8459d09..b215dda7df22 100644 --- a/stdlib/email/message.pyi +++ b/stdlib/email/message.pyi @@ -7,7 +7,7 @@ from typing import Any, Generator, Iterator, List, Optional, Sequence, Tuple, Ty _T = TypeVar("_T") _PayloadType = Union[List[Message], str, bytes] -_CharsetType = Union[Charset, str, None] +_CharsetType = Charset | str | None _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] _ParamType = Union[str, Tuple[Optional[str], Optional[str], str]] _HeaderType = Any diff --git a/stdlib/fractions.pyi b/stdlib/fractions.pyi index 22c48cbddaed..aca5f5e890a2 100644 --- a/stdlib/fractions.pyi +++ b/stdlib/fractions.pyi @@ -27,7 +27,7 @@ class Fraction(Rational): _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 @@ -118,7 +118,7 @@ class Fraction(Rational): @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/gzip.pyi b/stdlib/gzip.pyi index ed3c2c237952..09b4cc03e362 100644 --- a/stdlib/gzip.pyi +++ b/stdlib/gzip.pyi @@ -58,7 +58,7 @@ def open( ) -> TextIO: ... @overload def open( - filename: Union[StrOrBytesPath, _ReadableFileobj, _WritableFileobj], + filename: StrOrBytesPath | _ReadableFileobj | _WritableFileobj, mode: str, compresslevel: int = ..., encoding: Optional[str] = ..., @@ -125,7 +125,7 @@ class GzipFile(_compression.BaseStream): filename: Optional[StrOrBytesPath] = ..., mode: Optional[str] = ..., compresslevel: int = ..., - fileobj: Union[_ReadableFileobj, _WritableFileobj, None] = ..., + fileobj: _ReadableFileobj | _WritableFileobj | None = ..., mtime: Optional[float] = ..., ) -> None: ... @property diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index 9fc3a740c463..9d39c3fc5287 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -163,4 +163,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/io.pyi b/stdlib/io.pyi index 40e619608e65..76f276541d3a 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -70,7 +70,7 @@ class FileIO(RawIOBase, BinaryIO): name: int | str # type: ignore def __init__( self, - file: Union[str, bytes, int], + file: str | bytes | int, mode: str = ..., closefd: bool = ..., opener: Optional[Callable[[int | str, str], int]] = ..., diff --git a/stdlib/json/__init__.pyi b/stdlib/json/__init__.pyi index 1a6f7e51422d..9ac4411ba1ce 100644 --- a/stdlib/json/__init__.pyi +++ b/stdlib/json/__init__.pyi @@ -12,7 +12,7 @@ def dumps( check_circular: bool = ..., allow_nan: bool = ..., cls: Optional[Type[JSONEncoder]] = ..., - indent: Union[None, int, str] = ..., + indent: None | int | str = ..., separators: Optional[Tuple[str, str]] = ..., default: Optional[Callable[[Any], Any]] = ..., sort_keys: bool = ..., @@ -27,7 +27,7 @@ def dump( check_circular: bool = ..., allow_nan: bool = ..., cls: Optional[Type[JSONEncoder]] = ..., - indent: Union[None, int, str] = ..., + indent: None | int | str = ..., separators: Optional[Tuple[str, str]] = ..., default: Optional[Callable[[Any], Any]] = ..., sort_keys: bool = ..., diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index d64eef740ef2..41886857250f 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -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/multiprocessing/connection.pyi b/stdlib/multiprocessing/connection.pyi index 15f58a3745f3..b13062218230 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -56,7 +56,7 @@ class Listener: 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]]: ... + object_list: Iterable[Connection | socket.socket | int], timeout: Optional[float] = ... +) -> List[Connection | socket.socket | int]: ... def Client(address: _Address, family: Optional[str] = ..., authkey: Optional[bytes] = ...) -> Connection: ... def Pipe(duplex: bool = ...) -> Tuple[Connection, Connection]: ... diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index cb26c579c042..3e6e4b0b6c68 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -46,16 +46,16 @@ _Namespace = Namespace class Token(object): typeid: Optional[str | bytes] address: Tuple[str | bytes, int] - id: Optional[Union[str, bytes, int]] + id: Optional[str | bytes | int] def __init__( - self, typeid: Optional[bytes | str], address: Tuple[str | bytes, int], id: Optional[Union[str, bytes, int]] + self, typeid: Optional[bytes | str], address: Tuple[str | bytes, int], id: Optional[str | bytes | int] ) -> None: ... def __repr__(self) -> str: ... def __getstate__( self, - ) -> Tuple[Optional[str | bytes], Tuple[str | bytes, int], Optional[Union[str, bytes, int]]]: ... + ) -> Tuple[Optional[str | bytes], Tuple[str | bytes, int], Optional[str | bytes | int]]: ... def __setstate__( - self, state: Tuple[Optional[str | bytes], Tuple[str | bytes, int], Optional[Union[str, bytes, int]]] + self, state: Tuple[Optional[str | bytes], Tuple[str | bytes, int], Optional[str | bytes | int]] ) -> None: ... class BaseProxy(object): diff --git a/stdlib/pstats.pyi b/stdlib/pstats.pyi index 80ce44ddd54b..1b95af83e93e 100644 --- a/stdlib/pstats.pyi +++ b/stdlib/pstats.pyi @@ -4,7 +4,7 @@ from cProfile import Profile as _cProfile from profile import Profile from typing import IO, Any, Dict, Iterable, List, Optional, Tuple, TypeVar, Union, overload -_Selector = Union[str, float, int] +_Selector = str | float | int _T = TypeVar("_T", bound=Stats) if sys.version_info >= (3, 7): diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index 24fb80398113..d1d30f4a0170 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -222,7 +222,7 @@ class Helper: def __init__(self, input: Optional[IO[str]] = ..., output: Optional[IO[str]] = ...) -> 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: ... diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index 55aca0b506c2..787d3707f200 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -7,7 +7,7 @@ from typing import Any, Dict, Optional, Pattern, Protocol, Sequence, Tuple, Type _Reply = Tuple[int, bytes] _SendErrs = Dict[str, _Reply] # Should match source_address for socket.create_connection -_SourceAddress = Tuple[Union[bytearray, bytes, str], int] +_SourceAddress = Tuple[bytearray | bytes | str, int] SMTP_PORT: int SMTP_SSL_PORT: int diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index 67853ebd7b48..a2f54d8f4a42 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -597,7 +597,7 @@ if sys.platform == "win32": else: def socketpair( # type: ignore - family: Union[int, AddressFamily, None] = ..., type: SocketType | int = ..., proto: int = ... + family: int | AddressFamily | None = ..., type: SocketType | int = ..., proto: int = ... ) -> tuple[socket, socket]: ... class SocketIO(RawIOBase): @@ -613,7 +613,7 @@ 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]] = ..., + source_address: Optional[tuple[bytearray | bytes | str, int]] = ..., ) -> socket: ... if sys.version_info >= (3, 8): @@ -624,8 +624,8 @@ if sys.version_info >= (3, 8): # the 5th tuple item is an address def getaddrinfo( - host: Optional[Union[bytearray, bytes, str]], - port: Union[str, int, None], + host: Optional[bytearray | bytes | str], + port: str | int | None, family: int = ..., type: int = ..., proto: int = ..., 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/ssl.pyi b/stdlib/ssl.pyi index 665168bf2f1b..0ebc0460c3ab 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -7,8 +7,8 @@ from typing_extensions import Literal _PCTRTT = Tuple[Tuple[str, str], ...] _PCTRTTT = Tuple[_PCTRTT, ...] -_PeerCertRetDictType = Dict[str, Union[str, _PCTRTTT, _PCTRTT]] -_PeerCertRetType = Union[_PeerCertRetDictType, bytes, None] +_PeerCertRetDictType = Dict[str, str | _PCTRTTT | _PCTRTT] +_PeerCertRetType = _PeerCertRetDictType | bytes | None _EnumRetType = List[Tuple[bytes, str, Union[Set[str], bool]]] _PasswordType = Union[Callable[[], str | bytes], str, bytes] @@ -45,7 +45,7 @@ def wrap_socket( ciphers: Optional[str] = ..., ) -> SSLSocket: ... def create_default_context( - purpose: Any = ..., *, cafile: Optional[str] = ..., capath: Optional[str] = ..., cadata: Union[str, bytes, None] = ... + purpose: Any = ..., *, cafile: Optional[str] = ..., capath: Optional[str] = ..., cadata: str | bytes | None = ... ) -> SSLContext: ... if sys.version_info >= (3, 7): @@ -59,7 +59,7 @@ if sys.version_info >= (3, 7): keyfile: Optional[str] = ..., cafile: Optional[str] = ..., capath: Optional[str] = ..., - cadata: Union[str, bytes, None] = ..., + cadata: str | bytes | None = ..., ) -> SSLContext: ... else: @@ -73,7 +73,7 @@ else: keyfile: Optional[str] = ..., cafile: Optional[str] = ..., capath: Optional[str] = ..., - cadata: Union[str, bytes, None] = ..., + cadata: str | bytes | None = ..., ) -> SSLContext: ... _create_default_https_context: Callable[..., SSLContext] @@ -308,7 +308,7 @@ class SSLContext: ) -> 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: Optional[StrPath] = ..., capath: Optional[StrPath] = ..., cadata: str | bytes | None = ... ) -> None: ... def get_ca_certs(self, binary_form: bool = ...) -> Union[List[_PeerCertRetDictType], List[bytes]]: ... def set_default_verify_paths(self) -> None: ... diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index a74a5b5d09f5..89eee73fc572 100644 --- a/stdlib/statistics.pyi +++ b/stdlib/statistics.pyi @@ -6,7 +6,7 @@ from typing import Any, Hashable, Iterable, List, NamedTuple, Optional, Sequence _T = TypeVar("_T") # Most functions in this module accept homogeneous collections of one of these types -_Number = Union[float, Decimal, Fraction] +_Number = float | Decimal | Fraction _NumberT = TypeVar("_NumberT", float, Decimal, Fraction) # Used in mode, multimode diff --git a/stdlib/threading.pyi b/stdlib/threading.pyi index de75375056e0..5d59eecc64e0 100644 --- a/stdlib/threading.pyi +++ b/stdlib/threading.pyi @@ -85,7 +85,7 @@ class _RLock: 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] diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 586d858535a3..8c1a278dc609 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -381,7 +381,7 @@ class Misc: 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 = ... ) -> str: ... diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index 1ce130a752ed..a5ecc304de7c 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -41,7 +41,7 @@ class TokenInfo(_TokenInfo): def exact_type(self) -> int: ... # Backwards compatible tokens can be sequences of a shorter length too -_Token = Union[TokenInfo, Sequence[Union[int, str, _Position]]] +_Token = Union[TokenInfo, Sequence[int | str | _Position]] class TokenError(Exception): ... class StopTokenizing(Exception): ... # undocumented diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index d3d9358a2d8a..74aa12a60f18 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -40,7 +40,7 @@ class Terminator(Exception): ... class TurtleGraphicsError(Exception): ... class Shape(object): - def __init__(self, type_: str, data: Union[_PolygonCoords, PhotoImage, None] = ...) -> None: ... + def __init__(self, type_: str, data: _PolygonCoords | PhotoImage | None = ...) -> None: ... def addcomponent(self, poly: _PolygonCoords, fill: _Color, outline: Optional[_Color] = ...) -> None: ... class TurtleScreen(TurtleScreenBase): @@ -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 @@ -212,7 +212,7 @@ _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: ... @@ -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 diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index c685e84234ce..d7ef04c27314 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -138,7 +138,7 @@ class TestCase: msg: Any = ..., ) -> _AssertWarnsContext: ... def assertLogs( - self, logger: Optional[str | logging.Logger] = ..., level: Union[int, str, None] = ... + self, logger: Optional[str | logging.Logger] = ..., level: int | str | None = ... ) -> _AssertLogsContext: ... @overload def assertAlmostEqual( diff --git a/stdlib/unittest/main.pyi b/stdlib/unittest/main.pyi index 637b90e3d9f6..b65319640928 100644 --- a/stdlib/unittest/main.pyi +++ b/stdlib/unittest/main.pyi @@ -12,7 +12,7 @@ class _TestRunner(Protocol): # 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] @@ -24,7 +24,7 @@ class TestProgram: testNamePatterns: Optional[List[str]] def __init__( self, - module: Union[None, str, ModuleType] = ..., + module: None | str | ModuleType = ..., defaultTest: Union[str, Iterable[str], None] = ..., argv: Optional[List[str]] = ..., testRunner: Union[Type[_TestRunner], _TestRunner, None] = ..., diff --git a/stdlib/xml/etree/ElementInclude.pyi b/stdlib/xml/etree/ElementInclude.pyi index 36bd76379a99..0ff95a9aad8b 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] = ...) -> str | Element: ... +def default_loader(href: str | bytes | int, parse: str, encoding: Optional[str] = ...) -> 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 diff --git a/stdlib/zipapp.pyi b/stdlib/zipapp.pyi index e1b38e9711b6..40fad41dcd83 100644 --- a/stdlib/zipapp.pyi +++ b/stdlib/zipapp.pyi @@ -2,7 +2,7 @@ import sys from pathlib import Path from typing import BinaryIO, Callable, Optional, Union -_Path = Union[str, Path, BinaryIO] +_Path = str | Path | BinaryIO class ZipAppError(ValueError): ... From 882274b8153dd6bea7ca07e82c791af4f78faa0e Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:41:51 -0700 Subject: [PATCH 03/16] fastmod -d stdlib --accept-all '\bUnion\[([\w\.]+), ([\w\.]+), ([\w\.]+), ([\w\.]+)\]' '$1 | $2 | $3 | $4' --- stdlib/@python2/fractions.pyi | 2 +- stdlib/@python2/sqlite3/dbapi2.pyi | 2 +- stdlib/builtins.pyi | 4 ++-- stdlib/fractions.pyi | 2 +- stdlib/logging/__init__.pyi | 2 +- stdlib/pathlib.pyi | 2 +- stdlib/pstats.pyi | 6 +++--- stdlib/sqlite3/dbapi2.pyi | 2 +- stdlib/tkinter/__init__.pyi | 2 +- stdlib/xmlrpc/client.pyi | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/stdlib/@python2/fractions.pyi b/stdlib/@python2/fractions.pyi index 3687c2761bc2..48d53fc917a2 100644 --- a/stdlib/@python2/fractions.pyi +++ b/stdlib/@python2/fractions.pyi @@ -3,7 +3,7 @@ from numbers import Integral, Rational, Real from typing import Optional, Tuple, Type, TypeVar, Union, overload from typing_extensions import Literal -_ComparableNum = Union[int, float, Decimal, Real] +_ComparableNum = int | float | Decimal | Real _T = TypeVar("_T") @overload diff --git a/stdlib/@python2/sqlite3/dbapi2.pyi b/stdlib/@python2/sqlite3/dbapi2.pyi index 13c2cdf0a7df..46073e601e27 100644 --- a/stdlib/@python2/sqlite3/dbapi2.pyi +++ b/stdlib/@python2/sqlite3/dbapi2.pyi @@ -72,7 +72,7 @@ def connect( ) -> 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: ... class Cache(object): diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index ea9ab7704a46..b6a0108da16f 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -974,7 +974,7 @@ if sys.version_info >= (3, 10): if sys.version_info >= (3, 8): def compile( - source: Union[str, bytes, mod, AST], + source: str | bytes | mod | AST, filename: Union[str, bytes, _PathLike[Any]], mode: str, flags: int = ..., @@ -986,7 +986,7 @@ if sys.version_info >= (3, 8): else: def compile( - source: Union[str, bytes, mod, AST], + source: str | bytes | mod | AST, filename: Union[str, bytes, _PathLike[Any]], mode: str, flags: int = ..., diff --git a/stdlib/fractions.pyi b/stdlib/fractions.pyi index aca5f5e890a2..9218126bf319 100644 --- a/stdlib/fractions.pyi +++ b/stdlib/fractions.pyi @@ -4,7 +4,7 @@ from numbers import Integral, Rational, Real from typing import Optional, Tuple, Type, TypeVar, Union, overload from typing_extensions import Literal -_ComparableNum = Union[int, float, Decimal, Real] +_ComparableNum = int | float | Decimal | Real _T = TypeVar("_T") if sys.version_info < (3, 9): diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index b9cc629d847d..18d7cbfed24e 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -8,7 +8,7 @@ from types import FrameType, TracebackType from typing import IO, Any, ClassVar, Optional, Pattern, Tuple, Type, Union _SysExcInfoType = Union[Tuple[Type[BaseException], BaseException, Optional[TracebackType]], Tuple[None, None, None]] -_ExcInfoType = Union[None, bool, _SysExcInfoType, BaseException] +_ExcInfoType = None | bool | _SysExcInfoType | BaseException _ArgsType = Union[Tuple[Any, ...], Mapping[str, Any]] _FilterType = Union[Filter, Callable[[LogRecord], int]] _Level = int | str diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index 0027f28a0f8b..160ac89242d0 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -161,7 +161,7 @@ class Path(PurePath): 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 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: ... if sys.version_info >= (3, 8): diff --git a/stdlib/pstats.pyi b/stdlib/pstats.pyi index 1b95af83e93e..42c2b1d4f8e5 100644 --- a/stdlib/pstats.pyi +++ b/stdlib/pstats.pyi @@ -24,12 +24,12 @@ class Stats: sort_arg_dict_default: Dict[str, Tuple[Any, str]] def __init__( self: _T, - __arg: Union[None, str, Profile, _cProfile] = ..., + __arg: None | str | Profile | _cProfile = ..., *args: Union[None, str, Profile, _cProfile, _T], stream: Optional[IO[Any]] = ..., ) -> 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 dump_stats(self, filename: StrOrBytesPath) -> None: ... diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index 01fb2fa80695..4687497d11a9 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -90,7 +90,7 @@ else: 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): diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 8c1a278dc609..049c83116e78 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -2461,7 +2461,7 @@ class Scrollbar(Widget): def get(self): ... def set(self, first, last): ... -_TextIndex = Union[_tkinter.Tcl_Obj, str, float, Misc] +_TextIndex = _tkinter.Tcl_Obj | str | float | Misc class Text(Widget, XView, YView): def __init__( diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index 20d5ccc8a384..ae4a934c39ea 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -12,7 +12,7 @@ from typing_extensions import Literal class _SupportsTimeTuple(Protocol): def timetuple(self) -> time.struct_time: ... -_DateTimeComparable = Union[DateTime, datetime, str, _SupportsTimeTuple] +_DateTimeComparable = DateTime | datetime | str | _SupportsTimeTuple _Marshallable = Union[None, bool, int, float, str, bytes, Tuple[Any, ...], List[Any], Dict[Any, Any], datetime, DateTime, Binary] _XMLDate = Union[int, datetime, Tuple[int, ...], time.struct_time] _HostType = Union[Tuple[str, Dict[str, str]], str] From ad937c8d578e35acf513049af2657497dafe3134 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:41:52 -0700 Subject: [PATCH 04/16] fastmod -d stdlib --accept-all '\bUnion\[([\w\.]+)(\[[^\[\]]+\])?, ([\w\.]+)(\[[^\[\]]+\])?\]' '$1$2 | $3$4' --- stdlib/@python2/ConfigParser.pyi | 2 +- stdlib/@python2/SocketServer.pyi | 4 +- stdlib/@python2/UserString.pyi | 4 +- stdlib/@python2/__builtin__.pyi | 30 ++++---- stdlib/@python2/_codecs.pyi | 2 +- stdlib/@python2/_sre.pyi | 4 +- stdlib/@python2/aifc.pyi | 2 +- stdlib/@python2/argparse.pyi | 14 ++-- stdlib/@python2/array.pyi | 8 +- stdlib/@python2/asyncore.pyi | 6 +- stdlib/@python2/bdb.pyi | 2 +- stdlib/@python2/binhex.pyi | 2 +- stdlib/@python2/builtins.pyi | 30 ++++---- stdlib/@python2/bz2.pyi | 2 +- stdlib/@python2/calendar.pyi | 2 +- stdlib/@python2/copy_reg.pyi | 2 +- stdlib/@python2/copyreg.pyi | 2 +- stdlib/@python2/distutils/ccompiler.pyi | 2 +- stdlib/@python2/distutils/cmd.pyi | 2 +- stdlib/@python2/distutils/command/config.pyi | 2 +- stdlib/@python2/distutils/core.pyi | 4 +- stdlib/@python2/distutils/fancy_getopt.pyi | 2 +- stdlib/@python2/genericpath.pyi | 4 +- stdlib/@python2/gettext.pyi | 2 +- stdlib/@python2/imaplib.pyi | 6 +- stdlib/@python2/inspect.pyi | 2 +- stdlib/@python2/json.pyi | 2 +- stdlib/@python2/lib2to3/pytree.pyi | 2 +- stdlib/@python2/logging/__init__.pyi | 2 +- stdlib/@python2/logging/config.pyi | 2 +- stdlib/@python2/logging/handlers.pyi | 4 +- stdlib/@python2/mailbox.pyi | 2 +- stdlib/@python2/msilib/__init__.pyi | 4 +- stdlib/@python2/nntplib.pyi | 4 +- stdlib/@python2/pdb.pyi | 2 +- stdlib/@python2/pickletools.pyi | 6 +- stdlib/@python2/plistlib.pyi | 4 +- stdlib/@python2/pty.pyi | 2 +- stdlib/@python2/pydoc.pyi | 4 +- stdlib/@python2/re.pyi | 20 ++--- stdlib/@python2/sets.pyi | 2 +- stdlib/@python2/shlex.pyi | 2 +- stdlib/@python2/shutil.pyi | 2 +- stdlib/@python2/socket.pyi | 6 +- stdlib/@python2/ssl.pyi | 4 +- stdlib/@python2/string.pyi | 8 +- stdlib/@python2/subprocess.pyi | 4 +- stdlib/@python2/sunau.pyi | 2 +- stdlib/@python2/sys.pyi | 2 +- stdlib/@python2/telnetlib.pyi | 2 +- stdlib/@python2/termios.pyi | 2 +- stdlib/@python2/tty.pyi | 2 +- stdlib/@python2/turtle.pyi | 14 ++-- stdlib/@python2/unittest.pyi | 8 +- stdlib/@python2/urllib2.pyi | 8 +- stdlib/@python2/wave.pyi | 2 +- stdlib/@python2/webbrowser.pyi | 2 +- stdlib/@python2/xml/dom/minidom.pyi | 2 +- stdlib/@python2/xml/etree/ElementTree.pyi | 2 +- stdlib/@python2/xmlrpclib.pyi | 2 +- stdlib/@python2/zipfile.pyi | 4 +- stdlib/@python2/zlib.pyi | 2 +- stdlib/_codecs.pyi | 2 +- stdlib/_socket.pyi | 4 +- stdlib/_typeshed/__init__.pyi | 4 +- stdlib/_winapi.pyi | 2 +- stdlib/aifc.pyi | 2 +- stdlib/argparse.pyi | 18 ++--- stdlib/array.pyi | 8 +- stdlib/asyncio/base_events.pyi | 12 +-- stdlib/asyncio/base_subprocess.pyi | 2 +- stdlib/asyncio/events.pyi | 12 +-- stdlib/asyncio/futures.pyi | 2 +- stdlib/asyncio/tasks.pyi | 10 +-- stdlib/asyncio/trsock.pyi | 2 +- stdlib/asyncore.pyi | 4 +- stdlib/bdb.pyi | 2 +- stdlib/binhex.pyi | 2 +- stdlib/builtins.pyi | 30 ++++---- stdlib/calendar.pyi | 2 +- stdlib/collections/__init__.pyi | 8 +- stdlib/configparser.pyi | 2 +- stdlib/copyreg.pyi | 2 +- stdlib/distutils/ccompiler.pyi | 2 +- stdlib/distutils/cmd.pyi | 2 +- stdlib/distutils/command/config.pyi | 2 +- stdlib/distutils/core.pyi | 4 +- stdlib/distutils/dist.pyi | 12 +-- stdlib/distutils/fancy_getopt.pyi | 2 +- stdlib/distutils/filelist.pyi | 12 +-- stdlib/email/message.pyi | 4 +- stdlib/enum.pyi | 2 +- stdlib/filecmp.pyi | 8 +- stdlib/functools.pyi | 2 +- stdlib/genericpath.pyi | 4 +- stdlib/http/cookies.pyi | 4 +- stdlib/imaplib.pyi | 6 +- stdlib/importlib/resources.pyi | 2 +- stdlib/io.pyi | 2 +- stdlib/lib2to3/pytree.pyi | 2 +- stdlib/logging/__init__.pyi | 2 +- stdlib/logging/handlers.pyi | 16 ++-- stdlib/lzma.pyi | 2 +- stdlib/mailbox.pyi | 2 +- stdlib/msilib/__init__.pyi | 4 +- stdlib/multiprocessing/connection.pyi | 2 +- stdlib/multiprocessing/context.pyi | 22 +++--- stdlib/multiprocessing/dummy/connection.pyi | 2 +- stdlib/multiprocessing/sharedctypes.pyi | 24 +++--- stdlib/nntplib.pyi | 4 +- stdlib/os/__init__.pyi | 16 ++-- stdlib/pdb.pyi | 2 +- stdlib/pickletools.pyi | 6 +- stdlib/plistlib.pyi | 4 +- stdlib/pty.pyi | 2 +- stdlib/pydoc.pyi | 4 +- stdlib/random.pyi | 8 +- stdlib/re.pyi | 2 +- stdlib/shutil.pyi | 2 +- stdlib/smtplib.pyi | 6 +- stdlib/socket.pyi | 4 +- stdlib/socketserver.pyi | 4 +- stdlib/ssl.pyi | 4 +- stdlib/subprocess.pyi | 6 +- stdlib/sunau.pyi | 2 +- stdlib/sys.pyi | 2 +- stdlib/tarfile.pyi | 2 +- stdlib/telnetlib.pyi | 2 +- stdlib/tempfile.pyi | 2 +- stdlib/termios.pyi | 2 +- stdlib/tkinter/__init__.pyi | 80 ++++++++++---------- stdlib/tkinter/ttk.pyi | 34 ++++----- stdlib/tokenize.pyi | 2 +- stdlib/tty.pyi | 2 +- stdlib/turtle.pyi | 14 ++-- stdlib/typing.pyi | 8 +- stdlib/unittest/case.pyi | 16 ++-- stdlib/urllib/request.pyi | 10 +-- stdlib/wave.pyi | 2 +- stdlib/webbrowser.pyi | 2 +- stdlib/xml/dom/minidom.pyi | 2 +- stdlib/xml/etree/ElementTree.pyi | 2 +- stdlib/xmlrpc/client.pyi | 4 +- stdlib/xmlrpc/server.pyi | 4 +- stdlib/zipfile.pyi | 10 +-- stdlib/zlib.pyi | 2 +- 146 files changed, 424 insertions(+), 424 deletions(-) diff --git a/stdlib/@python2/ConfigParser.pyi b/stdlib/@python2/ConfigParser.pyi index 05c90ed2c248..538c5408766a 100644 --- a/stdlib/@python2/ConfigParser.pyi +++ b/stdlib/@python2/ConfigParser.pyi @@ -65,7 +65,7 @@ class RawConfigParser: def add_section(self, section: str) -> None: ... def has_section(self, section: str) -> bool: ... def options(self, section: str) -> List[str]: ... - def read(self, filenames: Union[str, Sequence[str]]) -> List[str]: ... + def read(self, filenames: str | Sequence[str]) -> List[str]: ... def readfp(self, fp: SupportsNoArgReadline[str], filename: str = ...) -> None: ... def get(self, section: str, option: str) -> str: ... def items(self, section: str) -> List[Tuple[Any, Any]]: ... diff --git a/stdlib/@python2/SocketServer.pyi b/stdlib/@python2/SocketServer.pyi index 05805ed29be9..5ae17c74edf2 100644 --- a/stdlib/@python2/SocketServer.pyi +++ b/stdlib/@python2/SocketServer.pyi @@ -85,8 +85,8 @@ if sys.platform != "win32": class BaseRequestHandler: # Those are technically of types, respectively: - # * Union[SocketType, Tuple[bytes, SocketType]] - # * Union[Tuple[str, int], str] + # * SocketType | Tuple[bytes, SocketType] + # * Tuple[str, int] | str # But there are some concerns that having unions here would cause # too much inconvenience to people using it (see # https://github.com/python/typeshed/pull/384#issuecomment-234649696) diff --git a/stdlib/@python2/UserString.pyi b/stdlib/@python2/UserString.pyi index 66c725e2edb7..2e383fe1ddb5 100644 --- a/stdlib/@python2/UserString.pyi +++ b/stdlib/@python2/UserString.pyi @@ -26,7 +26,7 @@ class UserString(Sequence[UserString]): def count(self, sub: int, start: int = ..., end: int = ...) -> int: ... def decode(self: _UST, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UST: ... def encode(self: _UST, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UST: ... - def endswith(self, suffix: Union[Text, Tuple[Text, ...]], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ... + def endswith(self, suffix: Text | Tuple[Text, ...], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ... def expandtabs(self: _UST, tabsize: int = ...) -> _UST: ... def find(self, sub: Text, start: int = ..., end: int = ...) -> int: ... def index(self, sub: Text, start: int = ..., end: int = ...) -> int: ... @@ -53,7 +53,7 @@ class UserString(Sequence[UserString]): def split(self, sep: Optional[Text] = ..., maxsplit: int = ...) -> List[Text]: ... def rsplit(self, sep: Optional[Text] = ..., maxsplit: int = ...) -> List[Text]: ... def splitlines(self, keepends: int = ...) -> List[Text]: ... - def startswith(self, prefix: Union[Text, Tuple[Text, ...]], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ... + def startswith(self, prefix: Text | Tuple[Text, ...], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ... def strip(self: _UST, chars: Optional[Text] = ...) -> _UST: ... def swapcase(self: _UST) -> _UST: ... def title(self: _UST) -> _UST: ... diff --git a/stdlib/@python2/__builtin__.pyi b/stdlib/@python2/__builtin__.pyi index ff5e5ca57c86..05e7af3f542f 100644 --- a/stdlib/@python2/__builtin__.pyi +++ b/stdlib/@python2/__builtin__.pyi @@ -68,7 +68,7 @@ _TBE = TypeVar("_TBE", bound="BaseException") class object: __doc__: Optional[str] __dict__: Dict[str, Any] - __slots__: Union[Text, Iterable[Text]] + __slots__: Text | Iterable[Text] __module__: str @property def __class__(self: _T) -> Type[_T]: ... @@ -86,8 +86,8 @@ 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_ex__(self, protocol: int) -> Union[str, Tuple[Any, ...]]: ... + def __reduce__(self) -> str | Tuple[Any, ...]: ... + def __reduce_ex__(self, protocol: int) -> str | Tuple[Any, ...]: ... class staticmethod(object): # Special, only valid as a decorator. __func__: Callable[..., Any] @@ -296,7 +296,7 @@ class unicode(basestring, Sequence[unicode]): def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ... def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... def endswith( - self, __suffix: Union[unicode, Tuple[unicode, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __suffix: unicode | Tuple[unicode, ...], __start: Optional[int] = ..., __end: Optional[int] = ... ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> unicode: ... def find(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... @@ -328,12 +328,12 @@ class unicode(basestring, Sequence[unicode]): def split(self, sep: Optional[unicode] = ..., maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[unicode]: ... def startswith( - self, __prefix: Union[unicode, Tuple[unicode, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __prefix: unicode | Tuple[unicode, ...], __start: Optional[int] = ..., __end: Optional[int] = ... ) -> bool: ... def strip(self, chars: unicode = ...) -> unicode: ... def swapcase(self) -> unicode: ... def title(self) -> unicode: ... - def translate(self, table: Union[Dict[int, Any], unicode]) -> unicode: ... + def translate(self, table: Dict[int, Any] | unicode) -> unicode: ... def upper(self) -> unicode: ... def zfill(self, width: int) -> unicode: ... @overload @@ -373,7 +373,7 @@ class str(Sequence[str], basestring): def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... def encode(self, encoding: Text = ..., errors: Text = ...) -> bytes: ... def endswith( - self, __suffix: Union[Text, Tuple[Text, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __suffix: Text | Tuple[Text, ...], __start: Optional[int] = ..., __end: Optional[int] = ... ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> str: ... def find(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... @@ -424,7 +424,7 @@ class str(Sequence[str], basestring): def split(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[str]: ... def startswith( - self, __prefix: Union[Text, Tuple[Text, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __prefix: Text | Tuple[Text, ...], __start: Optional[int] = ..., __end: Optional[int] = ... ) -> bool: ... @overload def strip(self, __chars: str = ...) -> str: ... @@ -476,10 +476,10 @@ class bytearray(MutableSequence[int], ByteString): def count(self, __sub: str) -> int: ... def decode(self, encoding: Text = ..., errors: Text = ...) -> str: ... def endswith( - self, __suffix: Union[bytes, Tuple[bytes, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __suffix: bytes | Tuple[bytes, ...], __start: Optional[int] = ..., __end: Optional[int] = ... ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> bytearray: ... - def extend(self, iterable: Union[str, Iterable[int]]) -> None: ... + def extend(self, iterable: str | Iterable[int]) -> None: ... def find(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ... def index(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ... def insert(self, __index: int, __item: int) -> None: ... @@ -505,7 +505,7 @@ class bytearray(MutableSequence[int], ByteString): def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... def startswith( - self, __prefix: Union[bytes, Tuple[bytes, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __prefix: bytes | Tuple[bytes, ...], __start: Optional[int] = ..., __end: Optional[int] = ... ) -> bool: ... def strip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... def swapcase(self) -> bytearray: ... @@ -529,10 +529,10 @@ class bytearray(MutableSequence[int], ByteString): @overload def __setitem__(self, i: int, x: int) -> None: ... @overload - def __setitem__(self, s: slice, x: Union[Iterable[int], bytes]) -> None: ... + def __setitem__(self, s: slice, x: Iterable[int] | bytes) -> None: ... def __delitem__(self, i: int | slice) -> None: ... def __getslice__(self, start: int, stop: int) -> bytearray: ... - def __setslice__(self, start: int, stop: int, x: Union[Sequence[int], str]) -> None: ... + def __setslice__(self, start: int, stop: int, x: Sequence[int] | str) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... def __add__(self, s: bytes) -> bytearray: ... def __mul__(self, n: int) -> bytearray: ... @@ -885,8 +885,8 @@ def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ... def iter(__function: Callable[[], Optional[_T]], __sentinel: None) -> Iterator[_T]: ... @overload def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ... -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: Union[type, Tuple[type | Tuple[Any, ...], ...]]) -> bool: ... +def issubclass(__cls: type, __class_or_tuple: Union[type, Tuple[type | Tuple[Any, ...], ...]]) -> bool: ... def len(__obj: Sized) -> int: ... def locals() -> Dict[str, Any]: ... @overload diff --git a/stdlib/@python2/_codecs.pyi b/stdlib/@python2/_codecs.pyi index 3dd4479ad333..5361aea802b6 100644 --- a/stdlib/@python2/_codecs.pyi +++ b/stdlib/@python2/_codecs.pyi @@ -13,7 +13,7 @@ _Encodable = bytes | Text class _EncodingMap(object): def size(self) -> int: ... -_MapT = Union[Dict[int, int], _EncodingMap] +_MapT = Dict[int, int] | _EncodingMap def register(__search_function: Callable[[str], Any]) -> None: ... def register_error(__errors: str | Text, __handler: _Handler) -> None: ... diff --git a/stdlib/@python2/_sre.pyi b/stdlib/@python2/_sre.pyi index 263f1da05632..b13e972cb2c9 100644 --- a/stdlib/@python2/_sre.pyi +++ b/stdlib/@python2/_sre.pyi @@ -30,8 +30,8 @@ class SRE_Pattern(object): groups: int groupindex: Mapping[str, int] indexgroup: Sequence[int] - def findall(self, source: str, pos: int = ..., endpos: int = ...) -> List[Union[Tuple[Any, ...], str]]: ... - def finditer(self, source: str, pos: int = ..., endpos: int = ...) -> Iterable[Union[Tuple[Any, ...], str]]: ... + def findall(self, source: str, pos: int = ..., endpos: int = ...) -> List[Tuple[Any, ...] | str]: ... + def finditer(self, source: str, pos: int = ..., endpos: int = ...) -> Iterable[Tuple[Any, ...] | str]: ... def match(self, pattern, pos: int = ..., endpos: int = ...) -> SRE_Match: ... def scanner(self, s: str, start: int = ..., end: int = ...) -> SRE_Scanner: ... def search(self, pattern, pos: int = ..., endpos: int = ...) -> SRE_Match: ... diff --git a/stdlib/@python2/aifc.pyi b/stdlib/@python2/aifc.pyi index 4349b11c1f1c..2021d3f2c8be 100644 --- a/stdlib/@python2/aifc.pyi +++ b/stdlib/@python2/aifc.pyi @@ -11,7 +11,7 @@ class _aifc_params(NamedTuple): comptype: bytes compname: bytes -_File = Union[Text, IO[bytes]] +_File = Text | IO[bytes] _Marker = Tuple[int, int, bytes] class Aifc_read: diff --git a/stdlib/@python2/argparse.pyi b/stdlib/@python2/argparse.pyi index 28241cd7174e..c3ebc49e8120 100644 --- a/stdlib/@python2/argparse.pyi +++ b/stdlib/@python2/argparse.pyi @@ -68,7 +68,7 @@ class _ActionsContainer: def add_argument( self, *name_or_flags: Text, - action: Union[Text, Type[Action]] = ..., + action: Text | Type[Action] = ..., nargs: int | Text = ..., const: Any = ..., default: Any = ..., @@ -76,7 +76,7 @@ class _ActionsContainer: choices: Iterable[_T] = ..., required: bool = ..., help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., + metavar: Optional[Text | Tuple[Text, ...]] = ..., dest: Optional[Text] = ..., version: Text = ..., **kwargs: Any, @@ -235,7 +235,7 @@ class Action(_AttributeHolder): choices: Optional[Iterable[Any]] required: bool help: Optional[_Text] - metavar: Optional[Union[_Text, Tuple[_Text, ...]]] + metavar: Optional[_Text | Tuple[_Text, ...]] def __init__( self, option_strings: Sequence[Text], @@ -247,7 +247,7 @@ class Action(_AttributeHolder): choices: Optional[Iterable[_T]] = ..., required: bool = ..., help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., + metavar: Optional[Text | Tuple[Text, ...]] = ..., ) -> None: ... def __call__( self, @@ -297,7 +297,7 @@ class _StoreConstAction(Action): default: Any = ..., required: bool = ..., help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., + metavar: Optional[Text | Tuple[Text, ...]] = ..., ) -> None: ... # undocumented @@ -325,7 +325,7 @@ class _AppendConstAction(Action): default: Any = ..., required: bool = ..., help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., + metavar: Optional[Text | Tuple[Text, ...]] = ..., ) -> None: ... # undocumented @@ -367,7 +367,7 @@ class _SubParsersAction(Action): parser_class: Type[ArgumentParser], dest: Text = ..., help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., + metavar: Optional[Text | Tuple[Text, ...]] = ..., ) -> None: ... # TODO: Type keyword args properly. def add_parser(self, name: Text, **kwargs: Any) -> ArgumentParser: ... diff --git a/stdlib/@python2/array.pyi b/stdlib/@python2/array.pyi index 964d992c95e5..727abf04d3ef 100644 --- a/stdlib/@python2/array.pyi +++ b/stdlib/@python2/array.pyi @@ -12,13 +12,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[Text], typecode: _UnicodeTypeCode, __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... + def __init__(self: array[Text], 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: ... diff --git a/stdlib/@python2/asyncore.pyi b/stdlib/@python2/asyncore.pyi index 9c1d6e8e6aa4..f8d365e58c52 100644 --- a/stdlib/@python2/asyncore.pyi +++ b/stdlib/@python2/asyncore.pyi @@ -40,8 +40,8 @@ class dispatcher: 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 bind(self, addr: Tuple[Any, ...] | str) -> None: ... + def connect(self, address: Tuple[Any, ...] | str) -> None: ... def accept(self) -> Optional[Tuple[SocketType, Any]]: ... def send(self, data: bytes) -> int: ... def recv(self, buffer_size: int) -> bytes: ... @@ -83,7 +83,7 @@ class dispatcher: def recvfrom_into(self, buffer: bytes, nbytes: int, flags: int = ...) -> Any: ... def recv_into(self, buffer: bytes, nbytes: int, flags: int = ...) -> Any: ... def sendall(self, data: bytes, flags: int = ...) -> None: ... - def sendto(self, data: bytes, address: Union[Tuple[str, int], str], flags: int = ...) -> int: ... + def sendto(self, data: bytes, address: Tuple[str, int] | str, flags: int = ...) -> int: ... def setblocking(self, flag: bool) -> None: ... def settimeout(self, value: float | None) -> None: ... def setsockopt(self, level: int, optname: int, value: int | bytes) -> None: ... diff --git a/stdlib/@python2/bdb.pyi b/stdlib/@python2/bdb.pyi index 7a586b0666fd..32452fc224e6 100644 --- a/stdlib/@python2/bdb.pyi +++ b/stdlib/@python2/bdb.pyi @@ -94,5 +94,5 @@ class Breakpoint: 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/@python2/binhex.pyi b/stdlib/@python2/binhex.pyi index 02d094faf923..a8280b819539 100644 --- a/stdlib/@python2/binhex.pyi +++ b/stdlib/@python2/binhex.pyi @@ -13,7 +13,7 @@ class FInfo: Flags: int _FileInfoTuple = Tuple[str, FInfo, int, int] -_FileHandleUnion = Union[str, IO[bytes]] +_FileHandleUnion = str | IO[bytes] def getfileinfo(name: str) -> _FileInfoTuple: ... diff --git a/stdlib/@python2/builtins.pyi b/stdlib/@python2/builtins.pyi index ff5e5ca57c86..05e7af3f542f 100644 --- a/stdlib/@python2/builtins.pyi +++ b/stdlib/@python2/builtins.pyi @@ -68,7 +68,7 @@ _TBE = TypeVar("_TBE", bound="BaseException") class object: __doc__: Optional[str] __dict__: Dict[str, Any] - __slots__: Union[Text, Iterable[Text]] + __slots__: Text | Iterable[Text] __module__: str @property def __class__(self: _T) -> Type[_T]: ... @@ -86,8 +86,8 @@ 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_ex__(self, protocol: int) -> Union[str, Tuple[Any, ...]]: ... + def __reduce__(self) -> str | Tuple[Any, ...]: ... + def __reduce_ex__(self, protocol: int) -> str | Tuple[Any, ...]: ... class staticmethod(object): # Special, only valid as a decorator. __func__: Callable[..., Any] @@ -296,7 +296,7 @@ class unicode(basestring, Sequence[unicode]): def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ... def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... def endswith( - self, __suffix: Union[unicode, Tuple[unicode, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __suffix: unicode | Tuple[unicode, ...], __start: Optional[int] = ..., __end: Optional[int] = ... ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> unicode: ... def find(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... @@ -328,12 +328,12 @@ class unicode(basestring, Sequence[unicode]): def split(self, sep: Optional[unicode] = ..., maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[unicode]: ... def startswith( - self, __prefix: Union[unicode, Tuple[unicode, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __prefix: unicode | Tuple[unicode, ...], __start: Optional[int] = ..., __end: Optional[int] = ... ) -> bool: ... def strip(self, chars: unicode = ...) -> unicode: ... def swapcase(self) -> unicode: ... def title(self) -> unicode: ... - def translate(self, table: Union[Dict[int, Any], unicode]) -> unicode: ... + def translate(self, table: Dict[int, Any] | unicode) -> unicode: ... def upper(self) -> unicode: ... def zfill(self, width: int) -> unicode: ... @overload @@ -373,7 +373,7 @@ class str(Sequence[str], basestring): def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... def encode(self, encoding: Text = ..., errors: Text = ...) -> bytes: ... def endswith( - self, __suffix: Union[Text, Tuple[Text, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __suffix: Text | Tuple[Text, ...], __start: Optional[int] = ..., __end: Optional[int] = ... ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> str: ... def find(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... @@ -424,7 +424,7 @@ class str(Sequence[str], basestring): def split(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[str]: ... def startswith( - self, __prefix: Union[Text, Tuple[Text, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __prefix: Text | Tuple[Text, ...], __start: Optional[int] = ..., __end: Optional[int] = ... ) -> bool: ... @overload def strip(self, __chars: str = ...) -> str: ... @@ -476,10 +476,10 @@ class bytearray(MutableSequence[int], ByteString): def count(self, __sub: str) -> int: ... def decode(self, encoding: Text = ..., errors: Text = ...) -> str: ... def endswith( - self, __suffix: Union[bytes, Tuple[bytes, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __suffix: bytes | Tuple[bytes, ...], __start: Optional[int] = ..., __end: Optional[int] = ... ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> bytearray: ... - def extend(self, iterable: Union[str, Iterable[int]]) -> None: ... + def extend(self, iterable: str | Iterable[int]) -> None: ... def find(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ... def index(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ... def insert(self, __index: int, __item: int) -> None: ... @@ -505,7 +505,7 @@ class bytearray(MutableSequence[int], ByteString): def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... def startswith( - self, __prefix: Union[bytes, Tuple[bytes, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __prefix: bytes | Tuple[bytes, ...], __start: Optional[int] = ..., __end: Optional[int] = ... ) -> bool: ... def strip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... def swapcase(self) -> bytearray: ... @@ -529,10 +529,10 @@ class bytearray(MutableSequence[int], ByteString): @overload def __setitem__(self, i: int, x: int) -> None: ... @overload - def __setitem__(self, s: slice, x: Union[Iterable[int], bytes]) -> None: ... + def __setitem__(self, s: slice, x: Iterable[int] | bytes) -> None: ... def __delitem__(self, i: int | slice) -> None: ... def __getslice__(self, start: int, stop: int) -> bytearray: ... - def __setslice__(self, start: int, stop: int, x: Union[Sequence[int], str]) -> None: ... + def __setslice__(self, start: int, stop: int, x: Sequence[int] | str) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... def __add__(self, s: bytes) -> bytearray: ... def __mul__(self, n: int) -> bytearray: ... @@ -885,8 +885,8 @@ def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ... def iter(__function: Callable[[], Optional[_T]], __sentinel: None) -> Iterator[_T]: ... @overload def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ... -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: Union[type, Tuple[type | Tuple[Any, ...], ...]]) -> bool: ... +def issubclass(__cls: type, __class_or_tuple: Union[type, Tuple[type | Tuple[Any, ...], ...]]) -> bool: ... def len(__obj: Sized) -> int: ... def locals() -> Dict[str, Any]: ... @overload diff --git a/stdlib/@python2/bz2.pyi b/stdlib/@python2/bz2.pyi index d3c0baded59a..2f58da93d610 100644 --- a/stdlib/@python2/bz2.pyi +++ b/stdlib/@python2/bz2.pyi @@ -3,7 +3,7 @@ from _typeshed import ReadableBuffer, WriteableBuffer from typing import IO, Any, Iterable, List, Optional, Text, TypeVar, Union from typing_extensions import SupportsIndex -_PathOrFile = Union[Text, IO[bytes]] +_PathOrFile = Text | IO[bytes] _T = TypeVar("_T") def compress(data: bytes, compresslevel: int = ...) -> bytes: ... diff --git a/stdlib/@python2/calendar.pyi b/stdlib/@python2/calendar.pyi index 1a8cb1657f1b..c33435170ddd 100644 --- a/stdlib/@python2/calendar.pyi +++ b/stdlib/@python2/calendar.pyi @@ -85,7 +85,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/@python2/copy_reg.pyi b/stdlib/@python2/copy_reg.pyi index ea07ba410b6d..aa9fed854693 100644 --- a/stdlib/@python2/copy_reg.pyi +++ b/stdlib/@python2/copy_reg.pyi @@ -7,7 +7,7 @@ __all__: List[str] def pickle( ob_type: _TypeT, - pickle_function: Callable[[_TypeT], Union[str, _Reduce[_TypeT]]], + pickle_function: Callable[[_TypeT], str | _Reduce[_TypeT]], constructor_ob: Optional[Callable[[_Reduce[_TypeT]], _TypeT]] = ..., ) -> None: ... def constructor(object: Callable[[_Reduce[_TypeT]], _TypeT]) -> None: ... diff --git a/stdlib/@python2/copyreg.pyi b/stdlib/@python2/copyreg.pyi index ea07ba410b6d..aa9fed854693 100644 --- a/stdlib/@python2/copyreg.pyi +++ b/stdlib/@python2/copyreg.pyi @@ -7,7 +7,7 @@ __all__: List[str] def pickle( ob_type: _TypeT, - pickle_function: Callable[[_TypeT], Union[str, _Reduce[_TypeT]]], + pickle_function: Callable[[_TypeT], str | _Reduce[_TypeT]], constructor_ob: Optional[Callable[[_Reduce[_TypeT]], _TypeT]] = ..., ) -> None: ... def constructor(object: Callable[[_Reduce[_TypeT]], _TypeT]) -> None: ... diff --git a/stdlib/@python2/distutils/ccompiler.pyi b/stdlib/@python2/distutils/ccompiler.pyi index 831311d2cb52..0e4adb4f27a9 100644 --- a/stdlib/@python2/distutils/ccompiler.pyi +++ b/stdlib/@python2/distutils/ccompiler.pyi @@ -36,7 +36,7 @@ class CCompiler: 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 detect_language(self, sources: str | List[str]) -> Optional[str]: ... def find_library_file(self, dirs: List[str], lib: str, debug: bool = ...) -> Optional[str]: ... def has_function( self, diff --git a/stdlib/@python2/distutils/cmd.pyi b/stdlib/@python2/distutils/cmd.pyi index 17aa7e32da6c..d87d30fb7277 100644 --- a/stdlib/@python2/distutils/cmd.pyi +++ b/stdlib/@python2/distutils/cmd.pyi @@ -14,7 +14,7 @@ class Command: def announce(self, msg: Text, level: int = ...) -> None: ... def debug_print(self, msg: Text) -> 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_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: ... diff --git a/stdlib/@python2/distutils/command/config.pyi b/stdlib/@python2/distutils/command/config.pyi index 592de5e0cf5b..fc7a7b2f8f23 100644 --- a/stdlib/@python2/distutils/command/config.pyi +++ b/stdlib/@python2/distutils/command/config.pyi @@ -31,7 +31,7 @@ class config(Command): ) -> bool: ... def search_cpp( self, - pattern: Union[Pattern[str], str], + pattern: Pattern[str] | str, body: Optional[str] = ..., headers: Optional[Sequence[str]] = ..., include_dirs: Optional[Sequence[str]] = ..., diff --git a/stdlib/@python2/distutils/core.pyi b/stdlib/@python2/distutils/core.pyi index 9a3fa70fd381..47bb1048d3b7 100644 --- a/stdlib/@python2/distutils/core.pyi +++ b/stdlib/@python2/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] = ..., diff --git a/stdlib/@python2/distutils/fancy_getopt.pyi b/stdlib/@python2/distutils/fancy_getopt.pyi index 8eb4c416fa28..fe5505e0649f 100644 --- a/stdlib/@python2/distutils/fancy_getopt.pyi +++ b/stdlib/@python2/distutils/fancy_getopt.pyi @@ -5,7 +5,7 @@ _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]: ... +) -> List[str] | _GR: ... def wrap_text(text: str, width: int) -> List[str]: ... class FancyGetopt: diff --git a/stdlib/@python2/genericpath.pyi b/stdlib/@python2/genericpath.pyi index f1d3538cd1a4..2ab01e8d99f4 100644 --- a/stdlib/@python2/genericpath.pyi +++ b/stdlib/@python2/genericpath.pyi @@ -3,10 +3,10 @@ from typing import List, Sequence, Text, 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[str]) -> Union[str, Literal[""]]: ... # type: ignore +def commonprefix(m: Sequence[str]) -> str | Literal[""]: ... # type: ignore @overload def commonprefix(m: Sequence[Text]) -> Text: ... # type: ignore @overload diff --git a/stdlib/@python2/gettext.pyi b/stdlib/@python2/gettext.pyi index b7d93ee053e8..d8acebfde6df 100644 --- a/stdlib/@python2/gettext.pyi +++ b/stdlib/@python2/gettext.pyi @@ -34,7 +34,7 @@ class GNUTranslations(NullTranslations): def find( domain: str, localedir: Optional[str] = ..., languages: Optional[Sequence[str]] = ..., all: Any = ... -) -> Optional[Union[str, List[str]]]: ... +) -> Optional[str | List[str]]: ... def translation( domain: str, localedir: Optional[str] = ..., diff --git a/stdlib/@python2/imaplib.pyi b/stdlib/@python2/imaplib.pyi index 18f21ef137e5..5f8673f1cb96 100644 --- a/stdlib/@python2/imaplib.pyi +++ b/stdlib/@python2/imaplib.pyi @@ -9,7 +9,7 @@ from typing_extensions import Literal # E.g. Tuple[Literal["OK"], List[bytes]] _CommandResults = Tuple[str, List[Any]] -_AnyResponseData = Union[List[None], List[Union[bytes, Tuple[bytes, bytes]]]] +_AnyResponseData = Union[List[None], List[bytes | Tuple[bytes, bytes]]] class IMAP4: error: Type[Exception] = ... @@ -20,7 +20,7 @@ class IMAP4: state: str = ... literal: Optional[Text] = ... tagged_commands: Dict[bytes, Optional[List[bytes]]] - untagged_responses: Dict[str, List[Union[bytes, Tuple[bytes, bytes]]]] + untagged_responses: Dict[str, List[bytes | Tuple[bytes, bytes]]] continuation_response: str = ... is_readonly: bool = ... tagnum: int = ... @@ -35,7 +35,7 @@ class IMAP4: host: str = ... port: int = ... sock: _socket = ... - file: Union[IO[Text], IO[bytes]] = ... + file: IO[Text] | IO[bytes] = ... def read(self, size: int) -> bytes: ... def readline(self) -> bytes: ... def send(self, data: bytes) -> None: ... diff --git a/stdlib/@python2/inspect.pyi b/stdlib/@python2/inspect.pyi index 64084a5cb0f8..73d59799dded 100644 --- a/stdlib/@python2/inspect.pyi +++ b/stdlib/@python2/inspect.pyi @@ -81,7 +81,7 @@ class ArgInfo(NamedTuple): locals: Dict[str, Any] class Arguments(NamedTuple): - args: List[Union[str, List[Any]]] + args: List[str | List[Any]] varargs: Optional[str] keywords: Optional[str] diff --git a/stdlib/@python2/json.pyi b/stdlib/@python2/json.pyi index a6030f2174e8..45c6e7503d59 100644 --- a/stdlib/@python2/json.pyi +++ b/stdlib/@python2/json.pyi @@ -17,7 +17,7 @@ def dumps( ) -> str: ... def dump( obj: Any, - fp: Union[IO[str], IO[Text]], + fp: IO[str] | IO[Text], skipkeys: bool = ..., ensure_ascii: bool = ..., check_circular: bool = ..., diff --git a/stdlib/@python2/lib2to3/pytree.pyi b/stdlib/@python2/lib2to3/pytree.pyi index fd201b63f893..2236fc716061 100644 --- a/stdlib/@python2/lib2to3/pytree.pyi +++ b/stdlib/@python2/lib2to3/pytree.pyi @@ -24,7 +24,7 @@ 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]: ... diff --git a/stdlib/@python2/logging/__init__.pyi b/stdlib/@python2/logging/__init__.pyi index 68524da772ff..85b105906a6e 100644 --- a/stdlib/@python2/logging/__init__.pyi +++ b/stdlib/@python2/logging/__init__.pyi @@ -6,7 +6,7 @@ from typing import IO, Any, Callable, Dict, List, Mapping, MutableMapping, Optio _SysExcInfoType = Union[Tuple[type, BaseException, Optional[TracebackType]], Tuple[None, None, None]] _ExcInfoType = None | bool | _SysExcInfoType -_ArgsType = Union[Tuple[Any, ...], Mapping[str, Any]] +_ArgsType = Tuple[Any, ...] | Mapping[str, Any] _FilterType = Union[Filter, Callable[[LogRecord], int]] _Level = int | Text diff --git a/stdlib/@python2/logging/config.pyi b/stdlib/@python2/logging/config.pyi index 3d8817b7736f..196588c54622 100644 --- a/stdlib/@python2/logging/config.pyi +++ b/stdlib/@python2/logging/config.pyi @@ -6,7 +6,7 @@ _Path = StrPath def dictConfig(config: Dict[str, Any]) -> None: ... def fileConfig( - fname: Union[str, IO[str]], defaults: Optional[Dict[str, str]] = ..., disable_existing_loggers: bool = ... + fname: str | IO[str], defaults: Optional[Dict[str, str]] = ..., disable_existing_loggers: bool = ... ) -> None: ... def listen(port: int = ...) -> Thread: ... def stopListening() -> None: ... diff --git a/stdlib/@python2/logging/handlers.pyi b/stdlib/@python2/logging/handlers.pyi index 13c561c0ce82..36fa2ad2146e 100644 --- a/stdlib/@python2/logging/handlers.pyi +++ b/stdlib/@python2/logging/handlers.pyi @@ -91,7 +91,7 @@ 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: Optional[SocketKind] = ... ) -> None: ... def encodePriority(self, facility: int | str, priority: int | str) -> int: ... def mapPriority(self, levelName: str) -> str: ... @@ -107,7 +107,7 @@ class SMTPHandler(Handler): # TODO `secure` can also be an empty tuple def __init__( self, - mailhost: Union[str, Tuple[str, int]], + mailhost: str | Tuple[str, int], fromaddr: str, toaddrs: List[str], subject: str, diff --git a/stdlib/@python2/mailbox.pyi b/stdlib/@python2/mailbox.pyi index 42af58f32908..4500f5af28ef 100644 --- a/stdlib/@python2/mailbox.pyi +++ b/stdlib/@python2/mailbox.pyi @@ -137,7 +137,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_: Optional[bool | Tuple[int, int, int, int, int, int, int, int, int]] = ... ) -> None: ... def get_flags(self) -> str: ... def set_flags(self, flags: Iterable[str]) -> None: ... diff --git a/stdlib/@python2/msilib/__init__.pyi b/stdlib/@python2/msilib/__init__.pyi index c783493f315e..9a0089d53373 100644 --- a/stdlib/@python2/msilib/__init__.pyi +++ b/stdlib/@python2/msilib/__init__.pyi @@ -33,8 +33,8 @@ if sys.platform == "win32": def change_sequence( seq: Sequence[Tuple[str, Optional[str], 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: ... diff --git a/stdlib/@python2/nntplib.pyi b/stdlib/@python2/nntplib.pyi index 0bbdc71841ff..4ce76e0ced9a 100644 --- a/stdlib/@python2/nntplib.pyi +++ b/stdlib/@python2/nntplib.pyi @@ -76,8 +76,8 @@ class _NNTPBase: 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: ... diff --git a/stdlib/@python2/pdb.pyi b/stdlib/@python2/pdb.pyi index ba04e4d28fab..d1e3649c5a5e 100644 --- a/stdlib/@python2/pdb.pyi +++ b/stdlib/@python2/pdb.pyi @@ -51,7 +51,7 @@ class Pdb(Bdb, Cmd): def displayhook(self, obj: object) -> None: ... def handle_command_def(self, line: str) -> bool: ... def defaultFile(self) -> str: ... - def lineinfo(self, identifier: str) -> 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: ... diff --git a/stdlib/@python2/pickletools.pyi b/stdlib/@python2/pickletools.pyi index 1f035886319e..423ece56286a 100644 --- a/stdlib/@python2/pickletools.pyi +++ b/stdlib/@python2/pickletools.pyi @@ -117,10 +117,10 @@ 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, Optional[Any], Optional[int]]]: ... +def optimize(p: bytes | IO[bytes]) -> bytes: ... def dis( - pickle: Union[bytes, IO[bytes]], + pickle: bytes | IO[bytes], out: Optional[IO[str]] = ..., memo: Optional[MutableMapping[int, Any]] = ..., indentlevel: int = ..., diff --git a/stdlib/@python2/plistlib.pyi b/stdlib/@python2/plistlib.pyi index 44f91e5297ca..25db8b3d9895 100644 --- a/stdlib/@python2/plistlib.pyi +++ b/stdlib/@python2/plistlib.pyi @@ -2,8 +2,8 @@ from typing import IO, Any, Dict as DictT, Mapping, Text, Union _Path = str | Text -def readPlist(pathOrFile: Union[_Path, IO[bytes]]) -> Any: ... -def writePlist(value: Mapping[str, Any], pathOrFile: Union[_Path, IO[bytes]]) -> None: ... +def readPlist(pathOrFile: _Path | IO[bytes]) -> Any: ... +def writePlist(value: Mapping[str, Any], pathOrFile: _Path | IO[bytes]) -> None: ... def readPlistFromBytes(data: bytes) -> Any: ... def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ... def readPlistFromResource(path: _Path, restype: str = ..., resid: int = ...) -> Any: ... diff --git a/stdlib/@python2/pty.pyi b/stdlib/@python2/pty.pyi index 93983690fff4..50c137a61c83 100644 --- a/stdlib/@python2/pty.pyi +++ b/stdlib/@python2/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 = ...) -> None: ... +def spawn(argv: str | Iterable[str], master_read: _Reader = ..., stdin_read: _Reader = ...) -> None: ... diff --git a/stdlib/@python2/pydoc.pyi b/stdlib/@python2/pydoc.pyi index 081fd2723adc..37ad2200e05b 100644 --- a/stdlib/@python2/pydoc.pyi +++ b/stdlib/@python2/pydoc.pyi @@ -218,9 +218,9 @@ def writedoc(thing: str | object, forceload: bool = ...) -> None: ... def writedocs(dir: str, pkgpath: str = ..., done: Optional[Any] = ...) -> 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, ...]]] + topics: Dict[str, str | Tuple[str, ...]] def __init__(self, input: Optional[IO[str]] = ..., output: Optional[IO[str]] = ...) -> None: ... input: IO[str] output: IO[str] diff --git a/stdlib/@python2/re.pyi b/stdlib/@python2/re.pyi index 18a462298b05..84dfdae5c61a 100644 --- a/stdlib/@python2/re.pyi +++ b/stdlib/@python2/re.pyi @@ -26,21 +26,21 @@ def compile(pattern: Pattern[AnyStr], flags: int = ...) -> Pattern[AnyStr]: ... @overload def search(pattern: str | unicode, string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... @overload -def search(pattern: Union[Pattern[str], Pattern[unicode]], string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... +def search(pattern: Pattern[str] | Pattern[unicode], string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... @overload def match(pattern: str | unicode, string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... @overload -def match(pattern: Union[Pattern[str], Pattern[unicode]], string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... +def match(pattern: Pattern[str] | Pattern[unicode], string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... @overload def split(pattern: str | unicode, string: AnyStr, maxsplit: int = ..., flags: int = ...) -> List[AnyStr]: ... @overload def split( - pattern: Union[Pattern[str], Pattern[unicode]], string: AnyStr, maxsplit: int = ..., flags: int = ... + pattern: Pattern[str] | Pattern[unicode], string: AnyStr, maxsplit: int = ..., flags: int = ... ) -> List[AnyStr]: ... @overload def findall(pattern: str | unicode, string: AnyStr, flags: int = ...) -> List[Any]: ... @overload -def findall(pattern: Union[Pattern[str], Pattern[unicode]], string: AnyStr, flags: int = ...) -> List[Any]: ... +def findall(pattern: Pattern[str] | Pattern[unicode], string: AnyStr, flags: int = ...) -> List[Any]: ... # Return an iterator yielding match objects over all non-overlapping matches # for the RE pattern in string. The string is scanned left-to-right, and @@ -49,7 +49,7 @@ def findall(pattern: Union[Pattern[str], Pattern[unicode]], string: AnyStr, flag @overload def finditer(pattern: str | unicode, string: AnyStr, flags: int = ...) -> Iterator[Match[AnyStr]]: ... @overload -def finditer(pattern: Union[Pattern[str], Pattern[unicode]], string: AnyStr, flags: int = ...) -> Iterator[Match[AnyStr]]: ... +def finditer(pattern: Pattern[str] | Pattern[unicode], string: AnyStr, flags: int = ...) -> Iterator[Match[AnyStr]]: ... @overload def sub(pattern: str | unicode, repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ...) -> AnyStr: ... @overload @@ -58,11 +58,11 @@ def sub( ) -> AnyStr: ... @overload def sub( - pattern: Union[Pattern[str], Pattern[unicode]], repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ... + pattern: Pattern[str] | Pattern[unicode], repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ... ) -> AnyStr: ... @overload def sub( - pattern: Union[Pattern[str], Pattern[unicode]], + pattern: Pattern[str] | Pattern[unicode], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., @@ -78,11 +78,11 @@ def subn( ) -> Tuple[AnyStr, int]: ... @overload def subn( - pattern: Union[Pattern[str], Pattern[unicode]], repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ... + pattern: Pattern[str] | Pattern[unicode], repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ... ) -> Tuple[AnyStr, int]: ... @overload def subn( - pattern: Union[Pattern[str], Pattern[unicode]], + pattern: Pattern[str] | Pattern[unicode], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., @@ -90,4 +90,4 @@ def subn( ) -> Tuple[AnyStr, int]: ... def escape(string: AnyStr) -> AnyStr: ... def purge() -> None: ... -def template(pattern: Union[AnyStr, Pattern[AnyStr]], flags: int = ...) -> Pattern[AnyStr]: ... +def template(pattern: AnyStr | Pattern[AnyStr], flags: int = ...) -> Pattern[AnyStr]: ... diff --git a/stdlib/@python2/sets.pyi b/stdlib/@python2/sets.pyi index 1ee3e8b26e1b..d617b2d89bfc 100644 --- a/stdlib/@python2/sets.pyi +++ b/stdlib/@python2/sets.pyi @@ -1,7 +1,7 @@ from typing import Any, Hashable, Iterable, Iterator, MutableMapping, Optional, TypeVar, Union _T = TypeVar("_T") -_Setlike = Union[BaseSet[_T], Iterable[_T]] +_Setlike = BaseSet[_T] | Iterable[_T] _SelfT = TypeVar("_SelfT") class BaseSet(Iterable[_T]): diff --git a/stdlib/@python2/shlex.pyi b/stdlib/@python2/shlex.pyi index 37c667238f09..ae048fc4c079 100644 --- a/stdlib/@python2/shlex.pyi +++ b/stdlib/@python2/shlex.pyi @@ -5,7 +5,7 @@ def split(s: Optional[str], comments: bool = ..., posix: bool = ...) -> List[str _SLT = TypeVar("_SLT", bound=shlex) class shlex: - def __init__(self, instream: Union[IO[Any], Text] = ..., infile: IO[Any] = ..., posix: bool = ...) -> None: ... + def __init__(self, instream: IO[Any] | Text = ..., infile: IO[Any] = ..., posix: bool = ...) -> None: ... def __iter__(self: _SLT) -> _SLT: ... def next(self) -> str: ... def get_token(self) -> Optional[str]: ... diff --git a/stdlib/@python2/shutil.pyi b/stdlib/@python2/shutil.pyi index ff4467ffc471..62bd64f7b4ea 100644 --- a/stdlib/@python2/shutil.pyi +++ b/stdlib/@python2/shutil.pyi @@ -39,7 +39,7 @@ 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: Optional[Sequence[Tuple[str, Any] | List[Any]]] = ..., description: str = ..., ) -> None: ... def unregister_archive_format(name: str) -> None: ... diff --git a/stdlib/@python2/socket.pyi b/stdlib/@python2/socket.pyi index 2a5b924a9f45..9fb44aee9e33 100644 --- a/stdlib/@python2/socket.pyi +++ b/stdlib/@python2/socket.pyi @@ -373,7 +373,7 @@ class timeout(error): # Addresses can be either tuples of varying lengths (AF_INET, AF_INET6, # AF_NETLINK, AF_TIPC) or strings (AF_UNIX). -_Address = Union[Tuple[Any, ...], str] +_Address = Tuple[Any, ...] | str _RetAddress = Any # TODO Most methods allow bytes as address objects @@ -404,7 +404,7 @@ class socket: def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ... def gettimeout(self) -> Optional[float]: ... if sys.platform == "win32": - def ioctl(self, control: int, option: Union[int, Tuple[int, int, int]]) -> None: ... + def ioctl(self, control: int, option: int | Tuple[int, int, int]) -> None: ... def listen(self, __backlog: int) -> None: ... # Note that the makefile's documented windows-specific behavior is not represented def makefile(self, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... @@ -448,7 +448,7 @@ def gethostbyname(hostname: str) -> str: ... def gethostbyname_ex(hostname: str) -> Tuple[str, List[str], List[str]]: ... def gethostname() -> str: ... def gethostbyaddr(ip_address: str) -> Tuple[str, List[str], List[str]]: ... -def getnameinfo(sockaddr: Union[Tuple[str, int], Tuple[str, int, int, int]], flags: int) -> Tuple[str, str]: ... +def getnameinfo(sockaddr: Tuple[str, int] | Tuple[str, int, int, int], flags: int) -> Tuple[str, str]: ... def getprotobyname(protocolname: str) -> int: ... def getservbyname(servicename: str, protocolname: str = ...) -> int: ... def getservbyport(port: int, protocolname: str = ...) -> str: ... diff --git a/stdlib/@python2/ssl.pyi b/stdlib/@python2/ssl.pyi index 1a4133983d52..3451ff3116f1 100644 --- a/stdlib/@python2/ssl.pyi +++ b/stdlib/@python2/ssl.pyi @@ -8,7 +8,7 @@ _PCTRTT = Tuple[Tuple[str, str], ...] _PCTRTTT = Tuple[_PCTRTT, ...] _PeerCertRetDictType = Dict[str, str | _PCTRTTT | _PCTRTT] _PeerCertRetType = _PeerCertRetDictType | bytes | None -_EnumRetType = List[Tuple[bytes, str, Union[Set[str], bool]]] +_EnumRetType = List[Tuple[bytes, str, Set[str] | bool]] _PasswordType = Union[Callable[[], str | bytes], str, bytes] _SC1ArgT = SSLSocket @@ -227,7 +227,7 @@ class SSLContext: def load_verify_locations( self, cafile: Optional[StrPath] = ..., capath: Optional[StrPath] = ..., cadata: Text | 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 set_default_verify_paths(self) -> None: ... def set_ciphers(self, __cipherlist: str) -> None: ... def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ... diff --git a/stdlib/@python2/string.pyi b/stdlib/@python2/string.pyi index 2341f720e867..939a5dd1611b 100644 --- a/stdlib/@python2/string.pyi +++ b/stdlib/@python2/string.pyi @@ -48,13 +48,13 @@ class Template: template: Text def __init__(self, template: Text) -> None: ... @overload - def substitute(self, mapping: Union[Mapping[str, str], Mapping[unicode, str]] = ..., **kwds: str) -> str: ... + def substitute(self, mapping: Mapping[str, str] | Mapping[unicode, str] = ..., **kwds: str) -> str: ... @overload - def substitute(self, mapping: Union[Mapping[str, Text], Mapping[unicode, Text]] = ..., **kwds: Text) -> Text: ... + def substitute(self, mapping: Mapping[str, Text] | Mapping[unicode, Text] = ..., **kwds: Text) -> Text: ... @overload - def safe_substitute(self, mapping: Union[Mapping[str, str], Mapping[unicode, str]] = ..., **kwds: str) -> str: ... + def safe_substitute(self, mapping: Mapping[str, str] | Mapping[unicode, str] = ..., **kwds: str) -> str: ... @overload - def safe_substitute(self, mapping: Union[Mapping[str, Text], Mapping[unicode, Text]], **kwds: Text) -> Text: ... + def safe_substitute(self, mapping: Mapping[str, Text] | Mapping[unicode, Text], **kwds: Text) -> Text: ... # TODO(MichalPokorny): This is probably badly and/or loosely typed. class Formatter(object): diff --git a/stdlib/@python2/subprocess.pyi b/stdlib/@python2/subprocess.pyi index 8b55295eb1c6..358853e9d667 100644 --- a/stdlib/@python2/subprocess.pyi +++ b/stdlib/@python2/subprocess.pyi @@ -2,8 +2,8 @@ from typing import IO, Any, Callable, Generic, Mapping, Optional, Sequence, Text _FILE = Union[None, int, IO[Any]] _TXT = bytes | Text -_CMD = Union[_TXT, Sequence[_TXT]] -_ENV = Union[Mapping[bytes, _TXT], Mapping[Text, _TXT]] +_CMD = _TXT | Sequence[_TXT] +_ENV = Mapping[bytes, _TXT] | Mapping[Text, _TXT] # Same args as Popen.__init__ def call( diff --git a/stdlib/@python2/sunau.pyi b/stdlib/@python2/sunau.pyi index e40ae2181be0..ec632897fdd8 100644 --- a/stdlib/@python2/sunau.pyi +++ b/stdlib/@python2/sunau.pyi @@ -1,6 +1,6 @@ from typing import IO, Any, NoReturn, Optional, Text, Tuple, Union -_File = Union[Text, IO[bytes]] +_File = Text | IO[bytes] class Error(Exception): ... diff --git a/stdlib/@python2/sys.pyi b/stdlib/@python2/sys.pyi index 4285acd4d801..c258e0f22f41 100644 --- a/stdlib/@python2/sys.pyi +++ b/stdlib/@python2/sys.pyi @@ -3,7 +3,7 @@ from typing import IO, Any, Callable, Dict, List, NoReturn, Optional, Text, Tupl # The following type alias are stub-only and do not exist during runtime _ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType] -_OptExcInfo = Union[_ExcInfo, Tuple[None, None, None]] +_OptExcInfo = _ExcInfo | Tuple[None, None, None] class _flags: bytes_warning: int diff --git a/stdlib/@python2/telnetlib.pyi b/stdlib/@python2/telnetlib.pyi index 388e5a8c9310..1f471689d9a0 100644 --- a/stdlib/@python2/telnetlib.pyi +++ b/stdlib/@python2/telnetlib.pyi @@ -107,5 +107,5 @@ class Telnet: def mt_interact(self) -> None: ... def listener(self) -> None: ... def expect( - self, list: Sequence[Union[Pattern[bytes], bytes]], timeout: Optional[float] = ... + self, list: Sequence[Pattern[bytes] | bytes], timeout: Optional[float] = ... ) -> Tuple[int, Optional[Match[bytes]], bytes]: ... diff --git a/stdlib/@python2/termios.pyi b/stdlib/@python2/termios.pyi index 90dd8db9d318..86da7243817d 100644 --- a/stdlib/@python2/termios.pyi +++ b/stdlib/@python2/termios.pyi @@ -1,7 +1,7 @@ from _typeshed import FileDescriptorLike from typing import Any, List, Union -_Attr = List[Union[int, List[bytes | int]]] +_Attr = List[int | List[bytes | int]] # TODO constants not really documented B0: int diff --git a/stdlib/@python2/tty.pyi b/stdlib/@python2/tty.pyi index c0dc418e9933..47132006edeb 100644 --- a/stdlib/@python2/tty.pyi +++ b/stdlib/@python2/tty.pyi @@ -1,6 +1,6 @@ from typing import IO, Union -_FD = Union[int, IO[str]] +_FD = int | IO[str] # XXX: Undocumented integer constants IFLAG: int diff --git a/stdlib/@python2/turtle.pyi b/stdlib/@python2/turtle.pyi index 87c60c3235b9..5f3c3055012f 100644 --- a/stdlib/@python2/turtle.pyi +++ b/stdlib/@python2/turtle.pyi @@ -8,7 +8,7 @@ PhotoImage = Any # alias we use for return types. Really, these two aliases should be the # same, but as per the "no union returns" typeshed policy, we'll return # Any instead. -_Color = Union[Text, Tuple[float, float, float]] +_Color = Text | Tuple[float, float, float] _AnyColor = Any # TODO: Replace this with a TypedDict once it becomes standardized. @@ -112,11 +112,11 @@ 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: ... @@ -231,7 +231,7 @@ class RawTurtle(TPen, TNavigator): # a compound stamp or not. So, as per the "no Union return" policy, # we return Any. def stamp(self) -> Any: ... - def clearstamp(self, stampid: Union[int, Tuple[int, ...]]) -> None: ... + def clearstamp(self, stampid: int | Tuple[int, ...]) -> None: ... def clearstamps(self, n: Optional[int] = ...) -> None: ... def filling(self) -> bool: ... def begin_fill(self) -> None: ... @@ -365,11 +365,11 @@ 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: ... @@ -478,7 +478,7 @@ def tilt(angle: float) -> None: ... # a compound stamp or not. So, as per the "no Union return" policy, # we return Any. def stamp() -> Any: ... -def clearstamp(stampid: Union[int, Tuple[int, ...]]) -> None: ... +def clearstamp(stampid: int | Tuple[int, ...]) -> None: ... def clearstamps(n: Optional[int] = ...) -> None: ... def filling() -> bool: ... def begin_fill() -> None: ... diff --git a/stdlib/@python2/unittest.pyi b/stdlib/@python2/unittest.pyi index 8d46e5b8d244..c69e17239074 100644 --- a/stdlib/@python2/unittest.pyi +++ b/stdlib/@python2/unittest.pyi @@ -28,7 +28,7 @@ _T = TypeVar("_T") _FT = TypeVar("_FT") _ExceptionType = Union[Type[BaseException], Tuple[Type[BaseException], ...]] -_Regexp = Union[Text, Pattern[Text]] +_Regexp = Text | Pattern[Text] _SysExcInfoType = Union[Tuple[Type[BaseException], BaseException, types.TracebackType], Tuple[None, None, None]] @@ -145,7 +145,7 @@ class TestCase(Testable): def assertListEqual(self, first: List[Any], second: List[Any], msg: object = ...) -> None: ... def assertTupleEqual(self, first: Tuple[Any, ...], second: Tuple[Any, ...], msg: object = ...) -> None: ... def assertSetEqual( - self, first: Union[Set[Any], FrozenSet[Any]], second: Union[Set[Any], FrozenSet[Any]], msg: object = ... + self, first: Set[Any] | FrozenSet[Any], second: Set[Any] | FrozenSet[Any], msg: object = ... ) -> None: ... def assertDictEqual(self, first: Dict[Any, Any], second: Dict[Any, Any], msg: object = ...) -> None: ... def assertLess(self, first: Any, second: Any, msg: object = ...) -> None: ... @@ -177,8 +177,8 @@ class TestCase(Testable): def assertIsNotNone(self, expr: Any, msg: object = ...) -> None: ... def assertIn(self, first: _T, second: Iterable[_T], msg: object = ...) -> None: ... def assertNotIn(self, first: _T, second: Iterable[_T], msg: object = ...) -> None: ... - def assertIsInstance(self, obj: Any, cls: Union[type, Tuple[type, ...]], msg: object = ...) -> None: ... - def assertNotIsInstance(self, obj: Any, cls: Union[type, Tuple[type, ...]], msg: object = ...) -> None: ... + def assertIsInstance(self, obj: Any, cls: type | Tuple[type, ...], msg: object = ...) -> None: ... + def assertNotIsInstance(self, obj: Any, cls: type | Tuple[type, ...], msg: object = ...) -> None: ... def fail(self, msg: object = ...) -> NoReturn: ... def countTestCases(self) -> int: ... def defaultTestResult(self) -> TestResult: ... diff --git a/stdlib/@python2/urllib2.pyi b/stdlib/@python2/urllib2.pyi index fbc05a608fa9..1a06c240e23b 100644 --- a/stdlib/@python2/urllib2.pyi +++ b/stdlib/@python2/urllib2.pyi @@ -70,7 +70,7 @@ def urlopen( context: Optional[ssl.SSLContext] = ..., ) -> addinfourl: ... def install_opener(opener: OpenerDirector) -> None: ... -def build_opener(*handlers: Union[BaseHandler, Type[BaseHandler]]) -> OpenerDirector: ... +def build_opener(*handlers: BaseHandler | Type[BaseHandler]) -> OpenerDirector: ... class BaseHandler: handler_order: int @@ -102,7 +102,7 @@ class ProxyHandler(BaseHandler): class HTTPPasswordMgr: def __init__(self) -> None: ... - def add_password(self, realm: Optional[Text], uri: Union[Text, Sequence[Text]], user: Text, passwd: Text) -> None: ... + def add_password(self, realm: Optional[Text], uri: Text | Sequence[Text], user: Text, passwd: Text) -> None: ... def find_user_password(self, realm: Optional[Text], authuri: Text) -> Tuple[Any, Any]: ... def reduce_uri(self, uri: _string, default_port: bool = ...) -> Tuple[Any, Any]: ... def is_suburi(self, base: _string, test: _string) -> bool: ... @@ -111,7 +111,7 @@ class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr): ... class AbstractBasicAuthHandler: def __init__(self, password_mgr: Optional[HTTPPasswordMgr] = ...) -> None: ... - def add_password(self, realm: Optional[Text], uri: Union[Text, Sequence[Text]], user: Text, passwd: Text) -> None: ... + def add_password(self, realm: Optional[Text], uri: Text | Sequence[Text], user: Text, passwd: Text) -> None: ... def http_error_auth_reqed(self, authreq, host, req: Request, headers: Mapping[str, str]): ... def retry_http_basic_auth(self, host, req: Request, realm): ... @@ -125,7 +125,7 @@ class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler): class AbstractDigestAuthHandler: def __init__(self, passwd: Optional[HTTPPasswordMgr] = ...) -> None: ... - def add_password(self, realm: Optional[Text], uri: Union[Text, Sequence[Text]], user: Text, passwd: Text) -> None: ... + def add_password(self, realm: Optional[Text], uri: Text | Sequence[Text], user: Text, passwd: Text) -> None: ... def reset_retry_count(self) -> None: ... def http_error_auth_reqed(self, auth_header: str, host: str, req: Request, headers: Mapping[str, str]) -> None: ... def retry_http_digest_auth(self, req: Request, auth: str) -> Optional[HTTPResponse]: ... diff --git a/stdlib/@python2/wave.pyi b/stdlib/@python2/wave.pyi index 8615d8fad8ca..cfcdf97e8b90 100644 --- a/stdlib/@python2/wave.pyi +++ b/stdlib/@python2/wave.pyi @@ -1,6 +1,6 @@ from typing import IO, Any, BinaryIO, NoReturn, Optional, Text, Tuple, Union -_File = Union[Text, IO[bytes]] +_File = Text | IO[bytes] class Error(Exception): ... diff --git a/stdlib/@python2/webbrowser.pyi b/stdlib/@python2/webbrowser.pyi index 9e143bb8c88f..d0dd0d8d7912 100644 --- a/stdlib/@python2/webbrowser.pyi +++ b/stdlib/@python2/webbrowser.pyi @@ -24,7 +24,7 @@ class GenericBrowser(BaseBrowser): args: List[str] name: str basename: str - def __init__(self, name: Union[Text, Sequence[Text]]) -> None: ... + def __init__(self, name: Text | Sequence[Text]) -> None: ... def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... class BackgroundBrowser(GenericBrowser): diff --git a/stdlib/@python2/xml/dom/minidom.pyi b/stdlib/@python2/xml/dom/minidom.pyi index 8a5126bb73eb..599fcb763c50 100644 --- a/stdlib/@python2/xml/dom/minidom.pyi +++ b/stdlib/@python2/xml/dom/minidom.pyi @@ -5,7 +5,7 @@ from xml.sax.xmlreader import XMLReader _T = TypeVar("_T") -def parse(file: Union[str, IO[Any]], parser: Optional[XMLReader] = ..., bufsize: Optional[int] = ...): ... +def parse(file: str | IO[Any], parser: Optional[XMLReader] = ..., bufsize: Optional[int] = ...): ... def parseString(string: bytes | _Text, parser: Optional[XMLReader] = ...): ... def getDOMImplementation(features=...): ... diff --git a/stdlib/@python2/xml/etree/ElementTree.pyi b/stdlib/@python2/xml/etree/ElementTree.pyi index 4ce89452ec47..938520d9de29 100644 --- a/stdlib/@python2/xml/etree/ElementTree.pyi +++ b/stdlib/@python2/xml/etree/ElementTree.pyi @@ -59,7 +59,7 @@ class Element(MutableSequence[Element]): tail: Optional[_str_result_type] def __init__( self, - tag: Union[_str_argument_type, Callable[..., Element]], + tag: _str_argument_type | Callable[..., Element], attrib: Dict[_str_argument_type, _str_argument_type] = ..., **extra: _str_argument_type, ) -> None: ... diff --git a/stdlib/@python2/xmlrpclib.pyi b/stdlib/@python2/xmlrpclib.pyi index c1d8b8c966f9..d6b1166df4d9 100644 --- a/stdlib/@python2/xmlrpclib.pyi +++ b/stdlib/@python2/xmlrpclib.pyi @@ -189,7 +189,7 @@ class MultiCall: def getparser(use_datetime: bool = ...) -> Tuple[ExpatParser | SlowParser, Unmarshaller]: ... def dumps( - params: Union[Tuple[Any, ...], Fault], + params: Tuple[Any, ...] | Fault, methodname: Optional[str] = ..., methodresponse: Optional[bool] = ..., encoding: Optional[str] = ..., diff --git a/stdlib/@python2/zipfile.pyi b/stdlib/@python2/zipfile.pyi index 3dbfd035c85b..19adc6c19402 100644 --- a/stdlib/@python2/zipfile.pyi +++ b/stdlib/@python2/zipfile.pyi @@ -47,7 +47,7 @@ class ZipFile: NameToInfo: Dict[Text, ZipInfo] start_dir: int # undocumented def __init__( - self, file: Union[StrPath, IO[bytes]], mode: Text = ..., compression: int = ..., allowZip64: bool = ... + self, file: StrPath | IO[bytes], mode: Text = ..., compression: int = ..., allowZip64: bool = ... ) -> None: ... def __enter__(self) -> ZipFile: ... def __exit__( @@ -96,7 +96,7 @@ class ZipInfo: class _PathOpenProtocol(Protocol): def __call__(self, mode: str = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... -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/@python2/zlib.pyi b/stdlib/@python2/zlib.pyi index f33777ced457..8f946924057c 100644 --- a/stdlib/@python2/zlib.pyi +++ b/stdlib/@python2/zlib.pyi @@ -35,6 +35,6 @@ 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 = ...) -> _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 = ...) -> _Decompress: ... diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index b62c2b0e34f8..49d2e140cfb9 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -6,7 +6,7 @@ from typing import Any, Callable, Dict, Optional, Tuple, Union class _EncodingMap: def size(self) -> int: ... -_MapT = Union[Dict[int, int], _EncodingMap] +_MapT = Dict[int, int] | _EncodingMap _Handler = Callable[[Exception], Tuple[str, int]] def register(__search_function: Callable[[str], Any]) -> None: ... diff --git a/stdlib/_socket.pyi b/stdlib/_socket.pyi index 2cd8f88aab48..f7f727b13e0d 100644 --- a/stdlib/_socket.pyi +++ b/stdlib/_socket.pyi @@ -15,7 +15,7 @@ _CMSGArg = Tuple[int, int, ReadableBuffer] # Addresses can be either tuples of varying lengths (AF_INET, AF_INET6, # AF_NETLINK, AF_TIPC) or strings (AF_UNIX). -_Address = Union[Tuple[Any, ...], str] +_Address = Tuple[Any, ...] | str _RetAddress = Any # TODO Most methods allow bytes as address objects @@ -595,7 +595,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: ... diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index 49402963d8dc..a968d9b50897 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -54,8 +54,8 @@ class SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra, def __delitem__(self, __v: _KT_contra) -> None: ... # These aliases are simple strings in Python 2. -StrPath = Union[str, PathLike[str]] # stable -BytesPath = Union[bytes, PathLike[bytes]] # stable +StrPath = str | PathLike[str] # stable +BytesPath = bytes | PathLike[bytes] # stable StrOrBytesPath = Union[str, bytes, PathLike[str], PathLike[bytes]] # stable AnyPath = StrOrBytesPath # obsolete, will be removed soon diff --git a/stdlib/_winapi.pyi b/stdlib/_winapi.pyi index 2457d65d2715..b573870fa0ae 100644 --- a/stdlib/_winapi.pyi +++ b/stdlib/_winapi.pyi @@ -106,7 +106,7 @@ 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 diff --git a/stdlib/aifc.pyi b/stdlib/aifc.pyi index b43af47ff5e8..d3327526a0ae 100644 --- a/stdlib/aifc.pyi +++ b/stdlib/aifc.pyi @@ -13,7 +13,7 @@ class _aifc_params(NamedTuple): comptype: bytes compname: bytes -_File = Union[str, IO[bytes]] +_File = str | IO[bytes] _Marker = Tuple[int, int, bytes] class Aifc_read: diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index cede7ae295a8..5f5cb6aca16d 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -64,7 +64,7 @@ class _ActionsContainer: def add_argument( self, *name_or_flags: str, - action: Union[str, Type[Action]] = ..., + action: str | Type[Action] = ..., nargs: int | str = ..., const: Any = ..., default: Any = ..., @@ -72,7 +72,7 @@ class _ActionsContainer: choices: Iterable[_T] = ..., required: bool = ..., help: Optional[str] = ..., - metavar: Optional[Union[str, Tuple[str, ...]]] = ..., + metavar: Optional[str | Tuple[str, ...]] = ..., dest: Optional[str] = ..., version: str = ..., **kwargs: Any, @@ -276,7 +276,7 @@ class Action(_AttributeHolder): choices: Optional[Iterable[Any]] required: bool help: Optional[str] - metavar: Optional[Union[str, Tuple[str, ...]]] + metavar: Optional[str | Tuple[str, ...]] def __init__( self, option_strings: Sequence[str], @@ -288,7 +288,7 @@ class Action(_AttributeHolder): choices: Optional[Iterable[_T]] = ..., required: bool = ..., help: Optional[str] = ..., - metavar: Optional[Union[str, Tuple[str, ...]]] = ..., + metavar: Optional[str | Tuple[str, ...]] = ..., ) -> None: ... def __call__( self, @@ -311,7 +311,7 @@ if sys.version_info >= (3, 9): choices: Optional[Iterable[_T]] = ..., required: bool = ..., help: Optional[str] = ..., - metavar: Optional[Union[str, Tuple[str, ...]]] = ..., + metavar: Optional[str | Tuple[str, ...]] = ..., ) -> None: ... class Namespace(_AttributeHolder): @@ -358,7 +358,7 @@ class _StoreConstAction(Action): default: Any = ..., required: bool = ..., help: Optional[str] = ..., - metavar: Optional[Union[str, Tuple[str, ...]]] = ..., + metavar: Optional[str | Tuple[str, ...]] = ..., ) -> None: ... # undocumented @@ -386,7 +386,7 @@ class _AppendConstAction(Action): default: Any = ..., required: bool = ..., help: Optional[str] = ..., - metavar: Optional[Union[str, Tuple[str, ...]]] = ..., + metavar: Optional[str | Tuple[str, ...]] = ..., ) -> None: ... # undocumented @@ -423,7 +423,7 @@ class _SubParsersAction(Action): dest: str = ..., required: bool = ..., help: Optional[str] = ..., - metavar: Optional[Union[str, Tuple[str, ...]]] = ..., + metavar: Optional[str | Tuple[str, ...]] = ..., ) -> None: ... else: def __init__( @@ -433,7 +433,7 @@ class _SubParsersAction(Action): parser_class: Type[ArgumentParser], dest: str = ..., help: Optional[str] = ..., - metavar: Optional[Union[str, Tuple[str, ...]]] = ..., + metavar: Optional[str | Tuple[str, ...]] = ..., ) -> None: ... # TODO: Type keyword args properly. def add_parser(self, name: str, **kwargs: Any) -> ArgumentParser: ... diff --git a/stdlib/array.pyi b/stdlib/array.pyi index cc8d56d7b6e5..58249f6ab55f 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: ... diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index a4f3b1f89b7f..b7633a2fc471 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -74,9 +74,9 @@ 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]]] ) -> None: ... @@ -98,9 +98,9 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): 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 @@ -211,7 +211,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): async def create_server( self, protocol_factory: _ProtocolFactory, - host: Optional[Union[str, Sequence[str]]] = ..., + host: Optional[str | Sequence[str]] = ..., port: int = ..., *, family: int = ..., @@ -273,7 +273,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): async def create_server( self, protocol_factory: _ProtocolFactory, - host: Optional[Union[str, Sequence[str]]] = ..., + host: Optional[str | Sequence[str]] = ..., port: int = ..., *, family: int = ..., diff --git a/stdlib/asyncio/base_subprocess.pyi b/stdlib/asyncio/base_subprocess.pyi index 392313fed57d..d16155521aa5 100644 --- a/stdlib/asyncio/base_subprocess.pyi +++ b/stdlib/asyncio/base_subprocess.pyi @@ -3,7 +3,7 @@ from typing import IO, Any, Callable, Deque, Dict, List, Optional, Sequence, Tup from . import events, futures, protocols, transports -_File = Optional[Union[int, IO[Any]]] +_File = Optional[int | IO[Any]] class BaseSubprocessTransport(transports.SubprocessTransport): diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index ad5fe08f6380..7944147f69b6 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -99,10 +99,10 @@ 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: Optional[str] = ...) -> 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]]] @@ -127,10 +127,10 @@ class AbstractEventLoop(metaclass=ABCMeta): 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 @@ -249,7 +249,7 @@ class AbstractEventLoop(metaclass=ABCMeta): async def create_server( self, protocol_factory: _ProtocolFactory, - host: Optional[Union[str, Sequence[str]]] = ..., + host: Optional[str | Sequence[str]] = ..., port: int = ..., *, family: int = ..., @@ -328,7 +328,7 @@ class AbstractEventLoop(metaclass=ABCMeta): async def create_server( self, protocol_factory: _ProtocolFactory, - host: Optional[Union[str, Sequence[str]]] = ..., + host: Optional[str | Sequence[str]] = ..., port: int = ..., *, family: int = ..., diff --git a/stdlib/asyncio/futures.pyi b/stdlib/asyncio/futures.pyi index 4700cf16c185..ed9e273bb58c 100644 --- a/stdlib/asyncio/futures.pyi +++ b/stdlib/asyncio/futures.pyi @@ -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: Optional[AbstractEventLoop] = ...) -> Future[_T]: ... diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index 09ab3c49b166..43fc38a4e728 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -274,18 +274,18 @@ 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] = ..., ) -> 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]: ... @@ -308,8 +308,8 @@ if sys.version_info >= (3, 7): def all_tasks(loop: Optional[AbstractEventLoop] = ...) -> 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: Optional[str] = ... ) -> Task[_T]: ... else: - def create_task(coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]]) -> Task[_T]: ... + def create_task(coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T]) -> Task[_T]: ... def current_task(loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ... diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index c77c8613b803..2a97891d6b0d 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -5,7 +5,7 @@ from typing import Any, BinaryIO, Iterable, List, NoReturn, Optional, Tuple, Typ if sys.version_info >= (3, 8): # These are based in socket, maybe move them out into _typeshed.pyi or such - _Address = Union[Tuple[Any, ...], str] + _Address = Tuple[Any, ...] | str _RetAddress = Any _WriteBuffer = bytearray | memoryview _CMSG = Tuple[int, int, bytes] diff --git a/stdlib/asyncore.pyi b/stdlib/asyncore.pyi index 2754d5efbb36..fccf03c7f78a 100644 --- a/stdlib/asyncore.pyi +++ b/stdlib/asyncore.pyi @@ -41,8 +41,8 @@ class dispatcher: 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 bind(self, addr: Tuple[Any, ...] | str) -> None: ... + def connect(self, address: Tuple[Any, ...] | str) -> None: ... def accept(self) -> Optional[Tuple[_socket, Any]]: ... def send(self, data: bytes) -> int: ... def recv(self, buffer_size: int) -> bytes: ... diff --git a/stdlib/bdb.pyi b/stdlib/bdb.pyi index 7a586b0666fd..32452fc224e6 100644 --- a/stdlib/bdb.pyi +++ b/stdlib/bdb.pyi @@ -94,5 +94,5 @@ class Breakpoint: 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/binhex.pyi b/stdlib/binhex.pyi index 02d094faf923..a8280b819539 100644 --- a/stdlib/binhex.pyi +++ b/stdlib/binhex.pyi @@ -13,7 +13,7 @@ class FInfo: Flags: int _FileInfoTuple = Tuple[str, FInfo, int, int] -_FileHandleUnion = Union[str, IO[bytes]] +_FileHandleUnion = str | IO[bytes] def getfileinfo(name: str) -> _FileInfoTuple: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index b6a0108da16f..0cf42645ab36 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -84,7 +84,7 @@ _TBE = TypeVar("_TBE", bound="BaseException") class object: __doc__: Optional[str] __dict__: Dict[str, Any] - __slots__: Union[str, Iterable[str]] + __slots__: str | Iterable[str] __module__: str __annotations__: Dict[str, Any] @property @@ -104,8 +104,8 @@ 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_ex__(self, protocol: int) -> Union[str, Tuple[Any, ...]]: ... + def __reduce__(self) -> str | Tuple[Any, ...]: ... + def __reduce_ex__(self, protocol: int) -> str | Tuple[Any, ...]: ... def __dir__(self) -> Iterable[str]: ... def __init_subclass__(cls) -> None: ... @@ -188,7 +188,7 @@ class int: def to_bytes(self, length: int, byteorder: str, *, signed: bool = ...) -> bytes: ... @classmethod def from_bytes( - cls, bytes: Union[Iterable[int], SupportsBytes], byteorder: str, *, signed: bool = ... + cls, bytes: Iterable[int] | SupportsBytes, byteorder: str, *, signed: bool = ... ) -> int: ... # TODO buffer object argument def __add__(self, x: int) -> int: ... def __sub__(self, x: int) -> int: ... @@ -338,7 +338,7 @@ class str(Sequence[str]): def count(self, x: str, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...) -> 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: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> str: ... def find(self, __sub: str, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ...) -> int: ... @@ -376,12 +376,12 @@ class str(Sequence[str]): def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> 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: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... ) -> bool: ... def strip(self, __chars: Optional[str] = ...) -> str: ... def swapcase(self) -> str: ... def title(self) -> str: ... - def translate(self, __table: Union[Mapping[int, int | str | None], Sequence[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: int) -> str: ... @staticmethod @@ -429,7 +429,7 @@ class bytes(ByteString): def decode(self, encoding: str = ..., errors: str = ...) -> str: ... def endswith( self, - __suffix: Union[bytes, Tuple[bytes, ...]], + __suffix: bytes | Tuple[bytes, ...], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ..., ) -> bool: ... @@ -476,7 +476,7 @@ class bytes(ByteString): def splitlines(self, keepends: bool = ...) -> List[bytes]: ... def startswith( self, - __prefix: Union[bytes, Tuple[bytes, ...]], + __prefix: bytes | Tuple[bytes, ...], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ..., ) -> bool: ... @@ -532,7 +532,7 @@ class bytearray(MutableSequence[int], ByteString): def decode(self, encoding: str = ..., errors: str = ...) -> str: ... def endswith( self, - __suffix: Union[bytes, Tuple[bytes, ...]], + __suffix: bytes | Tuple[bytes, ...], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ..., ) -> bool: ... @@ -581,7 +581,7 @@ class bytearray(MutableSequence[int], ByteString): def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... def startswith( self, - __prefix: Union[bytes, Tuple[bytes, ...]], + __prefix: bytes | Tuple[bytes, ...], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ..., ) -> bool: ... @@ -607,7 +607,7 @@ class bytearray(MutableSequence[int], ByteString): @overload def __setitem__(self, i: int, x: int) -> None: ... @overload - def __setitem__(self, s: slice, x: Union[Iterable[int], bytes]) -> None: ... + def __setitem__(self, s: slice, x: Iterable[int] | bytes) -> None: ... def __delitem__(self, i: int | slice) -> None: ... def __add__(self, s: bytes) -> bytearray: ... def __iadd__(self, s: Iterable[int]) -> bytearray: ... @@ -643,7 +643,7 @@ class memoryview(Sized, Sequence[int]): def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> 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: int) -> int: ... @overload @@ -1053,8 +1053,8 @@ if sys.version_info >= (3, 10): ) -> 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: Union[type, Tuple[type | Tuple[Any, ...], ...]]) -> bool: ... + def issubclass(__cls: type, __class_or_tuple: Union[type, Tuple[type | Tuple[Any, ...], ...]]) -> bool: ... def len(__obj: Sized) -> int: ... def license() -> None: ... diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index c1d69a466f2e..7af052442709 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -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/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 8d78b035d48e..b9cf3441ed20 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -27,7 +27,7 @@ _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] = ..., @@ -37,7 +37,7 @@ if sys.version_info >= (3, 7): else: def namedtuple( typename: str, - field_names: Union[str, Iterable[str]], + field_names: str | Iterable[str], *, verbose: bool = ..., rename: bool = ..., @@ -119,7 +119,7 @@ class UserString(Sequence[str]): def encode(self: UserString, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> 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 endswith(self, suffix: str | Tuple[str, ...], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ... def expandtabs(self: _UserStringT, tabsize: int = ...) -> _UserStringT: ... def find(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ... def format(self, *args: Any, **kwds: Any) -> str: ... @@ -161,7 +161,7 @@ class UserString(Sequence[str]): def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... def rsplit(self, sep: Optional[str] = ..., 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 startswith(self, prefix: str | Tuple[str, ...], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ... def strip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ... def swapcase(self: _UserStringT) -> _UserStringT: ... def title(self: _UserStringT) -> _UserStringT: ... diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 8d9392c5739c..8bc5bbb775d7 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -104,7 +104,7 @@ 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(self, filenames: _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: ... diff --git a/stdlib/copyreg.pyi b/stdlib/copyreg.pyi index ea07ba410b6d..aa9fed854693 100644 --- a/stdlib/copyreg.pyi +++ b/stdlib/copyreg.pyi @@ -7,7 +7,7 @@ __all__: List[str] def pickle( ob_type: _TypeT, - pickle_function: Callable[[_TypeT], Union[str, _Reduce[_TypeT]]], + pickle_function: Callable[[_TypeT], str | _Reduce[_TypeT]], constructor_ob: Optional[Callable[[_Reduce[_TypeT]], _TypeT]] = ..., ) -> None: ... def constructor(object: Callable[[_Reduce[_TypeT]], _TypeT]) -> None: ... diff --git a/stdlib/distutils/ccompiler.pyi b/stdlib/distutils/ccompiler.pyi index 831311d2cb52..0e4adb4f27a9 100644 --- a/stdlib/distutils/ccompiler.pyi +++ b/stdlib/distutils/ccompiler.pyi @@ -36,7 +36,7 @@ class CCompiler: 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 detect_language(self, sources: str | List[str]) -> Optional[str]: ... def find_library_file(self, dirs: List[str], lib: str, debug: bool = ...) -> Optional[str]: ... def has_function( self, diff --git a/stdlib/distutils/cmd.pyi b/stdlib/distutils/cmd.pyi index 26bf3bf1b1a5..79f349db5074 100644 --- a/stdlib/distutils/cmd.pyi +++ b/stdlib/distutils/cmd.pyi @@ -14,7 +14,7 @@ class Command: 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_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: ... diff --git a/stdlib/distutils/command/config.pyi b/stdlib/distutils/command/config.pyi index 592de5e0cf5b..fc7a7b2f8f23 100644 --- a/stdlib/distutils/command/config.pyi +++ b/stdlib/distutils/command/config.pyi @@ -31,7 +31,7 @@ class config(Command): ) -> bool: ... def search_cpp( self, - pattern: Union[Pattern[str], str], + pattern: Pattern[str] | str, body: Optional[str] = ..., headers: Optional[Sequence[str]] = ..., include_dirs: Optional[Sequence[str]] = ..., diff --git a/stdlib/distutils/core.pyi b/stdlib/distutils/core.pyi index 9a3fa70fd381..47bb1048d3b7 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] = ..., diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index 80347c843209..8bf3be806427 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -14,9 +14,9 @@ class DistributionMetadata: 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]]] + keywords: Optional[str | List[str]] + platforms: Optional[str | List[str]] + classifiers: Optional[str | List[str]] download_url: Optional[str] provides: Optional[List[str]] requires: Optional[List[str]] @@ -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: ... diff --git a/stdlib/distutils/fancy_getopt.pyi b/stdlib/distutils/fancy_getopt.pyi index 00f2cd648aeb..9e2003454cd2 100644 --- a/stdlib/distutils/fancy_getopt.pyi +++ b/stdlib/distutils/fancy_getopt.pyi @@ -5,7 +5,7 @@ _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]: ... +) -> List[str] | _GR: ... def wrap_text(text: str, width: int) -> List[str]: ... class FancyGetopt: diff --git a/stdlib/distutils/filelist.pyi b/stdlib/distutils/filelist.pyi index 6bd392b7d616..ff4962441446 100644 --- a/stdlib/distutils/filelist.pyi +++ b/stdlib/distutils/filelist.pyi @@ -19,11 +19,11 @@ class FileList: self, pattern: str, anchor: int | bool = ..., prefix: Optional[str] = ..., 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]], + pattern: str | Pattern[str], anchor: int | bool = ..., prefix: Optional[str] = ..., is_regex: int | bool = ..., @@ -33,11 +33,11 @@ class FileList: self, pattern: str, anchor: int | bool = ..., prefix: Optional[str] = ..., 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]], + pattern: str | Pattern[str], anchor: int | bool = ..., prefix: Optional[str] = ..., is_regex: int | bool = ..., @@ -50,10 +50,10 @@ def translate_pattern( pattern: str, anchor: int | bool = ..., prefix: Optional[str] = ..., 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]], + pattern: str | Pattern[str], anchor: int | bool = ..., prefix: Optional[str] = ..., is_regex: int | bool = ..., diff --git a/stdlib/email/message.pyi b/stdlib/email/message.pyi index b215dda7df22..69a4cd15a6f2 100644 --- a/stdlib/email/message.pyi +++ b/stdlib/email/message.pyi @@ -35,7 +35,7 @@ class Message: def values(self) -> List[_HeaderType]: ... def items(self) -> List[Tuple[str, _HeaderType]]: ... def get(self, name: str, failobj: _T = ...) -> _HeaderType | _T: ... - def get_all(self, name: str, failobj: _T = ...) -> Union[List[_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: ... @@ -51,7 +51,7 @@ class Message: def get_boundary(self, failobj: _T = ...) -> _T | str: ... def set_boundary(self, boundary: str) -> None: ... def get_content_charset(self, failobj: _T = ...) -> _T | str: ... - def get_charsets(self, failobj: _T = ...) -> Union[_T, List[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: ... diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index fdddd12bf9a2..75d0e29283b2 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 diff --git a/stdlib/filecmp.pyi b/stdlib/filecmp.pyi index a56a4f7c9dcb..3b40ae34ff2a 100644 --- a/stdlib/filecmp.pyi +++ b/stdlib/filecmp.pyi @@ -10,8 +10,8 @@ DEFAULT_IGNORES: List[str] 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: int | bool = ..., ) -> Tuple[List[AnyStr], List[AnyStr], List[AnyStr]]: ... @@ -19,8 +19,8 @@ def cmpfiles( class dircmp(Generic[AnyStr]): def __init__( self, - a: Union[AnyStr, PathLike[AnyStr]], - b: Union[AnyStr, PathLike[AnyStr]], + a: AnyStr | PathLike[AnyStr], + b: AnyStr | PathLike[AnyStr], ignore: Optional[Sequence[AnyStr]] = ..., hide: Optional[Sequence[AnyStr]] = ..., ) -> None: ... diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index d4a492c0102e..6595bef43c12 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -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 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/http/cookies.pyi b/stdlib/http/cookies.pyi index 1fc2179ecfd6..750147083d85 100644 --- a/stdlib/http/cookies.pyi +++ b/stdlib/http/cookies.pyi @@ -1,7 +1,7 @@ import sys from typing import Any, Dict, Generic, Iterable, List, Mapping, Optional, Tuple, TypeVar, Union, overload -_DataType = Union[str, Mapping[str, Union[str, Morsel[Any]]]] +_DataType = Union[str, Mapping[str, str | Morsel[Any]]] _T = TypeVar("_T") @overload @@ -42,6 +42,6 @@ class BaseCookie(Dict[str, Morsel[_T]], Generic[_T]): def output(self, attrs: Optional[List[str]] = ..., header: str = ..., sep: str = ...) -> str: ... def js_output(self, attrs: Optional[List[str]] = ...) -> 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/imaplib.pyi b/stdlib/imaplib.pyi index 9d39c3fc5287..c458c6f4ccb4 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -11,7 +11,7 @@ from typing_extensions import Literal # E.g. Tuple[Literal["OK"], List[bytes]] _CommandResults = Tuple[str, List[Any]] -_AnyResponseData = Union[List[None], List[Union[bytes, Tuple[bytes, bytes]]]] +_AnyResponseData = Union[List[None], List[bytes | Tuple[bytes, bytes]]] class IMAP4: error: Type[Exception] = ... @@ -22,7 +22,7 @@ class IMAP4: state: str = ... literal: Optional[str] = ... tagged_commands: Dict[bytes, Optional[List[bytes]]] - untagged_responses: Dict[str, List[Union[bytes, Tuple[bytes, bytes]]]] + untagged_responses: Dict[str, List[bytes | Tuple[bytes, bytes]]] continuation_response: str = ... is_readonly: bool = ... tagnum: int = ... @@ -41,7 +41,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: ... diff --git a/stdlib/importlib/resources.pyi b/stdlib/importlib/resources.pyi index 10f15da519ec..ab9610afadce 100644 --- a/stdlib/importlib/resources.pyi +++ b/stdlib/importlib/resources.pyi @@ -9,7 +9,7 @@ if sys.version_info >= (3, 7): from typing import BinaryIO, ContextManager, Iterator, TextIO, Union Package = str | ModuleType - Resource = Union[str, os.PathLike[Any]] + Resource = str | os.PathLike[Any] def open_binary(package: Package, resource: Resource) -> BinaryIO: ... def open_text(package: Package, resource: Resource, encoding: str = ..., errors: str = ...) -> TextIO: ... def read_binary(package: Package, resource: Resource) -> bytes: ... diff --git a/stdlib/io.pyi b/stdlib/io.pyi index 76f276541d3a..9120001d9619 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -185,4 +185,4 @@ class IncrementalNewlineDecoder(codecs.IncrementalDecoder): def __init__(self, decoder: Optional[codecs.IncrementalDecoder], 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) -> Optional[str | Tuple[str, ...]]: ... diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index 215b5bc5b1ff..d6091898808a 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -24,7 +24,7 @@ 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]: ... diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 18d7cbfed24e..aba9bb2e217a 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -9,7 +9,7 @@ from typing import IO, Any, ClassVar, Optional, Pattern, Tuple, Type, Union _SysExcInfoType = Union[Tuple[Type[BaseException], BaseException, Optional[TracebackType]], Tuple[None, None, None]] _ExcInfoType = None | bool | _SysExcInfoType | BaseException -_ArgsType = Union[Tuple[Any, ...], Mapping[str, Any]] +_ArgsType = Tuple[Any, ...] | Mapping[str, Any] _FilterType = Union[Filter, Callable[[LogRecord], int]] _Level = int | str diff --git a/stdlib/logging/handlers.pyi b/stdlib/logging/handlers.pyi index 8a1f73f62db4..048cda390ef2 100644 --- a/stdlib/logging/handlers.pyi +++ b/stdlib/logging/handlers.pyi @@ -119,7 +119,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler): class SocketHandler(Handler): host: str # undocumented port: Optional[int] # undocumented - address: Union[tuple[str, int], str] # undocumented + address: tuple[str, int] | str # undocumented sock: Optional[socket] # undocumented closeOnError: bool # undocumented retryTime: Optional[float] # undocumented @@ -181,7 +181,7 @@ 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: Optional[SocketKind] = ... ) -> None: ... def encodePriority(self, facility: int | str, priority: int | str) -> int: ... def mapPriority(self, levelName: str) -> str: ... @@ -206,9 +206,9 @@ class SMTPHandler(Handler): 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] = ..., @@ -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 86664ee3d66a..5916767403c2 100644 --- a/stdlib/lzma.pyi +++ b/stdlib/lzma.pyi @@ -6,7 +6,7 @@ from typing_extensions import Literal _OpenBinaryWritingMode = Literal["w", "wb", "x", "xb", "a", "ab"] _OpenTextWritingMode = Literal["wt", "xt", "at"] -_PathOrFile = Union[StrOrBytesPath, IO[bytes]] +_PathOrFile = StrOrBytesPath | IO[bytes] _FilterChain = Sequence[Mapping[str, Any]] _T = TypeVar("_T") diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index 87349050c339..6bb4cfb45171 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -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_: Optional[bool | Tuple[int, int, int, int, int, int, int, int, int]] = ... ) -> None: ... def get_flags(self) -> str: ... def set_flags(self, flags: Iterable[str]) -> None: ... diff --git a/stdlib/msilib/__init__.pyi b/stdlib/msilib/__init__.pyi index 0442ffaaec83..2d482424c55d 100644 --- a/stdlib/msilib/__init__.pyi +++ b/stdlib/msilib/__init__.pyi @@ -34,8 +34,8 @@ if sys.platform == "win32": def change_sequence( seq: Sequence[Tuple[str, Optional[str], 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: ... diff --git a/stdlib/multiprocessing/connection.pyi b/stdlib/multiprocessing/connection.pyi index b13062218230..3131a998f864 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -7,7 +7,7 @@ if sys.version_info >= (3, 8): from typing import SupportsIndex # https://docs.python.org/3/library/multiprocessing.html#address-formats -_Address = Union[str, Tuple[str, int]] +_Address = str | Tuple[str, int] class _ConnectionBase: if sys.version_info >= (3, 8): diff --git a/stdlib/multiprocessing/context.pyi b/stdlib/multiprocessing/context.pyi index 2df089841ebb..5cc6c1e9fe34 100644 --- a/stdlib/multiprocessing/context.pyi +++ b/stdlib/multiprocessing/context.pyi @@ -63,38 +63,38 @@ class BaseContext(object): @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: 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: bool | _LockLike = ..., ) -> Any: ... diff --git a/stdlib/multiprocessing/dummy/connection.pyi b/stdlib/multiprocessing/dummy/connection.pyi index 01733e59c763..032018da7bce 100644 --- a/stdlib/multiprocessing/dummy/connection.pyi +++ b/stdlib/multiprocessing/dummy/connection.pyi @@ -6,7 +6,7 @@ families: List[None] _ConnectionT = TypeVar("_ConnectionT", bound=Connection) _ListenerT = TypeVar("_ListenerT", bound=Listener) -_Address = Union[str, Tuple[str, int]] +_Address = str | Tuple[str, int] class Connection(object): _in: Any diff --git a/stdlib/multiprocessing/sharedctypes.pyi b/stdlib/multiprocessing/sharedctypes.pyi index f6785e0880c3..5684253407c5 100644 --- a/stdlib/multiprocessing/sharedctypes.pyi +++ b/stdlib/multiprocessing/sharedctypes.pyi @@ -14,27 +14,27 @@ 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: ... @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: Optional[BaseContext] = ... ) -> 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: Optional[BaseContext] = ... ) -> SynchronizedBase[Any]: ... @overload def Value( - typecode_or_type: Union[str, Type[_CData]], *args: Any, lock: bool | _LockLike = ..., ctx: Optional[BaseContext] = ... + typecode_or_type: str | Type[_CData], *args: Any, lock: bool | _LockLike = ..., ctx: Optional[BaseContext] = ... ) -> 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] = ..., @@ -42,23 +42,23 @@ def Array( @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], + lock: Literal[True] | _LockLike, ctx: Optional[BaseContext] = ..., ) -> 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], + lock: Literal[True] | _LockLike, ctx: Optional[BaseContext] = ..., ) -> 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: bool | _LockLike = ..., ctx: Optional[BaseContext] = ..., diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index 00e83e9452aa..009077d09d6c 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -78,8 +78,8 @@ class _NNTPBase: 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: ... diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index e409fbaefdd0..b23bba2db3d6 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -630,7 +630,7 @@ if sys.platform != "win32": def makedev(__major: int, __minor: int) -> int: ... def pathconf(path: _FdOrAnyPath, name: str | int) -> int: ... # Unix only -def readlink(path: Union[AnyStr, PathLike[AnyStr]], *, dir_fd: Optional[int] = ...) -> AnyStr: ... +def readlink(path: AnyStr | PathLike[AnyStr], *, dir_fd: Optional[int] = ...) -> AnyStr: ... def remove(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ... def removedirs(name: StrOrBytesPath) -> None: ... def rename( @@ -652,13 +652,13 @@ 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: ... @@ -682,7 +682,7 @@ def truncate(path: _FdOrAnyPath, length: int) -> None: ... # Unix only up to ve def unlink(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ... def utime( path: _FdOrAnyPath, - times: Optional[Union[Tuple[int, int], Tuple[float, float]]] = ..., + times: Optional[Tuple[int, int] | Tuple[float, float]] = ..., *, ns: Tuple[int, int] = ..., dir_fd: Optional[int] = ..., @@ -692,7 +692,7 @@ def utime( _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: Optional[_OnError] = ..., followlinks: bool = ... ) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... if sys.platform != "win32": @@ -753,11 +753,11 @@ _ExecVArgs = Union[ List[str], List[PathLike[Any]], List[bytes | str], - List[Union[bytes, PathLike[Any]]], - List[Union[str, PathLike[Any]]], + List[bytes | PathLike[Any]], + List[str | PathLike[Any]], List[Union[bytes, str, PathLike[Any]]], ] -_ExecEnv = Union[Mapping[bytes, bytes | str], Mapping[str, bytes | str]] +_ExecEnv = Mapping[bytes, bytes | str] | Mapping[str, bytes | str] def execv(__path: StrOrBytesPath, __argv: _ExecVArgs) -> NoReturn: ... def execve(path: _FdOrAnyPath, argv: _ExecVArgs, env: _ExecEnv) -> NoReturn: ... diff --git a/stdlib/pdb.pyi b/stdlib/pdb.pyi index ac25b368d6c6..b42fa0cc5410 100644 --- a/stdlib/pdb.pyi +++ b/stdlib/pdb.pyi @@ -62,7 +62,7 @@ class Pdb(Bdb, Cmd): def displayhook(self, obj: object) -> None: ... def handle_command_def(self, line: str) -> bool: ... def defaultFile(self) -> str: ... - def lineinfo(self, identifier: str) -> 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: ... diff --git a/stdlib/pickletools.pyi b/stdlib/pickletools.pyi index 8638485f776b..7f75336ebd3e 100644 --- a/stdlib/pickletools.pyi +++ b/stdlib/pickletools.pyi @@ -152,10 +152,10 @@ 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, Optional[Any], Optional[int]]]: ... +def optimize(p: bytes | IO[bytes]) -> bytes: ... def dis( - pickle: Union[bytes, IO[bytes]], + pickle: bytes | IO[bytes], out: Optional[IO[str]] = ..., memo: Optional[MutableMapping[int, Any]] = ..., indentlevel: int = ..., diff --git a/stdlib/plistlib.pyi b/stdlib/plistlib.pyi index c74d0d8d5951..e42c2aebf74c 100644 --- a/stdlib/plistlib.pyi +++ b/stdlib/plistlib.pyi @@ -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/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/pydoc.pyi b/stdlib/pydoc.pyi index d1d30f4a0170..1abfb8b51b50 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -216,9 +216,9 @@ def writedoc(thing: str | object, forceload: bool = ...) -> None: ... def writedocs(dir: str, pkgpath: str = ..., done: Optional[Any] = ...) -> 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, ...]]] + topics: Dict[str, str | Tuple[str, ...]] def __init__(self, input: Optional[IO[str]] = ..., output: Optional[IO[str]] = ...) -> None: ... input: IO[str] output: IO[str] diff --git a/stdlib/random.pyi b/stdlib/random.pyi index ea3801ed11cd..62463ca47570 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -27,10 +27,10 @@ class Random(_random.Random): def shuffle(self, x: MutableSequence[Any], random: Optional[Callable[[], float]] = ...) -> 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: Optional[Iterable[_T]] = ... ) -> 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: ... @@ -71,10 +71,10 @@ def choices( def shuffle(x: MutableSequence[Any], random: Optional[Callable[[], float]] = ...) -> 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: Optional[Iterable[_T]] = ...) -> 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: ... diff --git a/stdlib/re.pyi b/stdlib/re.pyi index 6a651eca6641..f8e6b3fe4c9a 100644 --- a/stdlib/re.pyi +++ b/stdlib/re.pyi @@ -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/shutil.pyi b/stdlib/shutil.pyi index 53f907b97a77..6d701d9bd248 100644 --- a/stdlib/shutil.pyi +++ b/stdlib/shutil.pyi @@ -89,7 +89,7 @@ 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: Optional[Sequence[Tuple[str, Any] | List[Any]]] = ..., description: str = ..., ) -> None: ... def unregister_archive_format(name: str) -> None: ... diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index 787d3707f200..ffade0b70051 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -23,7 +23,7 @@ class SMTPServerDisconnected(SMTPException): ... class SMTPResponseException(SMTPException): smtp_code: int smtp_error: bytes | str - args: Union[Tuple[int, bytes | str], Tuple[int, bytes, str]] + args: Tuple[int, bytes | str] | Tuple[int, bytes, str] def __init__(self, code: int, msg: bytes | str) -> None: ... class SMTPSenderRefused(SMTPResponseException): @@ -114,7 +114,7 @@ class SMTP: def sendmail( self, from_addr: str, - to_addrs: Union[str, Sequence[str]], + to_addrs: str | Sequence[str], msg: bytes | str, mail_options: Sequence[str] = ..., rcpt_options: Sequence[str] = ..., @@ -123,7 +123,7 @@ class SMTP: self, msg: _Message, from_addr: Optional[str] = ..., - to_addrs: Optional[Union[str, Sequence[str]]] = ..., + to_addrs: Optional[str | Sequence[str]] = ..., mail_options: Sequence[str] = ..., rcpt_options: Sequence[str] = ..., ) -> _SendErrs: ... diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index a2f54d8f4a42..06adfc85d171 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -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]: ... @@ -630,4 +630,4 @@ def getaddrinfo( 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 932f4607d5f4..cb0c45db281f 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -4,8 +4,8 @@ from socket import socket as _socket from typing import Any, BinaryIO, Callable, ClassVar, Optional, Set, Tuple, Type, TypeVar, Union _T = TypeVar("_T") -_RequestType = Union[_socket, Tuple[bytes, _socket]] -_AddressType = Union[Tuple[str, int], str] +_RequestType = _socket | Tuple[bytes, _socket] +_AddressType = Tuple[str, int] | str class BaseServer: address_family: int diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index 0ebc0460c3ab..d0e0dff855fb 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -9,7 +9,7 @@ _PCTRTT = Tuple[Tuple[str, str], ...] _PCTRTTT = Tuple[_PCTRTT, ...] _PeerCertRetDictType = Dict[str, str | _PCTRTTT | _PCTRTT] _PeerCertRetType = _PeerCertRetDictType | bytes | None -_EnumRetType = List[Tuple[bytes, str, Union[Set[str], bool]]] +_EnumRetType = List[Tuple[bytes, str, Set[str] | bool]] _PasswordType = Union[Callable[[], str | bytes], str, bytes] _SrvnmeCbType = Callable[[SSLSocket | SSLObject, Optional[str], SSLSocket], Optional[int]] @@ -310,7 +310,7 @@ class SSLContext: def load_verify_locations( self, cafile: Optional[StrPath] = ..., capath: Optional[StrPath] = ..., 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 set_default_verify_paths(self) -> None: ... def set_ciphers(self, __cipherlist: str) -> None: ... def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 953e23125461..0bab898ce0fd 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -24,15 +24,15 @@ if sys.version_info >= (3, 9): _FILE = Union[None, int, IO[Any]] _TXT = bytes | str if sys.version_info >= (3, 8): - _CMD = Union[StrOrBytesPath, Sequence[StrOrBytesPath]] + _CMD = StrOrBytesPath | Sequence[StrOrBytesPath] else: # Python 3.6 doesn't support _CMD being a single PathLike. # See: https://bugs.python.org/issue31961 - _CMD = Union[_TXT, Sequence[StrOrBytesPath]] + _CMD = _TXT | Sequence[StrOrBytesPath] if sys.platform == "win32": _ENV = Mapping[str, str] else: - _ENV = Union[Mapping[bytes, StrOrBytesPath], Mapping[str, StrOrBytesPath]] + _ENV = Mapping[bytes, StrOrBytesPath] | Mapping[str, StrOrBytesPath] _S = TypeVar("_S") _T = TypeVar("_T") diff --git a/stdlib/sunau.pyi b/stdlib/sunau.pyi index 79d0881c96c2..bbd487edab88 100644 --- a/stdlib/sunau.pyi +++ b/stdlib/sunau.pyi @@ -1,7 +1,7 @@ import sys from typing import IO, Any, NamedTuple, NoReturn, Optional, Union -_File = Union[str, IO[bytes]] +_File = str | IO[bytes] class Error(Exception): ... diff --git a/stdlib/sys.pyi b/stdlib/sys.pyi index c11605a9c1c0..5e48ad91b01c 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -26,7 +26,7 @@ _T = TypeVar("_T") # The following type alias are stub-only and do not exist during runtime _ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType] -_OptExcInfo = Union[_ExcInfo, Tuple[None, None, None]] +_OptExcInfo = _ExcInfo | Tuple[None, None, None] _PathSequence = Sequence[bytes | str] # Unlike importlib.abc.MetaPathFinder, invalidate_caches() might not exist (see python docs) diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index c18ec18ce454..ede3ead5d8a2 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -298,7 +298,7 @@ class TarFile: 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: ... diff --git a/stdlib/telnetlib.pyi b/stdlib/telnetlib.pyi index 0ee5b760b184..0a0343caae98 100644 --- a/stdlib/telnetlib.pyi +++ b/stdlib/telnetlib.pyi @@ -107,7 +107,7 @@ class Telnet: def mt_interact(self) -> None: ... def listener(self) -> None: ... def expect( - self, list: Sequence[Union[Pattern[bytes], bytes]], timeout: Optional[float] = ... + self, list: Sequence[Pattern[bytes] | bytes], timeout: Optional[float] = ... ) -> Tuple[int, Optional[Match[bytes]], bytes]: ... def __enter__(self) -> Telnet: ... def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index f618ce1751d2..44850b2f5911 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -13,7 +13,7 @@ tempdir: Optional[str] template: str _S = TypeVar("_S") -_DirT = Union[AnyStr, os.PathLike[AnyStr]] +_DirT = AnyStr | os.PathLike[AnyStr] if sys.version_info >= (3, 8): @overload diff --git a/stdlib/termios.pyi b/stdlib/termios.pyi index 90dd8db9d318..86da7243817d 100644 --- a/stdlib/termios.pyi +++ b/stdlib/termios.pyi @@ -1,7 +1,7 @@ from _typeshed import FileDescriptorLike from typing import Any, List, Union -_Attr = List[Union[int, List[bytes | int]]] +_Attr = List[int | List[bytes | int]] # TODO constants not really documented B0: int diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 049c83116e78..cdf280355ef0 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 @@ -97,7 +97,7 @@ EXCEPTION = _tkinter.EXCEPTION # ... # _tkinter.TclError: unknown font style "deque(['bold'])" _T = TypeVar("_T") -_TkinterSequence = Union[List[_T], Tuple[_T, ...]] +_TkinterSequence = List[_T] | Tuple[_T, ...] _TkinterSequence2D = Union[List[List[_T]], List[Tuple[_T, ...]], Tuple[List[_T], ...], Tuple[Tuple[_T, ...], ...]] # Some widgets have an option named -compound that accepts different values @@ -266,7 +266,7 @@ class Misc: @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: ... @@ -686,8 +686,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 @@ -706,8 +706,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: ... @@ -775,8 +775,8 @@ 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: @@ -790,8 +790,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 @@ -856,7 +856,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 = ..., @@ -871,7 +871,7 @@ 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 @@ -1027,7 +1027,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 = ..., @@ -1064,7 +1064,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 = ..., @@ -1134,7 +1134,7 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: Union[str, Tuple[str, ...]] = ..., + tags: str | Tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... def create_oval( @@ -1165,7 +1165,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: Union[str, Tuple[str, ...]] = ..., + tags: str | Tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... def create_polygon( @@ -1199,7 +1199,7 @@ class Canvas(Widget, XView, YView): splinesteps: float = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: Union[str, Tuple[str, ...]] = ..., + tags: str | Tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... def create_rectangle( @@ -1230,7 +1230,7 @@ class Canvas(Widget, XView, YView): outlinestipple: _Bitmap = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: Union[str, Tuple[str, ...]] = ..., + tags: str | Tuple[str, ...] = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... def create_text( @@ -1249,7 +1249,7 @@ class Canvas(Widget, XView, YView): offset: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., stipple: _Bitmap = ..., - tags: Union[str, Tuple[str, ...]] = ..., + tags: str | Tuple[str, ...] = ..., text: float | str = ..., width: _ScreenUnits = ..., ) -> _CanvasItemId: ... @@ -1261,7 +1261,7 @@ class Canvas(Widget, XView, YView): anchor: _Anchor = ..., height: _ScreenUnits = ..., state: Literal["normal", "active", "disabled"] = ..., - tags: Union[str, Tuple[str, ...]] = ..., + tags: str | Tuple[str, ...] = ..., width: _ScreenUnits = ..., window: Widget = ..., ) -> _CanvasItemId: ... @@ -1289,7 +1289,7 @@ class Canvas(Widget, XView, YView): def move(self, *args): ... if sys.version_info >= (3, 8): def moveto( - self, tagOrId: 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): ... def tag_raise(self, *args): ... @@ -1360,7 +1360,7 @@ class Checkbutton(Widget): tristateimage: _ImageSpec = ..., tristatevalue: Any = ..., underline: int = ..., - variable: Union[Variable, Literal[""]] = ..., + variable: Variable | Literal[""] = ..., width: _ScreenUnits = ..., wraplength: _ScreenUnits = ..., ) -> None: ... @@ -1408,7 +1408,7 @@ class Checkbutton(Widget): 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]]]: ... @@ -1544,7 +1544,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 = ..., @@ -1556,7 +1556,7 @@ class Frame(Widget): pady: _ScreenUnits = ..., relief: _Relief = ..., takefocus: _TakeFocusValue = ..., - visual: Union[str, Tuple[str, int]] = ..., + visual: str | Tuple[str, int] = ..., width: _ScreenUnits = ..., ) -> None: ... @overload @@ -2241,7 +2241,7 @@ class Radiobutton(Widget): tristatevalue: Any = ..., underline: int = ..., value: Any = ..., - variable: Union[Variable, Literal[""]] = ..., + variable: Variable | Literal[""] = ..., width: _ScreenUnits = ..., wraplength: _ScreenUnits = ..., ) -> None: ... @@ -2288,7 +2288,7 @@ class Radiobutton(Widget): 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]]]: ... @@ -2477,7 +2477,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 = ..., @@ -2508,7 +2508,7 @@ 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[_ScreenUnits | str, ...]] = ..., @@ -2533,7 +2533,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 = ..., @@ -2560,7 +2560,7 @@ 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[_ScreenUnits | str, ...]] = ..., tabstyle: Literal["tabular", "wordprocessor"] = ..., @@ -2641,7 +2641,7 @@ class Text(Widget, XView, YView): def image_create(self, index, cnf=..., **kw): ... def image_names(self): ... def index(self, index: _TextIndex) -> str: ... - def insert(self, index: _TextIndex, chars: str, *args: 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 @@ -2654,7 +2654,7 @@ class Text(Widget, XView, YView): # **kw of peer_create is same as the kwargs of Text.__init__ def peer_create(self, newPathName: str | Text, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def peer_names(self) -> Tuple[_tkinter.Tcl_Obj, ...]: ... - def replace(self, index1: _TextIndex, index2: _TextIndex, chars: str, *args: 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( @@ -2725,10 +2725,10 @@ class Text(Widget, XView, YView): def tag_names(self, index: Optional[_TextIndex] = ...) -> Tuple[str, ...]: ... def tag_nextrange( self, tagName: str, index1: _TextIndex, index2: Optional[_TextIndex] = ... - ) -> Union[Tuple[str, str], Tuple[()]]: ... + ) -> Tuple[str, str] | Tuple[()]: ... def tag_prevrange( self, tagName: str, index1: _TextIndex, index2: Optional[_TextIndex] = ... - ) -> Union[Tuple[str, str], Tuple[()]]: ... + ) -> Tuple[str, str] | Tuple[()]: ... def tag_raise(self, tagName: str, aboveThis: Optional[str] = ...) -> None: ... def tag_ranges(self, tagName: str) -> Tuple[_tkinter.Tcl_Obj, ...]: ... # tag_remove and tag_delete are different @@ -2813,8 +2813,8 @@ 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]] = ... @@ -2995,7 +2995,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 = ..., @@ -3014,7 +3014,7 @@ class LabelFrame(Widget): relief: _Relief = ..., takefocus: _TakeFocusValue = ..., text: float | str = ..., - visual: Union[str, Tuple[str, int]] = ..., + visual: str | Tuple[str, int] = ..., width: _ScreenUnits = ..., ) -> None: ... @overload diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index ad646fd1c58c..167641661754 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -52,7 +52,7 @@ class Button(Widget): text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., - width: Union[int, Literal[""]] = ..., + width: int | Literal[""] = ..., ) -> None: ... @overload def configure( @@ -71,7 +71,7 @@ class Button(Widget): text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., - width: Union[int, Literal[""]] = ..., + width: int | Literal[""] = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... @@ -102,7 +102,7 @@ class Checkbutton(Widget): # 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( @@ -123,7 +123,7 @@ class Checkbutton(Widget): textvariable: tkinter.Variable = ..., underline: int = ..., variable: tkinter.Variable = ..., - width: Union[int, Literal[""]] = ..., + width: int | Literal[""] = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... @@ -354,7 +354,7 @@ class Label(Widget): text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., - width: Union[int, Literal[""]] = ..., + width: int | Literal[""] = ..., wraplength: tkinter._ScreenUnits = ..., ) -> None: ... @overload @@ -380,7 +380,7 @@ class Label(Widget): 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]]]: ... @overload @@ -452,7 +452,7 @@ class Menubutton(Widget): text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., - width: Union[int, Literal[""]] = ..., + width: int | Literal[""] = ..., ) -> None: ... @overload def configure( @@ -471,7 +471,7 @@ class Menubutton(Widget): text: float | str = ..., textvariable: tkinter.Variable = ..., underline: int = ..., - width: Union[int, Literal[""]] = ..., + width: int | Literal[""] = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... @@ -626,8 +626,8 @@ class Radiobutton(Widget): 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( @@ -646,8 +646,8 @@ class Radiobutton(Widget): textvariable: tkinter.Variable = ..., underline: int = ..., value: Any = ..., - variable: Union[tkinter.Variable, Literal[""]] = ..., - width: Union[int, Literal[""]] = ..., + variable: tkinter.Variable | Literal[""] = ..., + width: int | Literal[""] = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... @@ -877,7 +877,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): master: Optional[tkinter.Misc] = ..., *, 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"]] = ..., height: int = ..., @@ -888,7 +888,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 = ..., @@ -899,13 +899,13 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): self, cnf: Optional[Dict[str, Any]] = ..., *, - 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"]] = ..., 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 = ..., @@ -970,7 +970,7 @@ class LabeledScale(Frame): 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 diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index a5ecc304de7c..15e6a988cc32 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -41,7 +41,7 @@ class TokenInfo(_TokenInfo): def exact_type(self) -> int: ... # Backwards compatible tokens can be sequences of a shorter length too -_Token = Union[TokenInfo, Sequence[int | str | _Position]] +_Token = TokenInfo | Sequence[int | str | _Position] class TokenError(Exception): ... class StopTokenizing(Exception): ... # undocumented diff --git a/stdlib/tty.pyi b/stdlib/tty.pyi index c0dc418e9933..47132006edeb 100644 --- a/stdlib/tty.pyi +++ b/stdlib/tty.pyi @@ -1,6 +1,6 @@ from typing import IO, Union -_FD = Union[int, IO[str]] +_FD = int | IO[str] # XXX: Undocumented integer constants IFLAG: int diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index 74aa12a60f18..da4ba1ca15e3 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -5,7 +5,7 @@ from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, TypeVar # alias we use for return types. Really, these two aliases should be the # same, but as per the "no union returns" typeshed policy, we'll return # Any instead. -_Color = Union[str, Tuple[float, float, float]] +_Color = str | Tuple[float, float, float] _AnyColor = Any # TODO: Replace this with a TypedDict once it becomes standardized. @@ -121,11 +121,11 @@ 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: ... @@ -252,7 +252,7 @@ class RawTurtle(TPen, TNavigator): # a compound stamp or not. So, as per the "no Union return" policy, # we return Any. def stamp(self) -> Any: ... - def clearstamp(self, stampid: Union[int, Tuple[int, ...]]) -> None: ... + def clearstamp(self, stampid: int | Tuple[int, ...]) -> None: ... def clearstamps(self, n: Optional[int] = ...) -> None: ... def filling(self) -> bool: ... def begin_fill(self) -> None: ... @@ -395,11 +395,11 @@ 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: ... @@ -521,7 +521,7 @@ def tilt(angle: float) -> None: ... # a compound stamp or not. So, as per the "no Union return" policy, # we return Any. def stamp() -> Any: ... -def clearstamp(stampid: Union[int, Tuple[int, ...]]) -> None: ... +def clearstamp(stampid: int | Tuple[int, ...]) -> None: ... def clearstamps(n: Optional[int] = ...) -> None: ... def filling() -> bool: ... def begin_fill() -> None: ... diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 2df93a19a7fe..0be8985f8b51 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -388,12 +388,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 diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index d7ef04c27314..d29a1c460fbe 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -73,10 +73,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: ... @@ -168,8 +168,8 @@ class TestCase: msg: Any = ..., delta: Optional[datetime.timedelta] = ..., ) -> 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: ... @@ -221,8 +221,8 @@ class TestCase: 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, diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 1dbebb26a00a..c37480c116e1 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -148,26 +148,26 @@ class ProxyHandler(BaseHandler): # 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 add_password(self, realm: str, uri: str | Sequence[str], user: str, passwd: str) -> None: ... def find_user_password(self, realm: str, authuri: str) -> Tuple[Optional[str], Optional[str]]: ... 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 add_password(self, realm: Optional[str], uri: str | Sequence[str], user: str, passwd: str) -> None: ... def find_user_password(self, realm: Optional[str], authuri: str) -> Tuple[Optional[str], Optional[str]]: ... class HTTPPasswordMgrWithPriorAuth(HTTPPasswordMgrWithDefaultRealm): def add_password( - self, realm: Optional[str], uri: Union[str, Sequence[str]], user: str, passwd: str, is_authenticated: bool = ... + self, realm: Optional[str], 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] + add_password: Callable[[str, str | Sequence[str], str, str], None] def __init__(self, password_mgr: Optional[HTTPPasswordMgr] = ...) -> None: ... def http_error_auth_reqed(self, authreq: str, host: str, req: Request, headers: Mapping[str, str]) -> None: ... def http_request(self, req: Request) -> Request: ... # undocumented diff --git a/stdlib/wave.pyi b/stdlib/wave.pyi index 61f9136ea334..36db3203ea88 100644 --- a/stdlib/wave.pyi +++ b/stdlib/wave.pyi @@ -1,7 +1,7 @@ import sys from typing import IO, Any, BinaryIO, NamedTuple, NoReturn, Optional, Union -_File = Union[str, IO[bytes]] +_File = str | IO[bytes] class Error(Exception): ... diff --git a/stdlib/webbrowser.pyi b/stdlib/webbrowser.pyi index bb543e2f2273..2131ca479646 100644 --- a/stdlib/webbrowser.pyi +++ b/stdlib/webbrowser.pyi @@ -31,7 +31,7 @@ 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): diff --git a/stdlib/xml/dom/minidom.pyi b/stdlib/xml/dom/minidom.pyi index 168b76d40f68..d31dc70f146f 100644 --- a/stdlib/xml/dom/minidom.pyi +++ b/stdlib/xml/dom/minidom.pyi @@ -6,7 +6,7 @@ from xml.sax.xmlreader import XMLReader _T = TypeVar("_T") -def parse(file: Union[str, IO[Any]], parser: Optional[XMLReader] = ..., bufsize: Optional[int] = ...): ... +def parse(file: str | IO[Any], parser: Optional[XMLReader] = ..., bufsize: Optional[int] = ...): ... def parseString(string: str | bytes, parser: Optional[XMLReader] = ...): ... def getDOMImplementation(features=...): ... diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index 10bbe9919963..70176aed4d4f 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -67,7 +67,7 @@ class Element(MutableSequence[Element]): 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: ... + 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: ... diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index ae4a934c39ea..0321ba56d8b1 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -104,7 +104,7 @@ class Marshaller: encoding: Optional[str] allow_none: bool def __init__(self, encoding: Optional[str] = ..., allow_none: bool = ...) -> None: ... - def dumps(self, values: Union[Fault, Iterable[_Marshallable]]) -> str: ... + def dumps(self, values: Fault | Iterable[_Marshallable]) -> str: ... def __dump(self, value: Union[_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: ... @@ -186,7 +186,7 @@ FastUnmarshaller: Optional[Unmarshaller] def getparser(use_datetime: bool = ..., use_builtin_types: bool = ...) -> Tuple[ExpatParser, Unmarshaller]: ... def dumps( - params: Union[Fault, Tuple[_Marshallable, ...]], + params: Fault | Tuple[_Marshallable, ...], methodname: Optional[str] = ..., methodresponse: Optional[bool] = ..., encoding: Optional[str] = ..., diff --git a/stdlib/xmlrpc/server.pyi b/stdlib/xmlrpc/server.pyi index a4497fe68b35..abc5b491c758 100644 --- a/stdlib/xmlrpc/server.pyi +++ b/stdlib/xmlrpc/server.pyi @@ -57,7 +57,7 @@ class SimpleXMLRPCDispatcher: # undocumented self, data: str, dispatch_method: Optional[ - Callable[[Optional[str], Tuple[_Marshallable, ...]], Union[Fault, Tuple[_Marshallable, ...]]] + Callable[[Optional[str], Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] ] = ..., path: Optional[Any] = ..., ) -> str: ... # undocumented @@ -115,7 +115,7 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented self, data: str, dispatch_method: Optional[ - Callable[[Optional[str], Tuple[_Marshallable, ...]], Union[Fault, Tuple[_Marshallable, ...]]] + Callable[[Optional[str], Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] ] = ..., path: Optional[Any] = ..., ) -> str: ... diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index 51a1327ed1dd..c178e3da849f 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -107,7 +107,7 @@ class ZipFile: if sys.version_info >= (3, 8): def __init__( self, - file: Union[StrPath, IO[bytes]], + file: StrPath | IO[bytes], mode: str = ..., compression: int = ..., allowZip64: bool = ..., @@ -118,7 +118,7 @@ class ZipFile: elif sys.version_info >= (3, 7): def __init__( self, - file: Union[StrPath, IO[bytes]], + file: StrPath | IO[bytes], mode: str = ..., compression: int = ..., allowZip64: bool = ..., @@ -126,7 +126,7 @@ class ZipFile: ) -> 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) -> ZipFile: ... def __exit__( @@ -172,7 +172,7 @@ class ZipFile: 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: ... @@ -235,7 +235,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/zlib.pyi b/stdlib/zlib.pyi index c0443c5d8c60..ffcfeaccac5e 100644 --- a/stdlib/zlib.pyi +++ b/stdlib/zlib.pyi @@ -40,6 +40,6 @@ def compress(__data: bytes, level: int = ...) -> bytes: ... def compressobj( level: int = ..., method: int = ..., wbits: int = ..., memLevel: int = ..., strategy: int = ..., zdict: Optional[bytes] = ... ) -> _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: ... From 73111c69a71953cc9a4a8a865983f345064252d0 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:41:52 -0700 Subject: [PATCH 05/16] fastmod -d stdlib --accept-all '\bUnion\[([\w\.]+)(\[[^\[\]]+\])?, ([\w\.]+)(\[[^\[\]]+\])?, ([\w\.]+)(\[[^\[\]]+\])?\]' '$1$2 | $3$4 | $5$6' --- stdlib/@python2/_csv.pyi | 2 +- stdlib/@python2/argparse.pyi | 2 +- stdlib/@python2/cgi.pyi | 2 +- stdlib/@python2/collections.pyi | 2 +- stdlib/@python2/decimal.pyi | 4 ++-- stdlib/@python2/dircache.pyi | 2 +- stdlib/@python2/distutils/cmd.pyi | 2 +- stdlib/@python2/distutils/text_file.pyi | 2 +- stdlib/@python2/fileinput.pyi | 4 ++-- stdlib/@python2/locale.pyi | 4 ++-- stdlib/@python2/logging/handlers.pyi | 2 +- stdlib/@python2/pyclbr.pyi | 2 +- stdlib/@python2/subprocess.pyi | 2 +- stdlib/@python2/typing_extensions.pyi | 2 +- stdlib/@python2/unittest.pyi | 2 +- stdlib/@python2/xml/etree/ElementTree.pyi | 2 +- stdlib/@python2/xml/sax/__init__.pyi | 2 +- stdlib/_csv.pyi | 2 +- stdlib/argparse.pyi | 2 +- stdlib/ast.pyi | 4 ++-- stdlib/asyncio/base_events.pyi | 12 +++++------ stdlib/asyncio/base_subprocess.pyi | 4 ++-- stdlib/asyncio/events.pyi | 12 +++++------ stdlib/asyncio/subprocess.pyi | 24 ++++++++++----------- stdlib/asyncio/tasks.pyi | 2 +- stdlib/asyncio/trsock.pyi | 4 ++-- stdlib/builtins.pyi | 10 ++++----- stdlib/cgi.pyi | 2 +- stdlib/collections/__init__.pyi | 2 +- stdlib/decimal.pyi | 4 ++-- stdlib/distutils/cmd.pyi | 2 +- stdlib/distutils/text_file.pyi | 2 +- stdlib/email/message.pyi | 2 +- stdlib/fcntl.pyi | 2 +- stdlib/fileinput.pyi | 12 +++++------ stdlib/inspect.pyi | 2 +- stdlib/io.pyi | 2 +- stdlib/locale.pyi | 4 ++-- stdlib/logging/config.pyi | 4 ++-- stdlib/os/__init__.pyi | 2 +- stdlib/pyclbr.pyi | 2 +- stdlib/subprocess.pyi | 2 +- stdlib/tkinter/__init__.pyi | 26 +++++++++++------------ stdlib/tkinter/font.pyi | 2 +- stdlib/typing.pyi | 4 ++-- stdlib/typing_extensions.pyi | 2 +- stdlib/unittest/main.pyi | 4 ++-- stdlib/xml/etree/ElementTree.pyi | 2 +- stdlib/xml/sax/__init__.pyi | 2 +- stdlib/zipfile.pyi | 2 +- stdlib/zipimport.pyi | 2 +- 51 files changed, 104 insertions(+), 104 deletions(-) diff --git a/stdlib/@python2/_csv.pyi b/stdlib/@python2/_csv.pyi index e194cc625889..53a18531d518 100644 --- a/stdlib/@python2/_csv.pyi +++ b/stdlib/@python2/_csv.pyi @@ -18,7 +18,7 @@ class Dialect: strict: int def __init__(self) -> None: ... -_DialectLike = Union[str, Dialect, Type[Dialect]] +_DialectLike = str | Dialect | Type[Dialect] class _reader(Iterator[List[str]]): dialect: Dialect diff --git a/stdlib/@python2/argparse.pyi b/stdlib/@python2/argparse.pyi index c3ebc49e8120..33196452f5f9 100644 --- a/stdlib/@python2/argparse.pyi +++ b/stdlib/@python2/argparse.pyi @@ -253,7 +253,7 @@ class Action(_AttributeHolder): self, parser: ArgumentParser, namespace: Namespace, - values: Union[Text, Sequence[Any], None], + values: Text | Sequence[Any] | None, option_string: Optional[Text] = ..., ) -> None: ... diff --git a/stdlib/@python2/cgi.pyi b/stdlib/@python2/cgi.pyi index c3519bba9b20..dcdac5a8a25b 100644 --- a/stdlib/@python2/cgi.pyi +++ b/stdlib/@python2/cgi.pyi @@ -64,7 +64,7 @@ class FieldStorage(object): length: int done: int list: Optional[List[Any]] - value: Union[None, bytes, List[Any]] + value: None | bytes | List[Any] def __init__( self, fp: IO[Any] = ..., diff --git a/stdlib/@python2/collections.pyi b/stdlib/@python2/collections.pyi index 9bca1873cf3e..c47dd167270e 100644 --- a/stdlib/@python2/collections.pyi +++ b/stdlib/@python2/collections.pyi @@ -38,7 +38,7 @@ _VT = TypeVar("_VT") # namedtuple is special-cased in the type checker; the initializer is ignored. def namedtuple( typename: str | unicode, - field_names: Union[str, unicode, Iterable[str | unicode]], + field_names: str | unicode | Iterable[str | unicode], verbose: bool = ..., rename: bool = ..., ) -> Type[Tuple[Any, ...]]: ... diff --git a/stdlib/@python2/decimal.pyi b/stdlib/@python2/decimal.pyi index 20e6c525e966..bb16c4453b0b 100644 --- a/stdlib/@python2/decimal.pyi +++ b/stdlib/@python2/decimal.pyi @@ -163,8 +163,8 @@ class Context(object): self, prec: Optional[int] = ..., rounding: Optional[str] = ..., - traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., - flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., + traps: None | Dict[_TrapType, bool] | Container[_TrapType] = ..., + flags: None | Dict[_TrapType, bool] | Container[_TrapType] = ..., Emin: Optional[int] = ..., Emax: Optional[int] = ..., capitals: Optional[int] = ..., diff --git a/stdlib/@python2/dircache.pyi b/stdlib/@python2/dircache.pyi index 07256e38bfad..5d68b9b03995 100644 --- a/stdlib/@python2/dircache.pyi +++ b/stdlib/@python2/dircache.pyi @@ -5,4 +5,4 @@ def listdir(path: Text) -> List[str]: ... opendir = listdir -def annotate(head: Text, list: Union[MutableSequence[str], MutableSequence[Text], MutableSequence[str | Text]]) -> None: ... +def annotate(head: Text, list: MutableSequence[str] | MutableSequence[Text] | MutableSequence[str | Text]) -> None: ... diff --git a/stdlib/@python2/distutils/cmd.pyi b/stdlib/@python2/distutils/cmd.pyi index d87d30fb7277..a284d183d882 100644 --- a/stdlib/@python2/distutils/cmd.pyi +++ b/stdlib/@python2/distutils/cmd.pyi @@ -57,7 +57,7 @@ class Command: ) -> 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], diff --git a/stdlib/@python2/distutils/text_file.pyi b/stdlib/@python2/distutils/text_file.pyi index 9872a1f25751..3f89b0e73ea8 100644 --- a/stdlib/@python2/distutils/text_file.pyi +++ b/stdlib/@python2/distutils/text_file.pyi @@ -15,7 +15,7 @@ class TextFile: ) -> None: ... def open(self, filename: str) -> None: ... def close(self) -> None: ... - def warn(self, msg: str, line: Union[List[int], Tuple[int, int], int] = ...) -> None: ... + def warn(self, msg: str, line: List[int] | Tuple[int, int] | int = ...) -> None: ... def readline(self) -> Optional[str]: ... def readlines(self) -> List[str]: ... def unreadline(self, line: str) -> str: ... diff --git a/stdlib/@python2/fileinput.pyi b/stdlib/@python2/fileinput.pyi index 1e1f8dace600..72e5b5aa833b 100644 --- a/stdlib/@python2/fileinput.pyi +++ b/stdlib/@python2/fileinput.pyi @@ -1,7 +1,7 @@ from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Text, Union def input( - files: Union[Text, Iterable[Text], None] = ..., + files: Text | Iterable[Text] | None = ..., inplace: bool = ..., backup: str = ..., bufsize: int = ..., @@ -20,7 +20,7 @@ def isstdin() -> bool: ... class FileInput(Iterable[AnyStr], Generic[AnyStr]): def __init__( self, - files: Union[None, Text, Iterable[Text]] = ..., + files: None | Text | Iterable[Text] = ..., inplace: bool = ..., backup: str = ..., bufsize: int = ..., diff --git a/stdlib/@python2/locale.pyi b/stdlib/@python2/locale.pyi index 9fca89e986a2..8ecd44305364 100644 --- a/stdlib/@python2/locale.pyi +++ b/stdlib/@python2/locale.pyi @@ -74,8 +74,8 @@ 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 getlocale(category: int = ...) -> Sequence[_str]: ... diff --git a/stdlib/@python2/logging/handlers.pyi b/stdlib/@python2/logging/handlers.pyi index 36fa2ad2146e..0640c8a79710 100644 --- a/stdlib/@python2/logging/handlers.pyi +++ b/stdlib/@python2/logging/handlers.pyi @@ -112,7 +112,7 @@ class SMTPHandler(Handler): toaddrs: List[str], subject: str, credentials: Optional[Tuple[str, str]] = ..., - secure: Union[Tuple[str], Tuple[str, str], None] = ..., + secure: Tuple[str] | Tuple[str, str] | None = ..., ) -> None: ... def getSubject(self, record: LogRecord) -> str: ... diff --git a/stdlib/@python2/pyclbr.pyi b/stdlib/@python2/pyclbr.pyi index 6a7451de720a..56a987d72402 100644 --- a/stdlib/@python2/pyclbr.pyi +++ b/stdlib/@python2/pyclbr.pyi @@ -17,4 +17,4 @@ class Function: 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_ex(module: str, path: Optional[Sequence[str]] = ...) -> Dict[str, Class | Function | List[str]]: ... diff --git a/stdlib/@python2/subprocess.pyi b/stdlib/@python2/subprocess.pyi index 358853e9d667..d978531c51a0 100644 --- a/stdlib/@python2/subprocess.pyi +++ b/stdlib/@python2/subprocess.pyi @@ -1,6 +1,6 @@ from typing import IO, Any, Callable, Generic, Mapping, Optional, Sequence, Text, Tuple, TypeVar, Union -_FILE = Union[None, int, IO[Any]] +_FILE = None | int | IO[Any] _TXT = bytes | Text _CMD = _TXT | Sequence[_TXT] _ENV = Mapping[bytes, _TXT] | Mapping[Text, _TXT] diff --git a/stdlib/@python2/typing_extensions.pyi b/stdlib/@python2/typing_extensions.pyi index 2499ae19d0f9..61dcd3864f75 100644 --- a/stdlib/@python2/typing_extensions.pyi +++ b/stdlib/@python2/typing_extensions.pyi @@ -95,7 +95,7 @@ class ParamSpec: __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/@python2/unittest.pyi b/stdlib/@python2/unittest.pyi index c69e17239074..fae03ac84074 100644 --- a/stdlib/@python2/unittest.pyi +++ b/stdlib/@python2/unittest.pyi @@ -259,7 +259,7 @@ def main( module: None | Text | types.ModuleType = ..., defaultTest: Optional[str] = ..., argv: Optional[Sequence[str]] = ..., - testRunner: Union[Type[TextTestRunner], TextTestRunner, None] = ..., + testRunner: Type[TextTestRunner] | TextTestRunner | None = ..., testLoader: TestLoader = ..., exit: bool = ..., verbosity: int = ..., diff --git a/stdlib/@python2/xml/etree/ElementTree.pyi b/stdlib/@python2/xml/etree/ElementTree.pyi index 938520d9de29..e8eb622e0e22 100644 --- a/stdlib/@python2/xml/etree/ElementTree.pyi +++ b/stdlib/@python2/xml/etree/ElementTree.pyi @@ -50,7 +50,7 @@ _str_argument_type = str | Text # _fixtext function in the source). Client code knows best: _str_result_type = Any -_file_or_filename = Union[Text, FileDescriptor, IO[Any]] +_file_or_filename = Text | FileDescriptor | IO[Any] class Element(MutableSequence[Element]): tag: _str_result_type diff --git a/stdlib/@python2/xml/sax/__init__.pyi b/stdlib/@python2/xml/sax/__init__.pyi index 32ef9706ed3e..f450d7fe73c0 100644 --- a/stdlib/@python2/xml/sax/__init__.pyi +++ b/stdlib/@python2/xml/sax/__init__.pyi @@ -22,6 +22,6 @@ class SAXReaderNotAvailable(SAXNotSupportedException): ... default_parser_list: List[str] def make_parser(parser_list: List[str] = ...) -> XMLReader: ... -def parse(source: Union[str, IO[str], IO[bytes]], handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ... +def parse(source: str | IO[str] | IO[bytes], handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ... def parseString(string: bytes | Text, handler: ContentHandler, errorHandler: Optional[ErrorHandler] = ...) -> None: ... def _create_parser(parser_name: str) -> XMLReader: ... diff --git a/stdlib/_csv.pyi b/stdlib/_csv.pyi index 45d05f478cb4..475db75ffd7c 100644 --- a/stdlib/_csv.pyi +++ b/stdlib/_csv.pyi @@ -18,7 +18,7 @@ class Dialect: strict: int def __init__(self) -> None: ... -_DialectLike = Union[str, Dialect, Type[Dialect]] +_DialectLike = str | Dialect | Type[Dialect] class _reader(Iterator[List[str]]): dialect: Dialect diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index 5f5cb6aca16d..27e8c97ba7f8 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -294,7 +294,7 @@ class Action(_AttributeHolder): self, parser: ArgumentParser, namespace: Namespace, - values: Union[str, Sequence[Any], None], + values: str | Sequence[Any] | None, option_string: Optional[str] = ..., ) -> None: ... if sys.version_info >= (3, 9): diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index ee6f18a74b3a..d0f108ba3ef0 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -163,7 +163,7 @@ if sys.version_info >= (3, 8): 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( @@ -172,7 +172,7 @@ if sys.version_info >= (3, 8): mode: str = ..., *, type_comments: bool = ..., - feature_version: Union[None, int, _typing.Tuple[int, int]] = ..., + feature_version: None | int | _typing.Tuple[int, int] = ..., ) -> AST: ... else: diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index b7633a2fc471..58e4357f7b43 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -324,9 +324,9 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): protocol_factory: _ProtocolFactory, 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] = ..., diff --git a/stdlib/asyncio/base_subprocess.pyi b/stdlib/asyncio/base_subprocess.pyi index d16155521aa5..bc834cd94cce 100644 --- a/stdlib/asyncio/base_subprocess.pyi +++ b/stdlib/asyncio/base_subprocess.pyi @@ -21,7 +21,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport): self, loop: events.AbstractEventLoop, protocol: protocols.SubprocessProtocol, - args: Union[str, bytes, Sequence[str | bytes]], + args: str | bytes | Sequence[str | bytes], shell: bool, stdin: _File, stdout: _File, @@ -33,7 +33,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport): ) -> None: ... def _start( self, - args: Union[str, bytes, Sequence[str | bytes]], + args: str | bytes | Sequence[str | bytes], shell: bool, stdin: _File, stdout: _File, diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 7944147f69b6..8db74edc57f8 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -399,9 +399,9 @@ class AbstractEventLoop(metaclass=ABCMeta): protocol_factory: _ProtocolFactory, 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] = ..., @@ -416,9 +416,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] = ..., diff --git a/stdlib/asyncio/subprocess.pyi b/stdlib/asyncio/subprocess.pyi index d07b6ed0e573..09b297ab1be2 100644 --- a/stdlib/asyncio/subprocess.pyi +++ b/stdlib/asyncio/subprocess.pyi @@ -43,9 +43,9 @@ class Process: if sys.version_info >= (3, 10): async def create_subprocess_shell( cmd: str | bytes, - 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 @@ -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] = ..., @@ -97,9 +97,9 @@ if sys.version_info >= (3, 10): else: async def create_subprocess_shell( cmd: str | bytes, - 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 = ..., loop: Optional[events.AbstractEventLoop] = ..., limit: int = ..., *, @@ -125,9 +125,9 @@ 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] = ..., + stdin: int | IO[Any] | None = ..., + stdout: int | IO[Any] | None = ..., + stderr: int | IO[Any] | None = ..., loop: Optional[events.AbstractEventLoop] = ..., limit: int = ..., # These parameters are forced to these values by BaseEventLoop.subprocess_shell diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index 43fc38a4e728..466ea0a67561 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -18,7 +18,7 @@ _T3 = TypeVar("_T3") _T4 = TypeVar("_T4") _T5 = TypeVar("_T5") _FT = TypeVar("_FT", bound=Future[Any]) -_FutureT = Union[Future[_T], Generator[Any, None, _T], Awaitable[_T]] +_FutureT = Future[_T] | Generator[Any, None, _T] | Awaitable[_T] _TaskYieldType = Optional[Future[object]] FIRST_EXCEPTION: str diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index 2a97891d6b0d..3ebf1c8fc2b5 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -39,9 +39,9 @@ if sys.version_info >= (3, 8): 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: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 0cf42645ab36..a2202796eb1e 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -386,7 +386,7 @@ class str(Sequence[str]): def zfill(self, __width: int) -> str: ... @staticmethod @overload - def maketrans(__x: Union[Dict[int, _T], Dict[str, _T], Dict[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, int | None]: ... @@ -975,7 +975,7 @@ if sys.version_info >= (3, 10): if sys.version_info >= (3, 8): def compile( source: str | bytes | mod | AST, - filename: Union[str, bytes, _PathLike[Any]], + filename: str | bytes | _PathLike[Any], mode: str, flags: int = ..., dont_inherit: int = ..., @@ -987,7 +987,7 @@ if sys.version_info >= (3, 8): else: def compile( source: str | bytes | mod | AST, - filename: Union[str, bytes, _PathLike[Any]], + filename: str | bytes | _PathLike[Any], mode: str, flags: int = ..., dont_inherit: int = ..., @@ -1046,10 +1046,10 @@ 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.Union, Tuple[Union[type, types.Union, Tuple[Any, ...]], ...]] + __obj: object, __class_or_tuple: Union[type, types.Union, Tuple[type | types.Union | Tuple[Any, ...], ...]] ) -> bool: ... def issubclass( - __cls: type, __class_or_tuple: Union[type, types.Union, Tuple[Union[type, types.Union, Tuple[Any, ...]], ...]] + __cls: type, __class_or_tuple: Union[type, types.Union, Tuple[type | types.Union | Tuple[Any, ...], ...]] ) -> bool: ... else: diff --git a/stdlib/cgi.pyi b/stdlib/cgi.pyi index da3a4d43c563..bc5917e272b4 100644 --- a/stdlib/cgi.pyi +++ b/stdlib/cgi.pyi @@ -79,7 +79,7 @@ class FieldStorage(object): length: int done: int list: Optional[_list[Any]] - value: Union[None, bytes, _list[Any]] + value: None | bytes | _list[Any] def __init__( self, fp: Optional[IO[Any]] = ..., diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index b9cf3441ed20..f49d2481b6ef 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -142,7 +142,7 @@ class UserString(Sequence[str]): def lstrip(self: _UserStringT, chars: Optional[str] = ...) -> _UserStringT: ... @staticmethod @overload - def maketrans(x: Union[Dict[int, _T], Dict[str, _T], Dict[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, int | None]: ... diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 496f717576cb..7c2914bdbdb2 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -174,8 +174,8 @@ class Context(object): 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]] = ..., + flags: None | Dict[_TrapType, bool] | Container[_TrapType] = ..., + traps: None | Dict[_TrapType, bool] | Container[_TrapType] = ..., _ignored_flags: Optional[List[_TrapType]] = ..., ) -> None: ... # __setattr__() only allows to set a specific set of attributes, diff --git a/stdlib/distutils/cmd.pyi b/stdlib/distutils/cmd.pyi index 79f349db5074..2808a490a59e 100644 --- a/stdlib/distutils/cmd.pyi +++ b/stdlib/distutils/cmd.pyi @@ -57,7 +57,7 @@ class Command: ) -> 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], diff --git a/stdlib/distutils/text_file.pyi b/stdlib/distutils/text_file.pyi index a65f37305d94..587d77c9ffad 100644 --- a/stdlib/distutils/text_file.pyi +++ b/stdlib/distutils/text_file.pyi @@ -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 warn(self, msg: str, line: Optional[List[int] | Tuple[int, int] | int] = ...) -> None: ... def readline(self) -> Optional[str]: ... def readlines(self) -> List[str]: ... def unreadline(self, line: str) -> str: ... diff --git a/stdlib/email/message.pyi b/stdlib/email/message.pyi index 69a4cd15a6f2..4ca7f85cf2cc 100644 --- a/stdlib/email/message.pyi +++ b/stdlib/email/message.pyi @@ -6,7 +6,7 @@ from typing import Any, Generator, Iterator, List, Optional, Sequence, Tuple, Ty _T = TypeVar("_T") -_PayloadType = Union[List[Message], str, bytes] +_PayloadType = List[Message] | str | bytes _CharsetType = Charset | str | None _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] _ParamType = Union[str, Tuple[Optional[str], Optional[str], str]] diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index ebaa31749528..4d590a40de28 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -87,7 +87,7 @@ def fcntl(__fd: FileDescriptorLike, __cmd: int, __arg: int = ...) -> int: ... def fcntl(__fd: FileDescriptorLike, __cmd: int, __arg: bytes) -> bytes: ... _ReadOnlyBuffer = bytes -_WritableBuffer = Union[bytearray, memoryview, array[Any]] +_WritableBuffer = bytearray | memoryview | array[Any] @overload def ioctl(__fd: FileDescriptorLike, __request: int, __arg: int = ..., __mutate_flag: bool = ...) -> int: ... diff --git a/stdlib/fileinput.pyi b/stdlib/fileinput.pyi index 0fd7937e1d22..b994e83f4652 100644 --- a/stdlib/fileinput.pyi +++ b/stdlib/fileinput.pyi @@ -4,7 +4,7 @@ from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Union if sys.version_info >= (3, 10): def input( - files: Union[StrOrBytesPath, Iterable[StrOrBytesPath], None] = ..., + files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ..., inplace: bool = ..., backup: str = ..., *, @@ -16,7 +16,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 = ..., *, @@ -26,7 +26,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 = ..., @@ -47,7 +47,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 = ..., *, @@ -59,7 +59,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 = ..., *, @@ -69,7 +69,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/inspect.pyi b/stdlib/inspect.pyi index 7e5024fe1d03..f3ed35f5bb3f 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -146,7 +146,7 @@ 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]] = ..., diff --git a/stdlib/io.pyi b/stdlib/io.pyi index 9120001d9619..261c178c7f80 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -125,7 +125,7 @@ class BufferedRWPair(BufferedIOBase): class TextIOBase(IOBase): encoding: str errors: Optional[str] - newlines: Union[str, Tuple[str, ...], None] + newlines: str | Tuple[str, ...] | None def __iter__(self) -> Iterator[str]: ... # type: ignore def __next__(self) -> str: ... # type: ignore def detach(self) -> BinaryIO: ... diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index 41886857250f..b56523a082ac 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -77,8 +77,8 @@ 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 getlocale(category: int = ...) -> Sequence[_str]: ... diff --git a/stdlib/logging/config.pyi b/stdlib/logging/config.pyi index ed79f48aa94c..b605cec66652 100644 --- a/stdlib/logging/config.pyi +++ b/stdlib/logging/config.pyi @@ -23,7 +23,7 @@ def dictConfig(config: dict[str, Any]) -> None: ... if sys.version_info >= (3, 10): def fileConfig( - fname: Union[_Path, IO[str], RawConfigParser], + fname: _Path | IO[str] | RawConfigParser, defaults: Optional[dict[str, str]] = ..., disable_existing_loggers: bool = ..., encoding: Optional[str] = ..., @@ -31,7 +31,7 @@ if sys.version_info >= (3, 10): else: def fileConfig( - fname: Union[_Path, IO[str], RawConfigParser], + fname: _Path | IO[str] | RawConfigParser, defaults: Optional[dict[str, str]] = ..., disable_existing_loggers: bool = ..., ) -> None: ... diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index b23bba2db3d6..8733c0044cac 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -755,7 +755,7 @@ _ExecVArgs = Union[ List[bytes | str], List[bytes | PathLike[Any]], List[str | PathLike[Any]], - List[Union[bytes, str, PathLike[Any]]], + List[bytes | str | PathLike[Any]], ] _ExecEnv = Mapping[bytes, bytes | str] | Mapping[str, bytes | str] diff --git a/stdlib/pyclbr.pyi b/stdlib/pyclbr.pyi index 38bd25aa9267..92b62aa88c75 100644 --- a/stdlib/pyclbr.pyi +++ b/stdlib/pyclbr.pyi @@ -34,4 +34,4 @@ class Function: 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_ex(module: str, path: Optional[Sequence[str]] = ...) -> Dict[str, Class | Function | List[str]]: ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 0bab898ce0fd..7c70c1023335 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -21,7 +21,7 @@ if sys.version_info >= (3, 9): # reveal_type(x) # bytes, based on the overloads # except TimeoutError as e: # reveal_type(e.cmd) # Any, but morally is _CMD -_FILE = Union[None, int, IO[Any]] +_FILE = None | int | IO[Any] _TXT = bytes | str if sys.version_info >= (3, 8): _CMD = StrOrBytesPath | Sequence[StrOrBytesPath] diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index cdf280355ef0..a826f539f6f4 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -270,7 +270,7 @@ class Misc: # 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 = ...): ... @@ -292,25 +292,25 @@ class Misc: def lower(self, belowThis: Optional[Any] = ...): ... def tkraise(self, aboveThis: Optional[Any] = ...): ... 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 = ...) -> Optional[Misc]: ... 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]: ... @@ -1121,7 +1121,7 @@ class Canvas(Widget, XView, YView): arrow: Literal["first", "last", "both"] = ..., arrowshape: Tuple[float, float, float] = ..., capstyle: Literal["round", "projecting", "butt"] = ..., - dash: Union[Tuple[float], Tuple[float, float], Tuple[float, float, float, float]] = ..., + dash: Tuple[float] | Tuple[float, float] | Tuple[float, float, float, float] = ..., dashoffset: _ScreenUnits = ..., disableddash: _Color = ..., disabledfill: _Color = ..., @@ -1150,7 +1150,7 @@ class Canvas(Widget, XView, YView): activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: Union[Tuple[float], Tuple[float, float], Tuple[float, float, float, float]] = ..., + dash: Tuple[float] | Tuple[float, float] | Tuple[float, float, float, float] = ..., dashoffset: _ScreenUnits = ..., disableddash: _Color = ..., disabledfill: _Color = ..., @@ -1181,7 +1181,7 @@ class Canvas(Widget, XView, YView): activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: Union[Tuple[float], Tuple[float, float], Tuple[float, float, float, float]] = ..., + dash: Tuple[float] | Tuple[float, float] | Tuple[float, float, float, float] = ..., dashoffset: _ScreenUnits = ..., disableddash: _Color = ..., disabledfill: _Color = ..., @@ -1215,7 +1215,7 @@ class Canvas(Widget, XView, YView): activeoutlinestipple: _Color = ..., activestipple: str = ..., activewidth: _ScreenUnits = ..., - dash: Union[Tuple[float], Tuple[float, float], Tuple[float, float, float, float]] = ..., + dash: Tuple[float] | Tuple[float, float] | Tuple[float, float, float, float] = ..., dashoffset: _ScreenUnits = ..., disableddash: _Color = ..., disabledfill: _Color = ..., @@ -2511,7 +2511,7 @@ class Text(Widget, XView, YView): startline: int | Literal[""] = ..., state: Literal["normal", "disabled"] = ..., # Literal inside Tuple doesn't actually work - tabs: Union[_ScreenUnits, str, Tuple[_ScreenUnits | str, ...]] = ..., + tabs: _ScreenUnits | str | Tuple[_ScreenUnits | str, ...] = ..., tabstyle: Literal["tabular", "wordprocessor"] = ..., takefocus: _TakeFocusValue = ..., undo: bool = ..., @@ -2562,7 +2562,7 @@ class Text(Widget, XView, YView): spacing3: _ScreenUnits = ..., startline: int | Literal[""] = ..., state: Literal["normal", "disabled"] = ..., - tabs: Union[_ScreenUnits, str, Tuple[_ScreenUnits | str, ...]] = ..., + tabs: _ScreenUnits | str | Tuple[_ScreenUnits | str, ...] = ..., tabstyle: Literal["tabular", "wordprocessor"] = ..., takefocus: _TakeFocusValue = ..., undo: bool = ..., @@ -2817,7 +2817,7 @@ class PhotoImage(Image): 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: Optional[Tuple[int, int]] = ... ) -> None: ... def write( self, filename: StrOrBytesPath, format: Optional[str] = ..., from_coords: Optional[Tuple[int, int]] = ... diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index a19c2dd6dc67..20a734221e22 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -9,7 +9,7 @@ BOLD: Literal["bold"] ITALIC: Literal["italic"] # Can contain e.g. nested sequences ('FONT DESCRIPTIONS' in font man page) -_FontDescription = Union[str, Font, tkinter._TkinterSequence[Any]] +_FontDescription = str | Font | tkinter._TkinterSequence[Any] class _FontDict(TypedDict): family: str diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 0be8985f8b51..adb31f4a32d5 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -24,7 +24,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: ... @@ -70,7 +70,7 @@ if sys.version_info >= (3, 10): __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/typing_extensions.pyi b/stdlib/typing_extensions.pyi index 807e37ef29d6..29f285132e0d 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -107,7 +107,7 @@ else: __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/unittest/main.pyi b/stdlib/unittest/main.pyi index b65319640928..59e9463ae325 100644 --- a/stdlib/unittest/main.pyi +++ b/stdlib/unittest/main.pyi @@ -25,9 +25,9 @@ class TestProgram: def __init__( self, module: None | str | ModuleType = ..., - defaultTest: Union[str, Iterable[str], None] = ..., + defaultTest: str | Iterable[str] | None = ..., argv: Optional[List[str]] = ..., - testRunner: Union[Type[_TestRunner], _TestRunner, None] = ..., + testRunner: Type[_TestRunner] | _TestRunner | None = ..., testLoader: unittest.loader.TestLoader = ..., exit: bool = ..., verbosity: int = ..., diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index 70176aed4d4f..04494913a897 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -22,7 +22,7 @@ from typing import ( from typing_extensions import Literal _T = TypeVar("_T") -_File = Union[StrOrBytesPath, FileDescriptor, IO[Any]] +_File = StrOrBytesPath | FileDescriptor | IO[Any] VERSION: str diff --git a/stdlib/xml/sax/__init__.pyi b/stdlib/xml/sax/__init__.pyi index 5c45410910f8..3559b2efcb91 100644 --- a/stdlib/xml/sax/__init__.pyi +++ b/stdlib/xml/sax/__init__.pyi @@ -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 parse(source: str | IO[str] | IO[bytes], handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ... def parseString(string: bytes | str, handler: ContentHandler, errorHandler: Optional[ErrorHandler] = ...) -> None: ... def _create_parser(parser_name: str) -> XMLReader: ... diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index c178e3da849f..14435fc7e5ff 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -213,7 +213,7 @@ 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]: ... else: diff --git a/stdlib/zipimport.pyi b/stdlib/zipimport.pyi index d36653196ee3..aa4c5a0b0d4e 100644 --- a/stdlib/zipimport.pyi +++ b/stdlib/zipimport.pyi @@ -11,7 +11,7 @@ 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 From c156d704a780f2bca4795dd74877ebbbcaa4d22f Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:41:53 -0700 Subject: [PATCH 06/16] fastmod -d stdlib --accept-all '\bOptional\[([\w\.\| ]+)\]' '$1 | None' --- stdlib/@python2/BaseHTTPServer.pyi | 6 +- stdlib/@python2/Cookie.pyi | 16 +- stdlib/@python2/Queue.pyi | 4 +- stdlib/@python2/SocketServer.pyi | 6 +- stdlib/@python2/StringIO.pyi | 2 +- stdlib/@python2/UserDict.pyi | 2 +- stdlib/@python2/UserString.pyi | 18 +- stdlib/@python2/__builtin__.pyi | 86 +-- stdlib/@python2/_ast.pyi | 44 +- stdlib/@python2/_bisect.pyi | 8 +- stdlib/@python2/_codecs.pyi | 4 +- stdlib/@python2/_collections.pyi | 2 +- stdlib/@python2/_csv.pyi | 4 +- stdlib/@python2/_curses.pyi | 2 +- stdlib/@python2/_dummy_threading.pyi | 28 +- stdlib/@python2/_io.pyi | 30 +- stdlib/@python2/_msi.pyi | 4 +- stdlib/@python2/_osx_support.pyi | 6 +- stdlib/@python2/_sha256.pyi | 4 +- stdlib/@python2/_sha512.pyi | 4 +- stdlib/@python2/_socket.pyi | 2 +- stdlib/@python2/_sre.pyi | 8 +- stdlib/@python2/_thread.pyi | 2 +- stdlib/@python2/_typeshed/wsgi.pyi | 2 +- stdlib/@python2/_typeshed/xml.pyi | 4 +- stdlib/@python2/_warnings.pyi | 4 +- stdlib/@python2/_weakref.pyi | 2 +- stdlib/@python2/_winreg.pyi | 14 +- stdlib/@python2/aifc.pyi | 4 +- stdlib/@python2/argparse.pyi | 96 ++-- stdlib/@python2/ast.pyi | 2 +- stdlib/@python2/asynchat.pyi | 2 +- stdlib/@python2/asyncore.pyi | 24 +- stdlib/@python2/audioop.pyi | 6 +- stdlib/@python2/base64.pyi | 6 +- stdlib/@python2/bdb.pyi | 30 +- stdlib/@python2/builtins.pyi | 86 +-- stdlib/@python2/bz2.pyi | 4 +- stdlib/@python2/cProfile.pyi | 4 +- stdlib/@python2/cStringIO.pyi | 4 +- stdlib/@python2/calendar.pyi | 8 +- stdlib/@python2/cgi.pyi | 8 +- stdlib/@python2/cgitb.pyi | 16 +- stdlib/@python2/cmd.pyi | 10 +- stdlib/@python2/code.pyi | 8 +- stdlib/@python2/codecs.pyi | 46 +- stdlib/@python2/codeop.pyi | 4 +- stdlib/@python2/collections.pyi | 4 +- stdlib/@python2/compileall.pyi | 4 +- stdlib/@python2/contextlib.pyi | 2 +- stdlib/@python2/cookielib.pyi | 22 +- stdlib/@python2/copy_reg.pyi | 2 +- stdlib/@python2/copyreg.pyi | 2 +- stdlib/@python2/csv.pyi | 18 +- stdlib/@python2/ctypes/__init__.pyi | 14 +- stdlib/@python2/ctypes/util.pyi | 4 +- stdlib/@python2/datetime.pyi | 32 +- stdlib/@python2/dbm/__init__.pyi | 2 +- stdlib/@python2/dbm/dumb.pyi | 2 +- stdlib/@python2/dbm/gnu.pyi | 8 +- stdlib/@python2/dbm/ndbm.pyi | 4 +- stdlib/@python2/decimal.pyi | 146 ++--- stdlib/@python2/difflib.pyi | 10 +- stdlib/@python2/distutils/archive_util.pyi | 6 +- stdlib/@python2/distutils/ccompiler.pyi | 48 +- stdlib/@python2/distutils/cmd.pyi | 18 +- stdlib/@python2/distutils/command/config.pyi | 12 +- stdlib/@python2/distutils/command/install.pyi | 8 +- .../distutils/command/install_egg_info.pyi | 2 +- stdlib/@python2/distutils/config.pyi | 2 +- stdlib/@python2/distutils/dist.pyi | 2 +- stdlib/@python2/distutils/extension.pyi | 4 +- stdlib/@python2/distutils/fancy_getopt.pyi | 4 +- stdlib/@python2/distutils/file_util.pyi | 2 +- stdlib/@python2/distutils/spawn.pyi | 2 +- stdlib/@python2/distutils/sysconfig.pyi | 4 +- stdlib/@python2/distutils/text_file.pyi | 4 +- stdlib/@python2/distutils/util.pyi | 8 +- stdlib/@python2/distutils/version.pyi | 6 +- stdlib/@python2/doctest.pyi | 48 +- stdlib/@python2/dummy_thread.pyi | 6 +- stdlib/@python2/email/_parseaddr.pyi | 2 +- stdlib/@python2/email/mime/application.pyi | 2 +- stdlib/@python2/email/utils.pyi | 6 +- stdlib/@python2/ensurepip/__init__.pyi | 2 +- stdlib/@python2/formatter.pyi | 32 +- stdlib/@python2/fractions.pyi | 2 +- stdlib/@python2/ftplib.pyi | 32 +- stdlib/@python2/gettext.pyi | 14 +- stdlib/@python2/grp.pyi | 2 +- stdlib/@python2/hmac.pyi | 4 +- stdlib/@python2/httplib.pyi | 46 +- stdlib/@python2/imaplib.pyi | 14 +- stdlib/@python2/imghdr.pyi | 6 +- stdlib/@python2/importlib.pyi | 2 +- stdlib/@python2/inspect.pyi | 28 +- stdlib/@python2/itertools.pyi | 4 +- stdlib/@python2/json.pyi | 10 +- stdlib/@python2/lib2to3/pgen2/driver.pyi | 6 +- stdlib/@python2/lib2to3/pgen2/grammar.pyi | 2 +- stdlib/@python2/lib2to3/pgen2/parse.pyi | 16 +- stdlib/@python2/lib2to3/pgen2/pgen.pyi | 6 +- stdlib/@python2/lib2to3/pytree.pyi | 32 +- stdlib/@python2/linecache.pyi | 8 +- stdlib/@python2/locale.pyi | 2 +- stdlib/@python2/logging/__init__.pyi | 44 +- stdlib/@python2/logging/handlers.pyi | 12 +- stdlib/@python2/macpath.pyi | 2 +- stdlib/@python2/mailbox.pyi | 22 +- stdlib/@python2/mailcap.pyi | 2 +- stdlib/@python2/mimetypes.pyi | 8 +- stdlib/@python2/mmap.pyi | 4 +- stdlib/@python2/modulefinder.pyi | 14 +- stdlib/@python2/msilib/__init__.pyi | 54 +- stdlib/@python2/msilib/schema.pyi | 2 +- stdlib/@python2/msilib/sequence.pyi | 2 +- stdlib/@python2/msilib/text.pyi | 4 +- stdlib/@python2/multiprocessing/__init__.pyi | 12 +- .../multiprocessing/dummy/__init__.pyi | 2 +- stdlib/@python2/multiprocessing/pool.pyi | 20 +- stdlib/@python2/multiprocessing/process.pyi | 4 +- stdlib/@python2/multiprocessing/util.pyi | 6 +- stdlib/@python2/netrc.pyi | 12 +- stdlib/@python2/nntplib.pyi | 22 +- stdlib/@python2/ntpath.pyi | 6 +- stdlib/@python2/numbers.pyi | 2 +- stdlib/@python2/optparse.pyi | 58 +- stdlib/@python2/os/__init__.pyi | 8 +- stdlib/@python2/os/path.pyi | 6 +- stdlib/@python2/os2emxpath.pyi | 6 +- stdlib/@python2/pdb.pyi | 76 +-- stdlib/@python2/pickle.pyi | 6 +- stdlib/@python2/pickletools.pyi | 6 +- stdlib/@python2/pkgutil.pyi | 8 +- stdlib/@python2/platform.pyi | 4 +- stdlib/@python2/popen2.pyi | 2 +- stdlib/@python2/poplib.pyi | 4 +- stdlib/@python2/posixpath.pyi | 6 +- stdlib/@python2/pprint.pyi | 6 +- stdlib/@python2/profile.pyi | 6 +- stdlib/@python2/py_compile.pyi | 2 +- stdlib/@python2/pydoc.pyi | 82 +-- stdlib/@python2/pyexpat/__init__.pyi | 24 +- stdlib/@python2/readline.pyi | 8 +- stdlib/@python2/rfc822.pyi | 4 +- stdlib/@python2/rlcompleter.pyi | 2 +- stdlib/@python2/runpy.pyi | 4 +- stdlib/@python2/select.pyi | 8 +- stdlib/@python2/shelve.pyi | 8 +- stdlib/@python2/shlex.pyi | 8 +- stdlib/@python2/shutil.pyi | 10 +- stdlib/@python2/site.pyi | 6 +- stdlib/@python2/smtpd.pyi | 6 +- stdlib/@python2/sndhdr.pyi | 4 +- stdlib/@python2/socket.pyi | 16 +- stdlib/@python2/sqlite3/dbapi2.pyi | 8 +- stdlib/@python2/sre_parse.pyi | 10 +- stdlib/@python2/ssl.pyi | 74 +-- stdlib/@python2/subprocess.pyi | 36 +- stdlib/@python2/sunau.pyi | 4 +- stdlib/@python2/sys.pyi | 6 +- stdlib/@python2/sysconfig.pyi | 4 +- stdlib/@python2/tarfile.pyi | 134 ++--- stdlib/@python2/telnetlib.pyi | 8 +- stdlib/@python2/tempfile.pyi | 14 +- stdlib/@python2/threading.pyi | 28 +- stdlib/@python2/time.pyi | 6 +- stdlib/@python2/trace.pyi | 14 +- stdlib/@python2/traceback.pyi | 30 +- stdlib/@python2/turtle.pyi | 62 +- stdlib/@python2/types.pyi | 20 +- stdlib/@python2/typing.pyi | 24 +- stdlib/@python2/unittest.pyi | 24 +- stdlib/@python2/urllib.pyi | 2 +- stdlib/@python2/urllib2.pyi | 48 +- stdlib/@python2/urlparse.pyi | 8 +- stdlib/@python2/uu.pyi | 4 +- stdlib/@python2/uuid.pyi | 18 +- stdlib/@python2/warnings.pyi | 22 +- stdlib/@python2/wave.pyi | 4 +- stdlib/@python2/webbrowser.pyi | 4 +- stdlib/@python2/whichdb.pyi | 2 +- stdlib/@python2/winsound.pyi | 4 +- stdlib/@python2/wsgiref/handlers.pyi | 10 +- stdlib/@python2/wsgiref/headers.pyi | 6 +- stdlib/@python2/wsgiref/simple_server.pyi | 6 +- stdlib/@python2/wsgiref/util.pyi | 2 +- stdlib/@python2/wsgiref/validate.pyi | 4 +- stdlib/@python2/xml/dom/domreg.pyi | 2 +- stdlib/@python2/xml/dom/minicompat.pyi | 2 +- stdlib/@python2/xml/dom/minidom.pyi | 22 +- stdlib/@python2/xml/etree/ElementInclude.pyi | 2 +- stdlib/@python2/xml/etree/ElementPath.pyi | 4 +- stdlib/@python2/xml/etree/ElementTree.pyi | 58 +- stdlib/@python2/xml/sax/__init__.pyi | 4 +- stdlib/@python2/xml/sax/saxutils.pyi | 2 +- stdlib/@python2/xml/sax/xmlreader.pyi | 2 +- stdlib/@python2/xmlrpclib.pyi | 30 +- stdlib/@python2/zipfile.pyi | 28 +- stdlib/@python2/zipimport.pyi | 4 +- stdlib/_ast.pyi | 68 +-- stdlib/_bisect.pyi | 16 +- stdlib/_codecs.pyi | 82 +-- stdlib/_csv.pyi | 4 +- stdlib/_curses.pyi | 2 +- stdlib/_dummy_thread.pyi | 6 +- stdlib/_dummy_threading.pyi | 42 +- stdlib/_json.pyi | 2 +- stdlib/_msi.pyi | 4 +- stdlib/_osx_support.pyi | 6 +- stdlib/_sitebuiltins.pyi | 2 +- stdlib/_socket.pyi | 4 +- stdlib/_thread.pyi | 10 +- stdlib/_typeshed/tkinter.pyi | 2 +- stdlib/_typeshed/wsgi.pyi | 2 +- stdlib/_typeshed/xml.pyi | 4 +- stdlib/_warnings.pyi | 12 +- stdlib/_weakref.pyi | 2 +- stdlib/_winapi.pyi | 12 +- stdlib/aifc.pyi | 8 +- stdlib/argparse.pyi | 126 ++--- stdlib/ast.pyi | 6 +- stdlib/asynchat.pyi | 2 +- stdlib/asyncio/base_events.pyi | 82 +-- stdlib/asyncio/base_subprocess.pyi | 16 +- stdlib/asyncio/base_tasks.pyi | 4 +- stdlib/asyncio/events.pyi | 106 ++-- stdlib/asyncio/exceptions.pyi | 4 +- stdlib/asyncio/format_helpers.pyi | 2 +- stdlib/asyncio/futures.pyi | 10 +- stdlib/asyncio/locks.pyi | 14 +- stdlib/asyncio/proactor_events.pyi | 12 +- 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 | 40 +- stdlib/asyncio/staggered.pyi | 6 +- stdlib/asyncio/streams.pyi | 38 +- stdlib/asyncio/subprocess.pyi | 58 +- stdlib/asyncio/tasks.pyi | 66 +-- stdlib/asyncio/transports.pyi | 10 +- stdlib/asyncio/trsock.pyi | 8 +- stdlib/asyncio/unix_events.pyi | 12 +- stdlib/asyncio/windows_events.pyi | 6 +- stdlib/asyncio/windows_utils.pyi | 2 +- stdlib/asyncore.pyi | 24 +- stdlib/audioop.pyi | 6 +- stdlib/base64.pyi | 6 +- stdlib/bdb.pyi | 30 +- stdlib/builtins.pyi | 172 +++--- stdlib/bz2.pyi | 26 +- stdlib/cProfile.pyi | 4 +- stdlib/calendar.pyi | 8 +- stdlib/cgi.pyi | 14 +- stdlib/cgitb.pyi | 16 +- stdlib/cmd.pyi | 10 +- stdlib/code.pyi | 10 +- stdlib/codecs.pyi | 48 +- stdlib/codeop.pyi | 4 +- stdlib/collections/__init__.pyi | 32 +- stdlib/compileall.pyi | 48 +- stdlib/concurrent/futures/_base.pyi | 14 +- stdlib/concurrent/futures/process.pyi | 6 +- stdlib/concurrent/futures/thread.pyi | 4 +- stdlib/configparser.pyi | 70 +-- stdlib/contextlib.pyi | 14 +- stdlib/contextvars.pyi | 4 +- stdlib/copyreg.pyi | 2 +- stdlib/crypt.pyi | 6 +- stdlib/csv.pyi | 18 +- stdlib/ctypes/__init__.pyi | 22 +- stdlib/ctypes/util.pyi | 4 +- stdlib/dataclasses.pyi | 18 +- stdlib/datetime.pyi | 40 +- stdlib/dbm/__init__.pyi | 2 +- stdlib/dbm/dumb.pyi | 2 +- stdlib/dbm/gnu.pyi | 8 +- stdlib/dbm/ndbm.pyi | 4 +- stdlib/decimal.pyi | 98 ++-- stdlib/difflib.pyi | 12 +- stdlib/dis.pyi | 14 +- stdlib/distutils/archive_util.pyi | 14 +- stdlib/distutils/ccompiler.pyi | 48 +- stdlib/distutils/cmd.pyi | 18 +- stdlib/distutils/command/config.pyi | 12 +- stdlib/distutils/command/install.pyi | 8 +- stdlib/distutils/command/install_egg_info.pyi | 2 +- stdlib/distutils/config.pyi | 2 +- stdlib/distutils/debug.pyi | 2 +- stdlib/distutils/dist.pyi | 26 +- stdlib/distutils/extension.pyi | 8 +- stdlib/distutils/fancy_getopt.pyi | 4 +- stdlib/distutils/file_util.pyi | 2 +- stdlib/distutils/filelist.pyi | 12 +- stdlib/distutils/spawn.pyi | 2 +- stdlib/distutils/sysconfig.pyi | 4 +- stdlib/distutils/text_file.pyi | 4 +- stdlib/distutils/util.pyi | 8 +- stdlib/distutils/version.pyi | 6 +- stdlib/doctest.pyi | 48 +- stdlib/email/_header_value_parser.pyi | 14 +- stdlib/email/charset.pyi | 10 +- stdlib/email/errors.pyi | 4 +- stdlib/email/generator.pyi | 24 +- stdlib/email/header.pyi | 14 +- stdlib/email/headerregistry.pyi | 14 +- stdlib/email/iterators.pyi | 2 +- stdlib/email/message.pyi | 42 +- stdlib/email/mime/application.pyi | 4 +- stdlib/email/mime/audio.pyi | 6 +- stdlib/email/mime/base.pyi | 4 +- 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/policy.pyi | 4 +- stdlib/email/utils.pyi | 20 +- stdlib/encodings/__init__.pyi | 2 +- stdlib/encodings/utf_8.pyi | 10 +- stdlib/ensurepip/__init__.pyi | 2 +- stdlib/formatter.pyi | 32 +- stdlib/fractions.pyi | 2 +- stdlib/ftplib.pyi | 30 +- stdlib/functools.pyi | 6 +- stdlib/gc.pyi | 2 +- stdlib/getpass.pyi | 2 +- stdlib/gettext.pyi | 22 +- stdlib/glob.pyi | 4 +- stdlib/grp.pyi | 2 +- stdlib/gzip.pyi | 48 +- stdlib/hashlib.pyi | 10 +- stdlib/hmac.pyi | 6 +- stdlib/html/parser.pyi | 6 +- stdlib/http/client.pyi | 56 +- stdlib/http/cookiejar.pyi | 46 +- stdlib/http/cookies.pyi | 4 +- stdlib/http/server.pyi | 12 +- stdlib/imaplib.pyi | 38 +- stdlib/imghdr.pyi | 6 +- stdlib/imp.pyi | 10 +- stdlib/importlib/__init__.pyi | 4 +- stdlib/importlib/abc.pyi | 28 +- stdlib/importlib/machinery.pyi | 44 +- stdlib/importlib/metadata.pyi | 14 +- stdlib/importlib/util.pyi | 16 +- stdlib/inspect.pyi | 48 +- stdlib/io.pyi | 46 +- stdlib/ipaddress.pyi | 8 +- stdlib/itertools.pyi | 10 +- stdlib/json/encoder.pyi | 2 +- stdlib/lib2to3/pgen2/driver.pyi | 6 +- stdlib/lib2to3/pgen2/grammar.pyi | 2 +- stdlib/lib2to3/pgen2/parse.pyi | 16 +- stdlib/lib2to3/pgen2/pgen.pyi | 6 +- stdlib/lib2to3/pytree.pyi | 32 +- stdlib/linecache.pyi | 8 +- stdlib/locale.pyi | 2 +- stdlib/logging/__init__.pyi | 92 +-- stdlib/logging/config.pyi | 4 +- stdlib/logging/handlers.pyi | 54 +- stdlib/lzma.pyi | 64 +-- stdlib/macpath.pyi | 2 +- stdlib/mailbox.pyi | 22 +- stdlib/mailcap.pyi | 2 +- stdlib/math.pyi | 2 +- stdlib/mimetypes.pyi | 10 +- stdlib/mmap.pyi | 4 +- stdlib/modulefinder.pyi | 14 +- stdlib/msilib/__init__.pyi | 54 +- stdlib/msilib/schema.pyi | 2 +- stdlib/msilib/sequence.pyi | 2 +- stdlib/msilib/text.pyi | 4 +- stdlib/multiprocessing/__init__.pyi | 14 +- stdlib/multiprocessing/connection.pyi | 18 +- stdlib/multiprocessing/context.pyi | 20 +- stdlib/multiprocessing/dummy/__init__.pyi | 6 +- stdlib/multiprocessing/dummy/connection.pyi | 6 +- stdlib/multiprocessing/managers.pyi | 22 +- stdlib/multiprocessing/pool.pyi | 28 +- stdlib/multiprocessing/process.pyi | 14 +- stdlib/multiprocessing/queues.pyi | 4 +- stdlib/multiprocessing/shared_memory.pyi | 4 +- stdlib/multiprocessing/sharedctypes.pyi | 28 +- stdlib/multiprocessing/spawn.pyi | 2 +- stdlib/multiprocessing/synchronize.pyi | 16 +- stdlib/netrc.pyi | 12 +- stdlib/nntplib.pyi | 22 +- stdlib/numbers.pyi | 2 +- stdlib/opcode.pyi | 4 +- stdlib/optparse.pyi | 58 +- stdlib/os/__init__.pyi | 102 ++-- stdlib/pathlib.pyi | 20 +- stdlib/pdb.pyi | 92 +-- stdlib/pickle.pyi | 12 +- stdlib/pickletools.pyi | 6 +- stdlib/pkgutil.pyi | 8 +- stdlib/platform.pyi | 2 +- stdlib/plistlib.pyi | 8 +- stdlib/poplib.pyi | 10 +- stdlib/posix.pyi | 2 +- stdlib/posixpath.pyi | 6 +- stdlib/pprint.pyi | 22 +- stdlib/profile.pyi | 6 +- stdlib/py_compile.pyi | 20 +- stdlib/pyclbr.pyi | 4 +- stdlib/pydoc.pyi | 82 +-- stdlib/pyexpat/__init__.pyi | 24 +- stdlib/queue.pyi | 8 +- stdlib/random.pyi | 6 +- stdlib/readline.pyi | 10 +- stdlib/rlcompleter.pyi | 2 +- stdlib/runpy.pyi | 4 +- stdlib/sched.pyi | 2 +- stdlib/secrets.pyi | 6 +- stdlib/select.pyi | 14 +- stdlib/selectors.pyi | 14 +- stdlib/shelve.pyi | 8 +- stdlib/shlex.pyi | 6 +- stdlib/shutil.pyi | 22 +- stdlib/signal.pyi | 4 +- stdlib/site.pyi | 6 +- stdlib/smtpd.pyi | 10 +- stdlib/smtplib.pyi | 46 +- stdlib/sndhdr.pyi | 4 +- stdlib/socket.pyi | 32 +- stdlib/socketserver.pyi | 8 +- stdlib/sqlite3/dbapi2.pyi | 10 +- stdlib/sre_constants.pyi | 6 +- stdlib/sre_parse.pyi | 20 +- stdlib/ssl.pyi | 116 ++-- stdlib/statistics.pyi | 10 +- stdlib/string.pyi | 4 +- stdlib/subprocess.pyi | 532 +++++++++--------- stdlib/sunau.pyi | 4 +- stdlib/sys.pyi | 30 +- stdlib/sysconfig.pyi | 4 +- stdlib/tarfile.pyi | 180 +++--- stdlib/telnetlib.pyi | 8 +- stdlib/tempfile.pyi | 200 +++---- stdlib/textwrap.pyi | 4 +- stdlib/threading.pyi | 42 +- stdlib/time.pyi | 6 +- stdlib/tkinter/__init__.pyi | 268 ++++----- stdlib/tkinter/colorchooser.pyi | 2 +- stdlib/tkinter/commondialog.pyi | 6 +- stdlib/tkinter/dialog.pyi | 2 +- stdlib/tkinter/dnd.pyi | 4 +- 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 | 90 +-- stdlib/tkinter/ttk.pyi | 110 ++-- stdlib/tokenize.pyi | 2 +- stdlib/trace.pyi | 14 +- stdlib/traceback.pyi | 64 +-- stdlib/tracemalloc.pyi | 20 +- stdlib/turtle.pyi | 90 +-- stdlib/types.pyi | 32 +- stdlib/typing.pyi | 44 +- stdlib/typing_extensions.pyi | 2 +- stdlib/unittest/__init__.pyi | 2 +- stdlib/unittest/case.pyi | 36 +- stdlib/unittest/loader.pyi | 6 +- stdlib/unittest/main.pyi | 20 +- stdlib/unittest/mock.pyi | 126 ++--- stdlib/unittest/result.pyi | 4 +- stdlib/unittest/runner.pyi | 4 +- stdlib/urllib/error.pyi | 2 +- stdlib/urllib/parse.pyi | 40 +- stdlib/urllib/request.pyi | 138 ++--- stdlib/urllib/response.pyi | 6 +- stdlib/urllib/robotparser.pyi | 4 +- stdlib/uu.pyi | 6 +- stdlib/uuid.pyi | 28 +- stdlib/venv/__init__.pyi | 10 +- stdlib/warnings.pyi | 26 +- stdlib/wave.pyi | 4 +- stdlib/weakref.pyi | 4 +- stdlib/webbrowser.pyi | 6 +- 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/etree/ElementInclude.pyi | 6 +- stdlib/xml/etree/ElementPath.pyi | 4 +- stdlib/xml/etree/ElementTree.pyi | 114 ++-- stdlib/xml/sax/__init__.pyi | 4 +- stdlib/xml/sax/saxutils.pyi | 2 +- stdlib/xml/sax/xmlreader.pyi | 2 +- stdlib/xmlrpc/client.pyi | 48 +- stdlib/xmlrpc/server.pyi | 30 +- stdlib/zipapp.pyi | 8 +- stdlib/zipfile.pyi | 62 +- stdlib/zipimport.pyi | 10 +- stdlib/zlib.pyi | 2 +- stdlib/zoneinfo/__init__.pyi | 2 +- 505 files changed, 4905 insertions(+), 4905 deletions(-) diff --git a/stdlib/@python2/BaseHTTPServer.pyi b/stdlib/@python2/BaseHTTPServer.pyi index b044006f7e74..a9ef767a9c3a 100644 --- a/stdlib/@python2/BaseHTTPServer.pyi +++ b/stdlib/@python2/BaseHTTPServer.pyi @@ -27,8 +27,8 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler): 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 send_error(self, code: int, message: Optional[str] = ...) -> None: ... - def send_response(self, code: int, message: Optional[str] = ...) -> None: ... + def send_error(self, code: int, message: str | None = ...) -> None: ... + def send_response(self, code: int, message: str | None = ...) -> None: ... def send_header(self, keyword: str, value: str) -> None: ... def end_headers(self) -> None: ... def flush_headers(self) -> None: ... @@ -36,6 +36,6 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler): 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: ... diff --git a/stdlib/@python2/Cookie.pyi b/stdlib/@python2/Cookie.pyi index 91dd93221c73..c2249577ba3a 100644 --- a/stdlib/@python2/Cookie.pyi +++ b/stdlib/@python2/Cookie.pyi @@ -10,17 +10,17 @@ class Morsel(Dict[Any, Any]): value: Any coded_value: Any def set(self, key, val, coded_val, LegalChars=..., idmap=..., translate=...): ... - def output(self, attrs: Optional[Any] = ..., header=...): ... - def js_output(self, attrs: Optional[Any] = ...): ... - def OutputString(self, attrs: Optional[Any] = ...): ... + def output(self, attrs: Any | None = ..., header=...): ... + def js_output(self, attrs: Any | None = ...): ... + def OutputString(self, attrs: Any | None = ...): ... class BaseCookie(Dict[Any, Any]): def value_decode(self, val): ... def value_encode(self, val): ... - def __init__(self, input: Optional[Any] = ...): ... + def __init__(self, input: Any | None = ...): ... def __setitem__(self, key, value): ... - def output(self, attrs: Optional[Any] = ..., header=..., sep=...): ... - def js_output(self, attrs: Optional[Any] = ...): ... + def output(self, attrs: Any | None = ..., header=..., sep=...): ... + def js_output(self, attrs: Any | None = ...): ... def load(self, rawdata): ... class SimpleCookie(BaseCookie): @@ -28,12 +28,12 @@ class SimpleCookie(BaseCookie): def value_encode(self, val): ... class SerialCookie(BaseCookie): - def __init__(self, input: Optional[Any] = ...): ... + def __init__(self, input: Any | None = ...): ... def value_decode(self, val): ... def value_encode(self, val): ... class SmartCookie(BaseCookie): - def __init__(self, input: Optional[Any] = ...): ... + def __init__(self, input: Any | None = ...): ... def value_decode(self, val): ... def value_encode(self, val): ... diff --git a/stdlib/@python2/Queue.pyi b/stdlib/@python2/Queue.pyi index 5297a4b76034..311c304c1a4d 100644 --- a/stdlib/@python2/Queue.pyi +++ b/stdlib/@python2/Queue.pyi @@ -19,9 +19,9 @@ class Queue(Generic[_T]): def qsize(self) -> int: ... def empty(self) -> bool: ... def full(self) -> bool: ... - 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 get(self, block: bool = ..., timeout: Optional[float] = ...) -> _T: ... + def get(self, block: bool = ..., timeout: float | None = ...) -> _T: ... def get_nowait(self) -> _T: ... class PriorityQueue(Queue[_T]): ... diff --git a/stdlib/@python2/SocketServer.pyi b/stdlib/@python2/SocketServer.pyi index 5ae17c74edf2..44827e06e538 100644 --- a/stdlib/@python2/SocketServer.pyi +++ b/stdlib/@python2/SocketServer.pyi @@ -10,7 +10,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: ... @@ -60,7 +60,7 @@ if sys.platform != "win32": if sys.platform != "win32": class ForkingMixIn: - timeout: Optional[float] # undocumented + timeout: float | None # undocumented active_children: Optional[List[int]] # undocumented max_children: int # undocumented def collect_children(self) -> None: ... # undocumented @@ -101,7 +101,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: SocketType # Undocumented rfile: BinaryIO diff --git a/stdlib/@python2/StringIO.pyi b/stdlib/@python2/StringIO.pyi index 4470b4fc1ad0..9e5a0c1316d3 100644 --- a/stdlib/@python2/StringIO.pyi +++ b/stdlib/@python2/StringIO.pyi @@ -15,7 +15,7 @@ class StringIO(IO[AnyStr], Generic[AnyStr]): def read(self, n: int = ...) -> AnyStr: ... def readline(self, length: int = ...) -> AnyStr: ... def readlines(self, sizehint: int = ...) -> List[AnyStr]: ... - 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 flush(self) -> None: ... diff --git a/stdlib/@python2/UserDict.pyi b/stdlib/@python2/UserDict.pyi index 98009d6a84e8..f8d1aab9a8f5 100644 --- a/stdlib/@python2/UserDict.pyi +++ b/stdlib/@python2/UserDict.pyi @@ -33,7 +33,7 @@ class DictMixin(Iterable[_KT], Container[_KT], Sized, Generic[_KT, _VT]): # From typing.Mapping[_KT, _VT] # (can't inherit because of keys()) @overload - def get(self, k: _KT) -> Optional[_VT]: ... + def get(self, k: _KT) -> _VT | None: ... @overload def get(self, k: _KT, default: _VT | _T) -> _VT | _T: ... def values(self) -> List[_VT]: ... diff --git a/stdlib/@python2/UserString.pyi b/stdlib/@python2/UserString.pyi index 2e383fe1ddb5..0abe36516140 100644 --- a/stdlib/@python2/UserString.pyi +++ b/stdlib/@python2/UserString.pyi @@ -24,9 +24,9 @@ class UserString(Sequence[UserString]): def capitalize(self: _UST) -> _UST: ... def center(self: _UST, width: int, *args: Any) -> _UST: ... def count(self, sub: int, start: int = ..., end: int = ...) -> int: ... - def decode(self: _UST, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UST: ... - def encode(self: _UST, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UST: ... - def endswith(self, suffix: Text | Tuple[Text, ...], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ... + def decode(self: _UST, encoding: str | None = ..., errors: str | None = ...) -> _UST: ... + def encode(self: _UST, encoding: str | None = ..., errors: str | None = ...) -> _UST: ... + def endswith(self, suffix: Text | Tuple[Text, ...], start: int | None = ..., end: int | None = ...) -> bool: ... def expandtabs(self: _UST, tabsize: int = ...) -> _UST: ... def find(self, sub: Text, start: int = ..., end: int = ...) -> int: ... def index(self, sub: Text, start: int = ..., end: int = ...) -> int: ... @@ -42,19 +42,19 @@ class UserString(Sequence[UserString]): def join(self, seq: Iterable[Text]) -> Text: ... def ljust(self: _UST, width: int, *args: Any) -> _UST: ... def lower(self: _UST) -> _UST: ... - def lstrip(self: _UST, chars: Optional[Text] = ...) -> _UST: ... + def lstrip(self: _UST, chars: Text | None = ...) -> _UST: ... def partition(self, sep: Text) -> Tuple[Text, Text, Text]: ... def replace(self: _UST, old: Text, new: Text, maxsplit: int = ...) -> _UST: ... def rfind(self, sub: Text, start: int = ..., end: int = ...) -> int: ... def rindex(self, sub: Text, start: int = ..., end: int = ...) -> int: ... def rjust(self: _UST, width: int, *args: Any) -> _UST: ... def rpartition(self, sep: Text) -> Tuple[Text, Text, Text]: ... - def rstrip(self: _UST, chars: Optional[Text] = ...) -> _UST: ... - def split(self, sep: Optional[Text] = ..., maxsplit: int = ...) -> List[Text]: ... - def rsplit(self, sep: Optional[Text] = ..., maxsplit: int = ...) -> List[Text]: ... + def rstrip(self: _UST, chars: Text | None = ...) -> _UST: ... + def split(self, sep: Text | None = ..., maxsplit: int = ...) -> List[Text]: ... + def rsplit(self, sep: Text | None = ..., maxsplit: int = ...) -> List[Text]: ... def splitlines(self, keepends: int = ...) -> List[Text]: ... - def startswith(self, prefix: Text | Tuple[Text, ...], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ... - def strip(self: _UST, chars: Optional[Text] = ...) -> _UST: ... + def startswith(self, prefix: Text | Tuple[Text, ...], start: int | None = ..., end: int | None = ...) -> bool: ... + def strip(self: _UST, chars: Text | None = ...) -> _UST: ... def swapcase(self: _UST) -> _UST: ... def title(self: _UST) -> _UST: ... def translate(self: _UST, *args: Any) -> _UST: ... diff --git a/stdlib/@python2/__builtin__.pyi b/stdlib/@python2/__builtin__.pyi index 05e7af3f542f..4f7395590d52 100644 --- a/stdlib/@python2/__builtin__.pyi +++ b/stdlib/@python2/__builtin__.pyi @@ -66,7 +66,7 @@ _TT = TypeVar("_TT", bound="type") _TBE = TypeVar("_TBE", bound="BaseException") class object: - __doc__: Optional[str] + __doc__: str | None __dict__: Dict[str, Any] __slots__: Text | Iterable[Text] __module__: str @@ -167,10 +167,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: ... @@ -296,7 +296,7 @@ class unicode(basestring, Sequence[unicode]): def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ... def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... def endswith( - self, __suffix: unicode | Tuple[unicode, ...], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __suffix: unicode | Tuple[unicode, ...], __start: int | None = ..., __end: int | None = ... ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> unicode: ... def find(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... @@ -323,12 +323,12 @@ class unicode(basestring, Sequence[unicode]): def rindex(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... def rjust(self, width: int, fillchar: unicode = ...) -> unicode: ... def rpartition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... - def rsplit(self, sep: Optional[unicode] = ..., maxsplit: int = ...) -> List[unicode]: ... + def rsplit(self, sep: unicode | None = ..., maxsplit: int = ...) -> List[unicode]: ... def rstrip(self, chars: unicode = ...) -> unicode: ... - def split(self, sep: Optional[unicode] = ..., maxsplit: int = ...) -> List[unicode]: ... + def split(self, sep: unicode | None = ..., maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[unicode]: ... def startswith( - self, __prefix: unicode | Tuple[unicode, ...], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __prefix: unicode | Tuple[unicode, ...], __start: int | None = ..., __end: int | None = ... ) -> bool: ... def strip(self, chars: unicode = ...) -> unicode: ... def swapcase(self) -> unicode: ... @@ -369,17 +369,17 @@ class str(Sequence[str], basestring): def __init__(self, o: object = ...) -> None: ... def capitalize(self) -> str: ... def center(self, __width: int, __fillchar: str = ...) -> str: ... - def count(self, x: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def count(self, x: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... def encode(self, encoding: Text = ..., errors: Text = ...) -> bytes: ... def endswith( - self, __suffix: Text | Tuple[Text, ...], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __suffix: Text | Tuple[Text, ...], __start: int | None = ..., __end: int | None = ... ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> str: ... - def find(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def find(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... def format(self, *args: object, **kwargs: object) -> str: ... def format_map(self, map: _FormatMapMapping) -> str: ... - def index(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def index(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... def isdigit(self) -> bool: ... @@ -401,8 +401,8 @@ class str(Sequence[str], basestring): @overload def partition(self, __sep: unicode) -> Tuple[unicode, unicode, unicode]: ... def replace(self, __old: AnyStr, __new: AnyStr, __count: int = ...) -> AnyStr: ... - def rfind(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... - def rindex(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def rfind(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... + def rindex(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... def rjust(self, __width: int, __fillchar: str = ...) -> str: ... @overload def rpartition(self, __sep: bytearray) -> Tuple[str, bytearray, str]: ... @@ -411,7 +411,7 @@ class str(Sequence[str], basestring): @overload def rpartition(self, __sep: unicode) -> Tuple[unicode, unicode, unicode]: ... @overload - def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... + def rsplit(self, sep: str | None = ..., maxsplit: int = ...) -> List[str]: ... @overload def rsplit(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ... @overload @@ -419,12 +419,12 @@ class str(Sequence[str], basestring): @overload def rstrip(self, __chars: unicode) -> unicode: ... @overload - def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... + def split(self, sep: str | None = ..., maxsplit: int = ...) -> List[str]: ... @overload def split(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[str]: ... def startswith( - self, __prefix: Text | Tuple[Text, ...], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __prefix: Text | Tuple[Text, ...], __start: int | None = ..., __end: int | None = ... ) -> bool: ... @overload def strip(self, __chars: str = ...) -> str: ... @@ -432,7 +432,7 @@ class str(Sequence[str], basestring): def strip(self, chars: unicode) -> unicode: ... def swapcase(self) -> str: ... def title(self) -> str: ... - def translate(self, __table: Optional[AnyStr], deletechars: AnyStr = ...) -> AnyStr: ... + def translate(self, __table: AnyStr | None, deletechars: AnyStr = ...) -> AnyStr: ... def upper(self) -> str: ... def zfill(self, __width: int) -> str: ... def __add__(self, s: AnyStr) -> AnyStr: ... @@ -476,7 +476,7 @@ class bytearray(MutableSequence[int], ByteString): def count(self, __sub: str) -> int: ... def decode(self, encoding: Text = ..., errors: Text = ...) -> str: ... def endswith( - self, __suffix: bytes | Tuple[bytes, ...], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __suffix: bytes | Tuple[bytes, ...], __start: int | None = ..., __end: int | None = ... ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> bytearray: ... def extend(self, iterable: str | Iterable[int]) -> None: ... @@ -493,21 +493,21 @@ class bytearray(MutableSequence[int], ByteString): def join(self, __iterable: Iterable[str]) -> bytearray: ... def ljust(self, __width: int, __fillchar: str = ...) -> 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]: ... def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytearray: ... def rfind(self, __sub: bytes, __start: int = ..., __end: int = ...) -> int: ... def rindex(self, __sub: bytes, __start: int = ..., __end: int = ...) -> int: ... def rjust(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... def rpartition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... - def rsplit(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... - def rstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... - def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... + def rsplit(self, sep: bytes | None = ..., maxsplit: int = ...) -> List[bytearray]: ... + def rstrip(self, __bytes: bytes | None = ...) -> bytearray: ... + def split(self, sep: bytes | None = ..., maxsplit: int = ...) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... def startswith( - self, __prefix: bytes | Tuple[bytes, ...], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __prefix: bytes | Tuple[bytes, ...], __start: int | None = ..., __end: int | 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: str) -> bytearray: ... @@ -746,13 +746,13 @@ class set(MutableSet[_T], Generic[_T]): def __or__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... def __ior__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... @overload - def __sub__(self: Set[str], s: AbstractSet[Optional[Text]]) -> Set[_T]: ... + def __sub__(self: Set[str], s: AbstractSet[Text | None]) -> Set[_T]: ... @overload - def __sub__(self, s: AbstractSet[Optional[_T]]) -> Set[_T]: ... + def __sub__(self, s: AbstractSet[_T | None]) -> Set[_T]: ... @overload # type: ignore - def __isub__(self: Set[str], s: AbstractSet[Optional[Text]]) -> Set[_T]: ... + def __isub__(self: Set[str], s: AbstractSet[Text | None]) -> Set[_T]: ... @overload - def __isub__(self, s: AbstractSet[Optional[_T]]) -> 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: ... @@ -805,12 +805,12 @@ class property(object): fget: Optional[Callable[[Any], Any]] = ..., fset: Optional[Callable[[Any, Any], None]] = ..., fdel: Optional[Callable[[Any], None]] = ..., - doc: Optional[str] = ..., + 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: ... def fget(self) -> Any: ... @@ -853,11 +853,11 @@ def exit(code: object = ...) -> NoReturn: ... @overload def filter(__function: Callable[[AnyStr], Any], __iterable: AnyStr) -> AnyStr: ... # type: ignore @overload -def filter(__function: None, __iterable: Tuple[Optional[_T], ...]) -> Tuple[_T, ...]: ... # type: ignore +def filter(__function: None, __iterable: Tuple[_T | None, ...]) -> Tuple[_T, ...]: ... # type: ignore @overload def filter(__function: Callable[[_T], Any], __iterable: Tuple[_T, ...]) -> Tuple[_T, ...]: ... # type: ignore @overload -def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> List[_T]: ... +def filter(__function: None, __iterable: Iterable[_T | None]) -> List[_T]: ... @overload def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> List[_T]: ... def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicode @@ -867,7 +867,7 @@ def getattr(__o: Any, name: Text) -> 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: Text, __default: None) -> Optional[Any]: ... +def getattr(__o: Any, name: Text, __default: None) -> Any | None: ... @overload def getattr(__o: Any, name: Text, __default: bool) -> Any | bool: ... @overload @@ -882,7 +882,7 @@ def intern(__string: str) -> 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]: ... def isinstance(__obj: object, __class_or_tuple: Union[type, Tuple[type | Tuple[Any, ...], ...]]) -> bool: ... @@ -973,7 +973,7 @@ def ord(__c: Text | bytes) -> int: ... # This is only available after from __future__ import print_function. def print( - *values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[SupportsWrite[Any]] = ... + *values: object, sep: Text | None = ..., end: Text | None = ..., file: Optional[SupportsWrite[Any]] = ... ) -> None: ... _E = TypeVar("_E", contravariant=True) @@ -1119,10 +1119,10 @@ class RuntimeError(_StandardError): ... 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 class SystemError(_StandardError): ... class TypeError(_StandardError): ... @@ -1182,8 +1182,8 @@ class file(BinaryIO): def read(self, n: int = ...) -> str: ... def __enter__(self) -> BinaryIO: ... def __exit__( - self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ... - ) -> Optional[bool]: ... + self, t: type | None = ..., exc: BaseException | None = ..., tb: Any | None = ... + ) -> bool | None: ... def flush(self) -> None: ... def fileno(self) -> int: ... def isatty(self) -> bool: ... @@ -1197,4 +1197,4 @@ class file(BinaryIO): def readlines(self, hint: int = ...) -> List[str]: ... def write(self, data: str) -> int: ... def writelines(self, data: Iterable[str]) -> None: ... - def truncate(self, pos: Optional[int] = ...) -> int: ... + def truncate(self, pos: int | None = ...) -> int: ... diff --git a/stdlib/@python2/_ast.pyi b/stdlib/@python2/_ast.pyi index 4ca7def60b04..42922f2d640f 100644 --- a/stdlib/@python2/_ast.pyi +++ b/stdlib/@python2/_ast.pyi @@ -41,7 +41,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] @@ -56,7 +56,7 @@ class AugAssign(stmt): value: expr class Print(stmt): - dest: Optional[expr] + dest: expr | None values: typing.List[expr] nl: bool @@ -78,13 +78,13 @@ class If(stmt): class With(stmt): context_expr: expr - optional_vars: Optional[expr] + optional_vars: expr | None body: typing.List[stmt] 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] @@ -97,20 +97,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] @@ -126,9 +126,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] @@ -189,7 +189,7 @@ class GeneratorExp(expr): generators: typing.List[comprehension] class Yield(expr): - value: Optional[expr] + value: expr | None class Compare(expr): left: expr @@ -200,8 +200,8 @@ 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 @@ -282,16 +282,16 @@ class comprehension(AST): class excepthandler(AST): ... class ExceptHandler(excepthandler): - 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] class keyword(AST): @@ -300,4 +300,4 @@ class keyword(AST): class alias(AST): name: _identifier - asname: Optional[_identifier] + asname: _identifier | None diff --git a/stdlib/@python2/_bisect.pyi b/stdlib/@python2/_bisect.pyi index 1e909c2a77d3..1467bb336315 100644 --- a/stdlib/@python2/_bisect.pyi +++ b/stdlib/@python2/_bisect.pyi @@ -2,7 +2,7 @@ from typing import MutableSequence, Optional, Sequence, TypeVar _T = TypeVar("_T") -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/@python2/_codecs.pyi b/stdlib/@python2/_codecs.pyi index 5361aea802b6..ab8f9938765d 100644 --- a/stdlib/@python2/_codecs.pyi +++ b/stdlib/@python2/_codecs.pyi @@ -25,8 +25,8 @@ def charmap_build(__map: Text) -> _MapT: ... def ascii_decode(__data: _Decodable, __errors: _Errors = ...) -> Tuple[Text, int]: ... def ascii_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... def charbuffer_encode(__data: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... -def charmap_decode(__data: _Decodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[Text, int]: ... -def charmap_encode(__str: _Encodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[bytes, int]: ... +def charmap_decode(__data: _Decodable, __errors: _Errors = ..., __mapping: _MapT | None = ...) -> Tuple[Text, int]: ... +def charmap_encode(__str: _Encodable, __errors: _Errors = ..., __mapping: _MapT | None = ...) -> Tuple[bytes, int]: ... def escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[str, int]: ... def escape_encode(__data: bytes, __errors: _Errors = ...) -> Tuple[bytes, int]: ... def latin_1_decode(__data: _Decodable, __errors: _Errors = ...) -> Tuple[Text, int]: ... diff --git a/stdlib/@python2/_collections.pyi b/stdlib/@python2/_collections.pyi index da1a96b630df..1241f79c6e04 100644 --- a/stdlib/@python2/_collections.pyi +++ b/stdlib/@python2/_collections.pyi @@ -13,7 +13,7 @@ class defaultdict(Dict[_K, _V]): def copy(self: _T) -> _T: ... class deque(Generic[_T]): - maxlen: Optional[int] + maxlen: int | None def __init__(self, iterable: Iterator[_T] = ..., maxlen: int = ...) -> None: ... def append(self, x: _T) -> None: ... def appendleft(self, x: _T) -> None: ... diff --git a/stdlib/@python2/_csv.pyi b/stdlib/@python2/_csv.pyi index 53a18531d518..277bc1465eae 100644 --- a/stdlib/@python2/_csv.pyi +++ b/stdlib/@python2/_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/@python2/_curses.pyi b/stdlib/@python2/_curses.pyi index 373ad94d01d6..4f78c78ba908 100644 --- a/stdlib/@python2/_curses.pyi +++ b/stdlib/@python2/_curses.pyi @@ -319,7 +319,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: ... diff --git a/stdlib/@python2/_dummy_threading.pyi b/stdlib/@python2/_dummy_threading.pyi index 06392616484e..44b81fe337bf 100644 --- a/stdlib/@python2/_dummy_threading.pyi +++ b/stdlib/@python2/_dummy_threading.pyi @@ -15,7 +15,7 @@ def current_thread() -> Thread: ... def currentThread() -> Thread: ... def enumerate() -> List[Thread]: ... def settrace(func: _TF) -> None: ... -def setprofile(func: Optional[_PF]) -> None: ... +def setprofile(func: _PF | None) -> None: ... def stack_size(size: int = ...) -> int: ... class ThreadError(Exception): ... @@ -27,19 +27,19 @@ 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[Text] = ..., + name: Text | None = ..., args: Iterable[Any] = ..., kwargs: Optional[Mapping[Text, Any]] = ..., ) -> 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: Text) -> None: ... def is_alive(self) -> bool: ... @@ -53,8 +53,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: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... def locked(self) -> bool: ... @@ -63,8 +63,8 @@ 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: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... @@ -74,11 +74,11 @@ class Condition: 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: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... - def wait(self, timeout: Optional[float] = ...) -> bool: ... + def wait(self, timeout: float | None = ...) -> bool: ... def notify(self, n: int = ...) -> None: ... def notify_all(self) -> None: ... def notifyAll(self) -> None: ... @@ -86,8 +86,8 @@ 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]: ... + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def __enter__(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... @@ -100,7 +100,7 @@ class Event: def isSet(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 Timer(Thread): def __init__( diff --git a/stdlib/@python2/_io.pyi b/stdlib/@python2/_io.pyi index 369a53bc9f27..5e3ebcf0ed8b 100644 --- a/stdlib/@python2/_io.pyi +++ b/stdlib/@python2/_io.pyi @@ -15,7 +15,7 @@ _T = TypeVar("_T") class _IOBase(BinaryIO): @property def closed(self) -> bool: ... - def _checkClosed(self, msg: Optional[str] = ...) -> None: ... # undocumented + def _checkClosed(self, msg: str | None = ...) -> None: ... # undocumented def _checkReadable(self) -> None: ... def _checkSeekable(self) -> None: ... def _checkWritable(self) -> None: ... @@ -28,12 +28,12 @@ class _IOBase(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 __enter__(self: _T) -> _T: ... def __exit__( - self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any] - ) -> Optional[bool]: ... + self, t: Optional[Type[BaseException]], value: BaseException | None, traceback: Any | None + ) -> bool | None: ... def __iter__(self: _T) -> _T: ... # The parameter type of writelines[s]() is determined by that of write(): def writelines(self, lines: Iterable[bytes]) -> None: ... @@ -113,7 +113,7 @@ class IncrementalNewlineDecoder(object): # Note: In the actual _io.py, _TextIOBase inherits from _IOBase. class _TextIOBase(TextIO): - errors: Optional[str] + errors: str | None # TODO: On _TextIOBase, this is always None. But it's unicode/bytes in subclasses. newlines: None | unicode | bytes encoding: str @@ -136,19 +136,19 @@ class _TextIOBase(TextIO): 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, pbuf: unicode) -> int: ... def writelines(self, lines: Iterable[unicode]) -> None: ... def __enter__(self: _T) -> _T: ... def __exit__( - self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any] - ) -> Optional[bool]: ... + self, t: Optional[Type[BaseException]], value: BaseException | None, traceback: Any | None + ) -> bool | None: ... def __iter__(self: _T) -> _T: ... class StringIO(_TextIOBase): line_buffering: bool - def __init__(self, initial_value: Optional[unicode] = ..., newline: Optional[unicode] = ...) -> None: ... + def __init__(self, initial_value: unicode | None = ..., newline: unicode | None = ...) -> None: ... def __setstate__(self, state: Tuple[Any, ...]) -> None: ... def __getstate__(self) -> Tuple[Any, ...]: ... # StringIO does not contain a "name" field. This workaround is necessary @@ -165,9 +165,9 @@ class TextIOWrapper(_TextIOBase): def __init__( self, buffer: IO[Any], - encoding: Optional[Text] = ..., - errors: Optional[Text] = ..., - newline: Optional[Text] = ..., + encoding: Text | None = ..., + errors: Text | None = ..., + newline: Text | None = ..., line_buffering: bool = ..., write_through: bool = ..., ) -> None: ... @@ -176,8 +176,8 @@ def open( file: str | unicode | int, mode: Text = ..., buffering: int = ..., - encoding: Optional[Text] = ..., - errors: Optional[Text] = ..., - newline: Optional[Text] = ..., + encoding: Text | None = ..., + errors: Text | None = ..., + newline: Text | None = ..., closefd: bool = ..., ) -> IO[Any]: ... diff --git a/stdlib/@python2/_msi.pyi b/stdlib/@python2/_msi.pyi index a026d4259c1e..f70a6df31a74 100644 --- a/stdlib/@python2/_msi.pyi +++ b/stdlib/@python2/_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,7 +15,7 @@ if sys.platform == "win32": __init__: None # type: ignore # Actual typename Summary, not exposed by the implementation class _Summary: - def GetProperty(self, propid: int) -> Optional[str | bytes]: ... + def GetProperty(self, propid: int) -> str | bytes | None: ... def GetPropertyCount(self) -> int: ... def SetProperty(self, propid: int, value: str | bytes) -> None: ... def Persist(self) -> None: ... diff --git a/stdlib/@python2/_osx_support.pyi b/stdlib/@python2/_osx_support.pyi index 90d7015bb16e..0362ebef3a2f 100644 --- a/stdlib/@python2/_osx_support.pyi +++ b/stdlib/@python2/_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 diff --git a/stdlib/@python2/_sha256.pyi b/stdlib/@python2/_sha256.pyi index b6eb47d4bc83..38b80d09b736 100644 --- a/stdlib/@python2/_sha256.pyi +++ b/stdlib/@python2/_sha256.pyi @@ -5,7 +5,7 @@ class sha224(object): block_size: int digest_size: int digestsize: int - def __init__(self, init: Optional[str]) -> None: ... + def __init__(self, init: str | None) -> None: ... def copy(self) -> sha224: ... def digest(self) -> str: ... def hexdigest(self) -> str: ... @@ -16,7 +16,7 @@ class sha256(object): block_size: int digest_size: int digestsize: int - def __init__(self, init: Optional[str]) -> None: ... + def __init__(self, init: str | None) -> None: ... def copy(self) -> sha256: ... def digest(self) -> str: ... def hexdigest(self) -> str: ... diff --git a/stdlib/@python2/_sha512.pyi b/stdlib/@python2/_sha512.pyi index b1ca9aee004c..51a0d0ec3259 100644 --- a/stdlib/@python2/_sha512.pyi +++ b/stdlib/@python2/_sha512.pyi @@ -5,7 +5,7 @@ class sha384(object): block_size: int digest_size: int digestsize: int - def __init__(self, init: Optional[str]) -> None: ... + def __init__(self, init: str | None) -> None: ... def copy(self) -> sha384: ... def digest(self) -> str: ... def hexdigest(self) -> str: ... @@ -16,7 +16,7 @@ class sha512(object): block_size: int digest_size: int digestsize: int - def __init__(self, init: Optional[str]) -> None: ... + def __init__(self, init: str | None) -> None: ... def copy(self) -> sha512: ... def digest(self) -> str: ... def hexdigest(self) -> str: ... diff --git a/stdlib/@python2/_socket.pyi b/stdlib/@python2/_socket.pyi index 5db23583604f..1782d4c4dd9b 100644 --- a/stdlib/@python2/_socket.pyi +++ b/stdlib/@python2/_socket.pyi @@ -277,5 +277,5 @@ class SocketType(object): def sendto(self, data: str, flags: int, address: Tuple[Any, ...]) -> int: ... def setblocking(self, flag: bool) -> None: ... def setsockopt(self, level: int, option: int, value: int | str) -> None: ... - def settimeout(self, value: Optional[float]) -> None: ... + def settimeout(self, value: float | None) -> None: ... def shutdown(self, flag: int) -> None: ... diff --git a/stdlib/@python2/_sre.pyi b/stdlib/@python2/_sre.pyi index b13e972cb2c9..1c0a608c259d 100644 --- a/stdlib/@python2/_sre.pyi +++ b/stdlib/@python2/_sre.pyi @@ -12,9 +12,9 @@ class SRE_Match(object): @overload def group(self) -> str: ... @overload - def group(self, group: int = ...) -> Optional[str]: ... - def groupdict(self) -> Dict[int, Optional[str]]: ... - def groups(self) -> Tuple[Optional[str], ...]: ... + def group(self, group: int = ...) -> str | None: ... + def groupdict(self) -> Dict[int, str | None]: ... + def groups(self) -> Tuple[str | None, ...]: ... def span(self) -> Tuple[int, int]: ... @property def regs(self) -> Tuple[Tuple[int, int], ...]: ... # undocumented @@ -35,7 +35,7 @@ class SRE_Pattern(object): def match(self, pattern, pos: int = ..., endpos: int = ...) -> SRE_Match: ... def scanner(self, s: str, start: int = ..., end: int = ...) -> SRE_Scanner: ... def search(self, pattern, pos: int = ..., endpos: int = ...) -> SRE_Match: ... - def split(self, source: str, maxsplit: int = ...) -> List[Optional[str]]: ... + def split(self, source: str, maxsplit: int = ...) -> List[str | None]: ... def sub(self, repl: str, string: str, count: int = ...) -> Tuple[Any, ...]: ... def subn(self, repl: str, string: str, count: int = ...) -> Tuple[Any, ...]: ... diff --git a/stdlib/@python2/_thread.pyi b/stdlib/@python2/_thread.pyi index 46a6c7741024..2fd84f1c5727 100644 --- a/stdlib/@python2/_thread.pyi +++ b/stdlib/@python2/_thread.pyi @@ -13,7 +13,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: Optional[Type[BaseException]], value: BaseException | None, traceback: TracebackType | None ) -> None: ... def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: Dict[str, Any] = ...) -> int: ... diff --git a/stdlib/@python2/_typeshed/wsgi.pyi b/stdlib/@python2/_typeshed/wsgi.pyi index bafaf7bc5f66..a1f10443a6f0 100644 --- a/stdlib/@python2/_typeshed/wsgi.pyi +++ b/stdlib/@python2/_typeshed/wsgi.pyi @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Iterable, List, Optional, Protocol, Text 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[Text, Any] diff --git a/stdlib/@python2/_typeshed/xml.pyi b/stdlib/@python2/_typeshed/xml.pyi index 7ad28aef1b75..1f7bd9aeb1de 100644 --- a/stdlib/@python2/_typeshed/xml.pyi +++ b/stdlib/@python2/_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/@python2/_warnings.pyi b/stdlib/@python2/_warnings.pyi index d16637e6814c..03bd1e5e4991 100644 --- a/stdlib/@python2/_warnings.pyi +++ b/stdlib/@python2/_warnings.pyi @@ -15,7 +15,7 @@ def warn_explicit( category: Type[Warning], filename: str, lineno: int, - module: Optional[str] = ..., + module: str | None = ..., registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., module_globals: Optional[Dict[str, Any]] = ..., ) -> None: ... @@ -25,7 +25,7 @@ def warn_explicit( category: Any, filename: str, lineno: int, - module: Optional[str] = ..., + module: str | None = ..., registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., module_globals: Optional[Dict[str, Any]] = ..., ) -> None: ... diff --git a/stdlib/@python2/_weakref.pyi b/stdlib/@python2/_weakref.pyi index e8882b6f18b8..264e2c63c6d3 100644 --- a/stdlib/@python2/_weakref.pyi +++ b/stdlib/@python2/_weakref.pyi @@ -11,7 +11,7 @@ class ProxyType(Generic[_T]): # "weakproxy" class ReferenceType(Generic[_T]): def __init__(self, o: _T, callback: Optional[Callable[[ReferenceType[_T]], Any]] = ...) -> None: ... - def __call__(self) -> Optional[_T]: ... + def __call__(self) -> _T | None: ... def __hash__(self) -> int: ... ref = ReferenceType diff --git a/stdlib/@python2/_winreg.pyi b/stdlib/@python2/_winreg.pyi index 25acd52e3d8d..0cb985d32bc9 100644 --- a/stdlib/@python2/_winreg.pyi +++ b/stdlib/@python2/_winreg.pyi @@ -4,9 +4,9 @@ from typing import Any, Optional, Tuple, Type, Union _KeyType = 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: ... @@ -18,12 +18,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: 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: ... @@ -90,7 +90,7 @@ class HKEYType: def __int__(self) -> int: ... def __enter__(self) -> HKEYType: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def Close(self) -> None: ... def Detach(self) -> int: ... diff --git a/stdlib/@python2/aifc.pyi b/stdlib/@python2/aifc.pyi index 2021d3f2c8be..0a3aa120d026 100644 --- a/stdlib/@python2/aifc.pyi +++ b/stdlib/@python2/aifc.pyi @@ -65,10 +65,10 @@ 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: ... @overload def openfp(f: _File, mode: Literal["r", "rb"]) -> Aifc_read: ... @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/@python2/argparse.pyi b/stdlib/@python2/argparse.pyi index 33196452f5f9..76a9da9baaf5 100644 --- a/stdlib/@python2/argparse.pyi +++ b/stdlib/@python2/argparse.pyi @@ -34,9 +34,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: @@ -45,7 +45,7 @@ class _AttributeHolder: # undocumented class _ActionsContainer: - description: Optional[_Text] + description: _Text | None prefix_chars: _Text argument_default: Any conflict_handler: _Text @@ -59,7 +59,7 @@ class _ActionsContainer: _negative_number_matcher: Pattern[str] _has_negative_number_optionals: List[bool] def __init__( - self, description: Optional[Text], prefix_chars: Text, argument_default: Any, conflict_handler: Text + self, description: Text | None, prefix_chars: Text, argument_default: Any, conflict_handler: Text ) -> None: ... def register(self, registry_name: Text, value: Any, object: Any) -> None: ... def _registry_get(self, registry_name: Text, value: Any, default: Any = ...) -> Any: ... @@ -75,9 +75,9 @@ class _ActionsContainer: type: Union[Callable[[Text], _T], Callable[[str], _T], FileType] = ..., choices: Iterable[_T] = ..., required: bool = ..., - help: Optional[Text] = ..., + help: Text | None = ..., metavar: Optional[Text | Tuple[Text, ...]] = ..., - dest: Optional[Text] = ..., + dest: Text | None = ..., version: Text = ..., **kwargs: Any, ) -> Action: ... @@ -99,26 +99,26 @@ class _FormatterClass(Protocol): class ArgumentParser(_AttributeHolder, _ActionsContainer): prog: _Text - usage: Optional[_Text] - epilog: Optional[_Text] + usage: _Text | None + epilog: _Text | None formatter_class: _FormatterClass - fromfile_prefix_chars: Optional[_Text] + fromfile_prefix_chars: _Text | None add_help: bool # undocumented _positionals: _ArgumentGroup _optionals: _ArgumentGroup - _subparsers: Optional[_ArgumentGroup] + _subparsers: _ArgumentGroup | None def __init__( self, - prog: Optional[Text] = ..., - usage: Optional[Text] = ..., - description: Optional[Text] = ..., - epilog: Optional[Text] = ..., + prog: Text | None = ..., + usage: Text | None = ..., + description: Text | None = ..., + epilog: Text | None = ..., parents: Sequence[ArgumentParser] = ..., formatter_class: _FormatterClass = ..., prefix_chars: Text = ..., - fromfile_prefix_chars: Optional[Text] = ..., + fromfile_prefix_chars: Text | None = ..., argument_default: Any = ..., conflict_handler: Text = ..., add_help: bool = ..., @@ -139,24 +139,24 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): self, *, title: Text = ..., - description: Optional[Text] = ..., + description: Text | None = ..., prog: Text = ..., parser_class: Type[ArgumentParser] = ..., action: Type[Action] = ..., option_string: Text = ..., - dest: Optional[Text] = ..., - help: Optional[Text] = ..., - metavar: Optional[Text] = ..., + dest: Text | None = ..., + help: Text | None = ..., + metavar: Text | None = ..., ) -> _SubParsersAction: ... def print_usage(self, file: Optional[IO[str]] = ...) -> None: ... def print_help(self, file: Optional[IO[str]] = ...) -> None: ... def format_usage(self) -> str: ... def format_help(self) -> str: ... def parse_known_args( - self, args: Optional[Sequence[Text]] = ..., namespace: Optional[Namespace] = ... + self, args: Optional[Sequence[Text]] = ..., namespace: Namespace | None = ... ) -> Tuple[Namespace, List[str]]: ... def convert_arg_line_to_args(self, arg_line: Text) -> List[str]: ... - def exit(self, status: int = ..., message: Optional[Text] = ...) -> NoReturn: ... + def exit(self, status: int = ..., message: Text | None = ...) -> NoReturn: ... def error(self, message: Text) -> NoReturn: ... # undocumented def _get_optional_actions(self) -> List[Action]: ... @@ -165,8 +165,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def _read_args_from_files(self, arg_strings: List[Text]) -> List[Text]: ... def _match_argument(self, action: Action, arg_strings_pattern: Text) -> int: ... def _match_arguments_partial(self, actions: Sequence[Action], arg_strings_pattern: Text) -> List[int]: ... - def _parse_optional(self, arg_string: Text) -> Optional[Tuple[Optional[Action], Text, Optional[Text]]]: ... - def _get_option_tuples(self, option_string: Text) -> List[Tuple[Action, Text, Optional[Text]]]: ... + def _parse_optional(self, arg_string: Text) -> Optional[Tuple[Action | None, Text, Text | None]]: ... + def _get_option_tuples(self, option_string: Text) -> List[Tuple[Action, Text, Text | None]]: ... def _get_nargs_pattern(self, action: Action) -> _Text: ... def _get_values(self, action: Action, arg_strings: List[Text]) -> Any: ... def _get_value(self, action: Action, arg_string: Text) -> Any: ... @@ -189,23 +189,23 @@ class HelpFormatter: _long_break_matcher: Pattern[str] _Section: Type[Any] # Nested class def __init__( - self, prog: Text, indent_increment: int = ..., max_help_position: int = ..., width: Optional[int] = ... + self, prog: Text, 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[..., _Text], args: Iterable[Any]) -> None: ... - def start_section(self, heading: Optional[Text]) -> None: ... + def start_section(self, heading: Text | None) -> None: ... def end_section(self) -> None: ... - def add_text(self, text: Optional[Text]) -> None: ... + def add_text(self, text: Text | None) -> None: ... def add_usage( - self, usage: Optional[Text], actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Optional[Text] = ... + self, usage: Text | None, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Text | None = ... ) -> None: ... def add_argument(self, action: Action) -> None: ... def add_arguments(self, actions: Iterable[Action]) -> None: ... def format_help(self) -> _Text: ... def _join_parts(self, part_strings: Iterable[Text]) -> _Text: ... def _format_usage( - self, usage: Text, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Optional[Text] + self, usage: Text, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Text | None ) -> _Text: ... def _format_actions_usage(self, actions: Iterable[Action], groups: Iterable[_ArgumentGroup]) -> _Text: ... def _format_text(self, text: Text) -> _Text: ... @@ -217,7 +217,7 @@ class HelpFormatter: def _iter_indented_subactions(self, action: Action) -> Generator[Action, None, None]: ... def _split_lines(self, text: Text, width: int) -> List[_Text]: ... def _fill_text(self, text: Text, width: int, indent: Text) -> _Text: ... - def _get_help_string(self, action: Action) -> Optional[_Text]: ... + def _get_help_string(self, action: Action) -> _Text | None: ... def _get_default_metavar_for_optional(self, action: Action) -> _Text: ... def _get_default_metavar_for_positional(self, action: Action) -> _Text: ... @@ -228,25 +228,25 @@ class ArgumentDefaultsHelpFormatter(HelpFormatter): ... class Action(_AttributeHolder): option_strings: Sequence[_Text] dest: _Text - nargs: Optional[int | _Text] + nargs: int | _Text | None const: Any default: Any type: Union[Callable[[str], Any], FileType, None] choices: Optional[Iterable[Any]] required: bool - help: Optional[_Text] + help: _Text | None metavar: Optional[_Text | Tuple[_Text, ...]] def __init__( self, option_strings: Sequence[Text], dest: Text, - nargs: Optional[int | Text] = ..., - const: Optional[_T] = ..., + nargs: int | Text | None = ..., + const: _T | None = ..., default: _T | str | None = ..., type: Optional[Union[Callable[[Text], _T], Callable[[str], _T], FileType]] = ..., choices: Optional[Iterable[_T]] = ..., required: bool = ..., - help: Optional[Text] = ..., + help: Text | None = ..., metavar: Optional[Text | Tuple[Text, ...]] = ..., ) -> None: ... def __call__( @@ -254,7 +254,7 @@ class Action(_AttributeHolder): parser: ArgumentParser, namespace: Namespace, values: Text | Sequence[Any] | None, - option_string: Optional[Text] = ..., + option_string: Text | None = ..., ) -> None: ... class Namespace(_AttributeHolder): @@ -267,15 +267,15 @@ class FileType: # undocumented _mode: _Text _bufsize: int - def __init__(self, mode: Text = ..., bufsize: Optional[int] = ...) -> None: ... + def __init__(self, mode: Text = ..., bufsize: int | None = ...) -> None: ... def __call__(self, string: Text) -> IO[Any]: ... # undocumented class _ArgumentGroup(_ActionsContainer): - title: Optional[_Text] + title: _Text | None _group_actions: List[Action] def __init__( - self, container: _ActionsContainer, title: Optional[Text] = ..., description: Optional[Text] = ..., **kwargs: Any + self, container: _ActionsContainer, title: Text | None = ..., description: Text | None = ..., **kwargs: Any ) -> None: ... # undocumented @@ -296,20 +296,20 @@ class _StoreConstAction(Action): const: Any, default: Any = ..., required: bool = ..., - help: Optional[Text] = ..., + help: Text | None = ..., metavar: Optional[Text | Tuple[Text, ...]] = ..., ) -> None: ... # undocumented class _StoreTrueAction(_StoreConstAction): def __init__( - self, option_strings: Sequence[Text], dest: Text, default: bool = ..., required: bool = ..., help: Optional[Text] = ... + self, option_strings: Sequence[Text], dest: Text, default: bool = ..., required: bool = ..., help: Text | None = ... ) -> None: ... # undocumented class _StoreFalseAction(_StoreConstAction): def __init__( - self, option_strings: Sequence[Text], dest: Text, default: bool = ..., required: bool = ..., help: Optional[Text] = ... + self, option_strings: Sequence[Text], dest: Text, default: bool = ..., required: bool = ..., help: Text | None = ... ) -> None: ... # undocumented @@ -324,29 +324,29 @@ class _AppendConstAction(Action): const: Any, default: Any = ..., required: bool = ..., - help: Optional[Text] = ..., + help: Text | None = ..., metavar: Optional[Text | Tuple[Text, ...]] = ..., ) -> None: ... # undocumented class _CountAction(Action): def __init__( - self, option_strings: Sequence[Text], dest: Text, default: Any = ..., required: bool = ..., help: Optional[Text] = ... + self, option_strings: Sequence[Text], dest: Text, default: Any = ..., required: bool = ..., help: Text | None = ... ) -> None: ... # undocumented class _HelpAction(Action): def __init__( - self, option_strings: Sequence[Text], dest: Text = ..., default: Text = ..., help: Optional[Text] = ... + self, option_strings: Sequence[Text], dest: Text = ..., default: Text = ..., help: Text | None = ... ) -> None: ... # undocumented class _VersionAction(Action): - version: Optional[_Text] + version: _Text | None def __init__( self, option_strings: Sequence[Text], - version: Optional[Text] = ..., + version: Text | None = ..., dest: Text = ..., default: Text = ..., help: Text = ..., @@ -366,7 +366,7 @@ class _SubParsersAction(Action): prog: Text, parser_class: Type[ArgumentParser], dest: Text = ..., - help: Optional[Text] = ..., + help: Text | None = ..., metavar: Optional[Text | Tuple[Text, ...]] = ..., ) -> None: ... # TODO: Type keyword args properly. @@ -380,4 +380,4 @@ class ArgumentTypeError(Exception): ... def _ensure_value(namespace: Namespace, name: Text, 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/@python2/ast.pyi b/stdlib/@python2/ast.pyi index ea0899c442c5..e52ebb43d21c 100644 --- a/stdlib/@python2/ast.pyi +++ b/stdlib/@python2/ast.pyi @@ -25,4 +25,4 @@ class NodeVisitor: def generic_visit(self, node: AST) -> Any: ... class NodeTransformer(NodeVisitor): - def generic_visit(self, node: AST) -> Optional[AST]: ... + def generic_visit(self, node: AST) -> AST | None: ... diff --git a/stdlib/@python2/asynchat.pyi b/stdlib/@python2/asynchat.pyi index 7effb73d9a26..4e03ad9efac3 100644 --- a/stdlib/@python2/asynchat.pyi +++ b/stdlib/@python2/asynchat.pyi @@ -10,7 +10,7 @@ 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 diff --git a/stdlib/@python2/asyncore.pyi b/stdlib/@python2/asyncore.pyi index f8d365e58c52..7c8bd1b29974 100644 --- a/stdlib/@python2/asyncore.pyi +++ b/stdlib/@python2/asyncore.pyi @@ -13,12 +13,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. @@ -30,12 +30,12 @@ class dispatcher: connecting: bool closing: bool ignore_log_types: frozenset[str] - socket: Optional[SocketType] - def __init__(self, sock: Optional[SocketType] = ..., map: Optional[_maptype] = ...) -> None: ... - def add_channel(self, map: Optional[_maptype] = ...) -> None: ... - def del_channel(self, map: Optional[_maptype] = ...) -> None: ... + socket: SocketType | None + def __init__(self, sock: SocketType | 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: SocketType, map: Optional[_maptype] = ...) -> None: ... + def set_socket(self, sock: SocketType, map: _maptype | None = ...) -> None: ... def set_reuse_addr(self) -> None: ... def readable(self) -> bool: ... def writable(self) -> bool: ... @@ -90,14 +90,14 @@ class dispatcher: def shutdown(self, how: int) -> None: ... class dispatcher_with_send(dispatcher): - def __init__(self, sock: SocketType = ..., map: Optional[_maptype] = ...) -> None: ... + def __init__(self, sock: SocketType = ..., 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: @@ -114,5 +114,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/@python2/audioop.pyi b/stdlib/@python2/audioop.pyi index 606f4b9f5f7e..53ba6a46ec44 100644 --- a/stdlib/@python2/audioop.pyi +++ b/stdlib/@python2/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/@python2/base64.pyi b/stdlib/@python2/base64.pyi index 3c10133f87d2..4bc926c09594 100644 --- a/stdlib/@python2/base64.pyi +++ b/stdlib/@python2/base64.pyi @@ -3,14 +3,14 @@ from typing import IO, Optional, Union _encodable = bytes | unicode _decodable = bytes | unicode -def b64encode(s: _encodable, altchars: Optional[bytes] = ...) -> bytes: ... -def b64decode(s: _decodable, altchars: Optional[bytes] = ..., validate: bool = ...) -> bytes: ... +def b64encode(s: _encodable, altchars: bytes | None = ...) -> bytes: ... +def b64decode(s: _decodable, altchars: bytes | None = ..., validate: bool = ...) -> bytes: ... def standard_b64encode(s: _encodable) -> bytes: ... def standard_b64decode(s: _decodable) -> bytes: ... def urlsafe_b64encode(s: _encodable) -> bytes: ... def urlsafe_b64decode(s: _decodable) -> bytes: ... def b32encode(s: _encodable) -> bytes: ... -def b32decode(s: _decodable, casefold: bool = ..., map01: Optional[bytes] = ...) -> bytes: ... +def b32decode(s: _decodable, casefold: bool = ..., map01: bytes | None = ...) -> bytes: ... def b16encode(s: _encodable) -> bytes: ... def b16decode(s: _decodable, casefold: bool = ...) -> bytes: ... def decode(input: IO[bytes], output: IO[bytes]) -> None: ... diff --git a/stdlib/@python2/bdb.pyi b/stdlib/@python2/bdb.pyi index 32452fc224e6..cba5a6750ec3 100644 --- a/stdlib/@python2/bdb.pyi +++ b/stdlib/@python2/bdb.pyi @@ -14,11 +14,11 @@ class Bdb: skip: Optional[Set[str]] 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 canonic(self, filename: str) -> str: ... @@ -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,7 +56,7 @@ class Bdb: def get_breaks(self, filename: str, lineno: int) -> List[Breakpoint]: ... def get_file_breaks(self, filename: str) -> List[Breakpoint]: ... def get_all_breaks(self) -> List[Breakpoint]: ... - def get_stack(self, f: 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: str | CodeType, globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ... @@ -65,26 +65,26 @@ class Bdb: def runctx( self, cmd: str | CodeType, globals: Optional[Dict[str, Any]], locals: Optional[Mapping[str, Any]] ) -> 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: ... diff --git a/stdlib/@python2/builtins.pyi b/stdlib/@python2/builtins.pyi index 05e7af3f542f..4f7395590d52 100644 --- a/stdlib/@python2/builtins.pyi +++ b/stdlib/@python2/builtins.pyi @@ -66,7 +66,7 @@ _TT = TypeVar("_TT", bound="type") _TBE = TypeVar("_TBE", bound="BaseException") class object: - __doc__: Optional[str] + __doc__: str | None __dict__: Dict[str, Any] __slots__: Text | Iterable[Text] __module__: str @@ -167,10 +167,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: ... @@ -296,7 +296,7 @@ class unicode(basestring, Sequence[unicode]): def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ... def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... def endswith( - self, __suffix: unicode | Tuple[unicode, ...], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __suffix: unicode | Tuple[unicode, ...], __start: int | None = ..., __end: int | None = ... ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> unicode: ... def find(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... @@ -323,12 +323,12 @@ class unicode(basestring, Sequence[unicode]): def rindex(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... def rjust(self, width: int, fillchar: unicode = ...) -> unicode: ... def rpartition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... - def rsplit(self, sep: Optional[unicode] = ..., maxsplit: int = ...) -> List[unicode]: ... + def rsplit(self, sep: unicode | None = ..., maxsplit: int = ...) -> List[unicode]: ... def rstrip(self, chars: unicode = ...) -> unicode: ... - def split(self, sep: Optional[unicode] = ..., maxsplit: int = ...) -> List[unicode]: ... + def split(self, sep: unicode | None = ..., maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[unicode]: ... def startswith( - self, __prefix: unicode | Tuple[unicode, ...], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __prefix: unicode | Tuple[unicode, ...], __start: int | None = ..., __end: int | None = ... ) -> bool: ... def strip(self, chars: unicode = ...) -> unicode: ... def swapcase(self) -> unicode: ... @@ -369,17 +369,17 @@ class str(Sequence[str], basestring): def __init__(self, o: object = ...) -> None: ... def capitalize(self) -> str: ... def center(self, __width: int, __fillchar: str = ...) -> str: ... - def count(self, x: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def count(self, x: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... def encode(self, encoding: Text = ..., errors: Text = ...) -> bytes: ... def endswith( - self, __suffix: Text | Tuple[Text, ...], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __suffix: Text | Tuple[Text, ...], __start: int | None = ..., __end: int | None = ... ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> str: ... - def find(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def find(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... def format(self, *args: object, **kwargs: object) -> str: ... def format_map(self, map: _FormatMapMapping) -> str: ... - def index(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def index(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... def isdigit(self) -> bool: ... @@ -401,8 +401,8 @@ class str(Sequence[str], basestring): @overload def partition(self, __sep: unicode) -> Tuple[unicode, unicode, unicode]: ... def replace(self, __old: AnyStr, __new: AnyStr, __count: int = ...) -> AnyStr: ... - def rfind(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... - def rindex(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def rfind(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... + def rindex(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... def rjust(self, __width: int, __fillchar: str = ...) -> str: ... @overload def rpartition(self, __sep: bytearray) -> Tuple[str, bytearray, str]: ... @@ -411,7 +411,7 @@ class str(Sequence[str], basestring): @overload def rpartition(self, __sep: unicode) -> Tuple[unicode, unicode, unicode]: ... @overload - def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... + def rsplit(self, sep: str | None = ..., maxsplit: int = ...) -> List[str]: ... @overload def rsplit(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ... @overload @@ -419,12 +419,12 @@ class str(Sequence[str], basestring): @overload def rstrip(self, __chars: unicode) -> unicode: ... @overload - def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... + def split(self, sep: str | None = ..., maxsplit: int = ...) -> List[str]: ... @overload def split(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[str]: ... def startswith( - self, __prefix: Text | Tuple[Text, ...], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __prefix: Text | Tuple[Text, ...], __start: int | None = ..., __end: int | None = ... ) -> bool: ... @overload def strip(self, __chars: str = ...) -> str: ... @@ -432,7 +432,7 @@ class str(Sequence[str], basestring): def strip(self, chars: unicode) -> unicode: ... def swapcase(self) -> str: ... def title(self) -> str: ... - def translate(self, __table: Optional[AnyStr], deletechars: AnyStr = ...) -> AnyStr: ... + def translate(self, __table: AnyStr | None, deletechars: AnyStr = ...) -> AnyStr: ... def upper(self) -> str: ... def zfill(self, __width: int) -> str: ... def __add__(self, s: AnyStr) -> AnyStr: ... @@ -476,7 +476,7 @@ class bytearray(MutableSequence[int], ByteString): def count(self, __sub: str) -> int: ... def decode(self, encoding: Text = ..., errors: Text = ...) -> str: ... def endswith( - self, __suffix: bytes | Tuple[bytes, ...], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __suffix: bytes | Tuple[bytes, ...], __start: int | None = ..., __end: int | None = ... ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> bytearray: ... def extend(self, iterable: str | Iterable[int]) -> None: ... @@ -493,21 +493,21 @@ class bytearray(MutableSequence[int], ByteString): def join(self, __iterable: Iterable[str]) -> bytearray: ... def ljust(self, __width: int, __fillchar: str = ...) -> 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]: ... def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytearray: ... def rfind(self, __sub: bytes, __start: int = ..., __end: int = ...) -> int: ... def rindex(self, __sub: bytes, __start: int = ..., __end: int = ...) -> int: ... def rjust(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... def rpartition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... - def rsplit(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... - def rstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... - def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... + def rsplit(self, sep: bytes | None = ..., maxsplit: int = ...) -> List[bytearray]: ... + def rstrip(self, __bytes: bytes | None = ...) -> bytearray: ... + def split(self, sep: bytes | None = ..., maxsplit: int = ...) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... def startswith( - self, __prefix: bytes | Tuple[bytes, ...], __start: Optional[int] = ..., __end: Optional[int] = ... + self, __prefix: bytes | Tuple[bytes, ...], __start: int | None = ..., __end: int | 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: str) -> bytearray: ... @@ -746,13 +746,13 @@ class set(MutableSet[_T], Generic[_T]): def __or__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... def __ior__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... @overload - def __sub__(self: Set[str], s: AbstractSet[Optional[Text]]) -> Set[_T]: ... + def __sub__(self: Set[str], s: AbstractSet[Text | None]) -> Set[_T]: ... @overload - def __sub__(self, s: AbstractSet[Optional[_T]]) -> Set[_T]: ... + def __sub__(self, s: AbstractSet[_T | None]) -> Set[_T]: ... @overload # type: ignore - def __isub__(self: Set[str], s: AbstractSet[Optional[Text]]) -> Set[_T]: ... + def __isub__(self: Set[str], s: AbstractSet[Text | None]) -> Set[_T]: ... @overload - def __isub__(self, s: AbstractSet[Optional[_T]]) -> 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: ... @@ -805,12 +805,12 @@ class property(object): fget: Optional[Callable[[Any], Any]] = ..., fset: Optional[Callable[[Any, Any], None]] = ..., fdel: Optional[Callable[[Any], None]] = ..., - doc: Optional[str] = ..., + 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: ... def fget(self) -> Any: ... @@ -853,11 +853,11 @@ def exit(code: object = ...) -> NoReturn: ... @overload def filter(__function: Callable[[AnyStr], Any], __iterable: AnyStr) -> AnyStr: ... # type: ignore @overload -def filter(__function: None, __iterable: Tuple[Optional[_T], ...]) -> Tuple[_T, ...]: ... # type: ignore +def filter(__function: None, __iterable: Tuple[_T | None, ...]) -> Tuple[_T, ...]: ... # type: ignore @overload def filter(__function: Callable[[_T], Any], __iterable: Tuple[_T, ...]) -> Tuple[_T, ...]: ... # type: ignore @overload -def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> List[_T]: ... +def filter(__function: None, __iterable: Iterable[_T | None]) -> List[_T]: ... @overload def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> List[_T]: ... def format(__value: object, __format_spec: str = ...) -> str: ... # TODO unicode @@ -867,7 +867,7 @@ def getattr(__o: Any, name: Text) -> 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: Text, __default: None) -> Optional[Any]: ... +def getattr(__o: Any, name: Text, __default: None) -> Any | None: ... @overload def getattr(__o: Any, name: Text, __default: bool) -> Any | bool: ... @overload @@ -882,7 +882,7 @@ def intern(__string: str) -> 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]: ... def isinstance(__obj: object, __class_or_tuple: Union[type, Tuple[type | Tuple[Any, ...], ...]]) -> bool: ... @@ -973,7 +973,7 @@ def ord(__c: Text | bytes) -> int: ... # This is only available after from __future__ import print_function. def print( - *values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[SupportsWrite[Any]] = ... + *values: object, sep: Text | None = ..., end: Text | None = ..., file: Optional[SupportsWrite[Any]] = ... ) -> None: ... _E = TypeVar("_E", contravariant=True) @@ -1119,10 +1119,10 @@ class RuntimeError(_StandardError): ... 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 class SystemError(_StandardError): ... class TypeError(_StandardError): ... @@ -1182,8 +1182,8 @@ class file(BinaryIO): def read(self, n: int = ...) -> str: ... def __enter__(self) -> BinaryIO: ... def __exit__( - self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ... - ) -> Optional[bool]: ... + self, t: type | None = ..., exc: BaseException | None = ..., tb: Any | None = ... + ) -> bool | None: ... def flush(self) -> None: ... def fileno(self) -> int: ... def isatty(self) -> bool: ... @@ -1197,4 +1197,4 @@ class file(BinaryIO): def readlines(self, hint: int = ...) -> List[str]: ... def write(self, data: str) -> int: ... def writelines(self, data: Iterable[str]) -> None: ... - def truncate(self, pos: Optional[int] = ...) -> int: ... + def truncate(self, pos: int | None = ...) -> int: ... diff --git a/stdlib/@python2/bz2.pyi b/stdlib/@python2/bz2.pyi index 2f58da93d610..7712d887b4fb 100644 --- a/stdlib/@python2/bz2.pyi +++ b/stdlib/@python2/bz2.pyi @@ -12,9 +12,9 @@ def decompress(data: bytes) -> bytes: ... class BZ2File(io.BufferedIOBase, IO[bytes]): def __enter__(self: _T) -> _T: ... def __init__( - self, filename: _PathOrFile, mode: str = ..., buffering: Optional[Any] = ..., compresslevel: int = ... + self, filename: _PathOrFile, mode: str = ..., 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/@python2/cProfile.pyi b/stdlib/@python2/cProfile.pyi index dda463a35eab..0e436859d92a 100644 --- a/stdlib/@python2/cProfile.pyi +++ b/stdlib/@python2/cProfile.pyi @@ -1,9 +1,9 @@ from types import CodeType from typing import Any, Callable, Dict, Optional, Text, Tuple, TypeVar, Union -def run(statement: str, filename: Optional[str] = ..., sort: 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: str | int = ... + statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: str | None = ..., sort: str | int = ... ) -> None: ... _SelfT = TypeVar("_SelfT", bound=Profile) diff --git a/stdlib/@python2/cStringIO.pyi b/stdlib/@python2/cStringIO.pyi index 3701e6e1d4f7..90a9fa16c181 100644 --- a/stdlib/@python2/cStringIO.pyi +++ b/stdlib/@python2/cStringIO.pyi @@ -15,7 +15,7 @@ class InputType(IO[str], Iterator[str], metaclass=ABCMeta): def readlines(self, hint: int = ...) -> List[str]: ... 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 __iter__(self) -> InputType: ... def next(self) -> str: ... def reset(self) -> None: ... @@ -34,7 +34,7 @@ class OutputType(IO[str], Iterator[str], metaclass=ABCMeta): def readlines(self, hint: int = ...) -> List[str]: ... 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 __iter__(self) -> OutputType: ... def next(self) -> str: ... def reset(self) -> None: ... diff --git a/stdlib/@python2/calendar.pyi b/stdlib/@python2/calendar.pyi index c33435170ddd..b9ad9ff4a069 100644 --- a/stdlib/@python2/calendar.pyi +++ b/stdlib/@python2/calendar.pyi @@ -2,7 +2,7 @@ import datetime from time import struct_time from typing import Any, Iterable, List, Optional, Sequence, Tuple, Union -_LocaleType = Tuple[Optional[str], Optional[str]] +_LocaleType = Tuple[str | None, str | None] class IllegalMonthError(ValueError): def __init__(self, month: int) -> None: ... @@ -63,7 +63,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: ... class TimeEncoding: def __init__(self, locale: _LocaleType) -> None: ... @@ -71,12 +71,12 @@ class TimeEncoding: 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: ... diff --git a/stdlib/@python2/cgi.pyi b/stdlib/@python2/cgi.pyi index dcdac5a8a25b..b8a0918dce6c 100644 --- a/stdlib/@python2/cgi.pyi +++ b/stdlib/@python2/cgi.pyi @@ -43,20 +43,20 @@ class MiniFieldStorage: def __repr__(self) -> str: ... 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] + filename: str | None file: Optional[IO[bytes]] type: str type_options: dict[str, str] diff --git a/stdlib/@python2/cgitb.pyi b/stdlib/@python2/cgitb.pyi index 017840dc472c..9a75965c3796 100644 --- a/stdlib/@python2/cgitb.pyi +++ b/stdlib/@python2/cgitb.pyi @@ -1,16 +1,16 @@ from types import FrameType, TracebackType from typing import IO, Any, Callable, Dict, List, Optional, Text, Tuple, Type -_ExcInfo = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_ExcInfo = Tuple[Optional[Type[BaseException]], BaseException | None, TracebackType | None] 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: ... @@ -18,15 +18,15 @@ class Hook: # undocumented def __init__( self, display: int = ..., - logdir: Optional[Text] = ..., + logdir: Text | None = ..., context: int = ..., file: Optional[IO[str]] = ..., format: str = ..., ) -> None: ... def __call__( - self, etype: Optional[Type[BaseException]], evalue: Optional[BaseException], etb: Optional[TracebackType] + self, etype: Optional[Type[BaseException]], 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[Text] = ..., context: int = ..., format: str = ...) -> None: ... +def handler(info: _ExcInfo | None = ...) -> None: ... +def enable(display: int = ..., logdir: Text | None = ..., context: int = ..., format: str = ...) -> None: ... diff --git a/stdlib/@python2/cmd.pyi b/stdlib/@python2/cmd.pyi index 0b7a7f704a9b..afcfd0a2a2ea 100644 --- a/stdlib/@python2/cmd.pyi +++ b/stdlib/@python2/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 @@ -17,13 +17,13 @@ class Cmd: 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: ... + old_completer: Optional[Callable[[str, int], str | 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: ... @@ -34,6 +34,6 @@ class Cmd: 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 do_help(self, arg: str) -> bool | None: ... 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: ... diff --git a/stdlib/@python2/code.pyi b/stdlib/@python2/code.pyi index ea882c9de68e..05e85cf5581a 100644 --- a/stdlib/@python2/code.pyi +++ b/stdlib/@python2/code.pyi @@ -5,18 +5,18 @@ class InteractiveInterpreter: def __init__(self, locals: Optional[Mapping[str, Any]] = ...) -> None: ... def runsource(self, source: str, filename: str = ..., symbol: str = ...) -> bool: ... def runcode(self, code: CodeType) -> None: ... - def showsyntaxerror(self, filename: Optional[str] = ...) -> None: ... + def showsyntaxerror(self, filename: str | None = ...) -> None: ... def showtraceback(self) -> None: ... def write(self, data: str) -> None: ... class InteractiveConsole(InteractiveInterpreter): def __init__(self, locals: Optional[Mapping[str, Any]] = ..., filename: str = ...) -> None: ... - def interact(self, banner: Optional[str] = ...) -> None: ... + def interact(self, banner: str | None = ...) -> None: ... def push(self, line: str) -> bool: ... def resetbuffer(self) -> None: ... def raw_input(self, prompt: str = ...) -> str: ... def interact( - banner: Optional[str] = ..., readfunc: Optional[Callable[[str], str]] = ..., local: Optional[Mapping[str, Any]] = ... + banner: str | None = ..., readfunc: Optional[Callable[[str], str]] = ..., local: Optional[Mapping[str, Any]] = ... ) -> None: ... -def compile_command(source: str, filename: str = ..., symbol: str = ...) -> Optional[CodeType]: ... +def compile_command(source: str, filename: str = ..., symbol: str = ...) -> CodeType | None: ... diff --git a/stdlib/@python2/codecs.pyi b/stdlib/@python2/codecs.pyi index 7c9217650681..c6494cf820db 100644 --- a/stdlib/@python2/codecs.pyi +++ b/stdlib/@python2/codecs.pyi @@ -83,9 +83,9 @@ def decode(obj: str, encoding: Literal["rot13", "rot_13"] = ..., errors: str = . def decode(obj: _Encoded, encoding: str = ..., errors: str = ...) -> _Decoded: ... def lookup(__encoding: str) -> CodecInfo: ... def utf_16_be_decode( - __data: _Encoded, __errors: Optional[str] = ..., __final: bool = ... + __data: _Encoded, __errors: str | None = ..., __final: bool = ... ) -> Tuple[_Decoded, int]: ... # undocumented -def utf_16_be_encode(__str: _Decoded, __errors: Optional[str] = ...) -> Tuple[_Encoded, int]: ... # undocumented +def utf_16_be_encode(__str: _Decoded, __errors: str | None = ...) -> Tuple[_Encoded, int]: ... # undocumented class CodecInfo(Tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]): @property @@ -105,13 +105,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: ... @@ -120,12 +120,12 @@ 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[_Encoded], data_encoding: str, file_encoding: Optional[str] = ..., errors: str = ... + file: IO[_Encoded], data_encoding: str, file_encoding: str | None = ..., errors: str = ... ) -> StreamRecoder: ... def iterencode(iterator: Iterable[_Decoded], encoding: str, errors: str = ...) -> Generator[_Encoded, None, None]: ... def iterdecode(iterator: Iterable[_Encoded], encoding: str, errors: str = ...) -> Generator[_Decoded, None, None]: ... @@ -204,7 +204,7 @@ class StreamWriter(Codec): def reset(self) -> None: ... def __enter__(self: _SW) -> _SW: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] + self, typ: Optional[Type[BaseException]], exc: BaseException | None, tb: types.TracebackType | None ) -> None: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... @@ -214,12 +214,12 @@ class StreamReader(Codec): errors: str def __init__(self, stream: IO[_Encoded], errors: str = ...) -> None: ... def read(self, size: int = ..., chars: int = ..., firstline: bool = ...) -> _Decoded: ... - def readline(self, size: Optional[int] = ..., keepends: bool = ...) -> _Decoded: ... - def readlines(self, sizehint: Optional[int] = ..., keepends: bool = ...) -> List[_Decoded]: ... + def readline(self, size: int | None = ..., keepends: bool = ...) -> _Decoded: ... + def readlines(self, sizehint: int | None = ..., keepends: bool = ...) -> List[_Decoded]: ... def reset(self) -> None: ... def __enter__(self: _SR) -> _SR: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] + self, typ: Optional[Type[BaseException]], exc: BaseException | None, tb: types.TracebackType | None ) -> None: ... def __iter__(self) -> Iterator[_Decoded]: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... @@ -231,8 +231,8 @@ _T = TypeVar("_T", bound=StreamReaderWriter) class StreamReaderWriter(TextIO): def __init__(self, stream: IO[_Encoded], Reader: _StreamReader, Writer: _StreamWriter, errors: str = ...) -> None: ... def read(self, size: int = ...) -> _Decoded: ... - def readline(self, size: Optional[int] = ...) -> _Decoded: ... - def readlines(self, sizehint: Optional[int] = ...) -> List[_Decoded]: ... + def readline(self, size: int | None = ...) -> _Decoded: ... + def readlines(self, sizehint: int | None = ...) -> List[_Decoded]: ... def next(self) -> Text: ... def __iter__(self: _T) -> _T: ... # This actually returns None, but that's incompatible with the supertype @@ -243,7 +243,7 @@ class StreamReaderWriter(TextIO): def seek(self, offset: int, whence: int = ...) -> int: ... def __enter__(self: _T) -> _T: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] + self, typ: Optional[Type[BaseException]], 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 @@ -253,7 +253,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: ... @@ -271,8 +271,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: ... @@ -281,7 +281,7 @@ class StreamRecoder(BinaryIO): def __getattr__(self, name: str) -> Any: ... def __enter__(self: _SRT) -> _SRT: ... def __exit__( - self, type: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] + self, type: Optional[Type[BaseException]], 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__. @@ -291,7 +291,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/@python2/codeop.pyi b/stdlib/@python2/codeop.pyi index f3d6c2819ec6..35cb4c5e3e60 100644 --- a/stdlib/@python2/codeop.pyi +++ b/stdlib/@python2/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/@python2/collections.pyi b/stdlib/@python2/collections.pyi index c47dd167270e..09045e480152 100644 --- a/stdlib/@python2/collections.pyi +++ b/stdlib/@python2/collections.pyi @@ -46,7 +46,7 @@ def namedtuple( class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]): def __init__(self, iterable: Iterable[_T] = ..., maxlen: int = ...) -> None: ... @property - def maxlen(self) -> Optional[int]: ... + def maxlen(self) -> int | None: ... def append(self, x: _T) -> None: ... def appendleft(self, x: _T) -> None: ... def clear(self) -> None: ... @@ -77,7 +77,7 @@ class Counter(Dict[_T, int], Generic[_T]): def __init__(self, iterable: Iterable[_T]) -> None: ... def copy(self: _S) -> _S: ... def elements(self) -> Iterator[_T]: ... - def most_common(self, n: Optional[int] = ...) -> List[Tuple[_T, int]]: ... + def most_common(self, n: int | None = ...) -> List[Tuple[_T, int]]: ... @overload def subtract(self, __mapping: Mapping[_T, int]) -> None: ... @overload diff --git a/stdlib/@python2/compileall.pyi b/stdlib/@python2/compileall.pyi index 5ae1d6f7f7c1..1316875a6233 100644 --- a/stdlib/@python2/compileall.pyi +++ b/stdlib/@python2/compileall.pyi @@ -4,12 +4,12 @@ from typing import Any, Optional, Pattern, Text def compile_dir( dir: Text, maxlevels: int = ..., - ddir: Optional[Text] = ..., + ddir: Text | None = ..., force: bool = ..., rx: Optional[Pattern[Any]] = ..., quiet: int = ..., ) -> int: ... def compile_file( - fullname: Text, ddir: Optional[Text] = ..., force: bool = ..., rx: Optional[Pattern[Any]] = ..., quiet: int = ... + fullname: Text, ddir: Text | None = ..., force: bool = ..., rx: Optional[Pattern[Any]] = ..., quiet: int = ... ) -> int: ... def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ...) -> int: ... diff --git a/stdlib/@python2/contextlib.pyi b/stdlib/@python2/contextlib.pyi index 6aabf5a16e47..6bd73748d16c 100644 --- a/stdlib/@python2/contextlib.pyi +++ b/stdlib/@python2/contextlib.pyi @@ -7,7 +7,7 @@ _T_co = TypeVar("_T_co", covariant=True) _T_io = TypeVar("_T_io", bound=Optional[IO[str]]) _F = TypeVar("_F", bound=Callable[..., Any]) -_ExitFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], bool] +_ExitFunc = Callable[[Optional[Type[BaseException]], BaseException | None, TracebackType | None], bool] _CM_EF = TypeVar("_CM_EF", ContextManager[Any], _ExitFunc) class GeneratorContextManager(ContextManager[_T_co]): diff --git a/stdlib/@python2/cookielib.pyi b/stdlib/@python2/cookielib.pyi index 7405ba91c0ff..d58e669c3dba 100644 --- a/stdlib/@python2/cookielib.pyi +++ b/stdlib/@python2/cookielib.pyi @@ -38,9 +38,9 @@ class Cookie: rfc2109: bool = ..., ): ... def has_nonstandard_attr(self, name): ... - def get_nonstandard_attr(self, name, default: Optional[Any] = ...): ... + def get_nonstandard_attr(self, name, default: Any | None = ...): ... def set_nonstandard_attr(self, name, value): ... - def is_expired(self, now: Optional[Any] = ...): ... + def is_expired(self, now: Any | None = ...): ... class CookiePolicy: def set_ok(self, cookie, request): ... @@ -66,11 +66,11 @@ class DefaultCookiePolicy(CookiePolicy): strict_ns_set_path: Any def __init__( self, - blocked_domains: Optional[Any] = ..., - allowed_domains: Optional[Any] = ..., + blocked_domains: Any | None = ..., + allowed_domains: Any | None = ..., netscape: bool = ..., rfc2965: bool = ..., - rfc2109_as_netscape: Optional[Any] = ..., + rfc2109_as_netscape: Any | None = ..., hide_cookie2: bool = ..., strict_domain: bool = ..., strict_rfc2965_unverifiable: bool = ..., @@ -111,14 +111,14 @@ class CookieJar: domain_re: Any dots_re: Any magic_re: Any - def __init__(self, policy: Optional[Any] = ...): ... + def __init__(self, policy: Any | None = ...): ... def set_policy(self, policy): ... def add_cookie_header(self, request): ... def make_cookies(self, response, request): ... def set_cookie_if_ok(self, cookie, request): ... def set_cookie(self, cookie): ... def extract_cookies(self, response, request): ... - def clear(self, domain: Optional[Any] = ..., path: Optional[Any] = ..., name: Optional[Any] = ...): ... + def clear(self, domain: Any | None = ..., path: Any | None = ..., name: Any | None = ...): ... def clear_session_cookies(self): ... def clear_expired_cookies(self): ... def __iter__(self): ... @@ -129,10 +129,10 @@ class LoadError(IOError): ... class FileCookieJar(CookieJar): filename: Any delayload: Any - def __init__(self, filename: Optional[Any] = ..., delayload: bool = ..., policy: Optional[Any] = ...): ... - def save(self, filename: Optional[Any] = ..., ignore_discard: bool = ..., ignore_expires: bool = ...): ... - def load(self, filename: Optional[Any] = ..., ignore_discard: bool = ..., ignore_expires: bool = ...): ... - def revert(self, filename: Optional[Any] = ..., ignore_discard: bool = ..., ignore_expires: bool = ...): ... + def __init__(self, filename: Any | None = ..., delayload: bool = ..., policy: Any | None = ...): ... + def save(self, filename: Any | None = ..., ignore_discard: bool = ..., ignore_expires: bool = ...): ... + def load(self, filename: Any | None = ..., ignore_discard: bool = ..., ignore_expires: bool = ...): ... + def revert(self, filename: Any | None = ..., ignore_discard: bool = ..., ignore_expires: bool = ...): ... class LWPCookieJar(FileCookieJar): def as_lwp_str(self, ignore_discard: bool = ..., ignore_expires: bool = ...) -> str: ... # undocumented diff --git a/stdlib/@python2/copy_reg.pyi b/stdlib/@python2/copy_reg.pyi index aa9fed854693..bbde98047df1 100644 --- a/stdlib/@python2/copy_reg.pyi +++ b/stdlib/@python2/copy_reg.pyi @@ -1,7 +1,7 @@ from typing import Any, Callable, Hashable, List, Optional, SupportsInt, Tuple, TypeVar, Union _TypeT = TypeVar("_TypeT", bound=type) -_Reduce = Union[Tuple[Callable[..., _TypeT], Tuple[Any, ...]], Tuple[Callable[..., _TypeT], Tuple[Any, ...], Optional[Any]]] +_Reduce = Union[Tuple[Callable[..., _TypeT], Tuple[Any, ...]], Tuple[Callable[..., _TypeT], Tuple[Any, ...], Any | None]] __all__: List[str] diff --git a/stdlib/@python2/copyreg.pyi b/stdlib/@python2/copyreg.pyi index aa9fed854693..bbde98047df1 100644 --- a/stdlib/@python2/copyreg.pyi +++ b/stdlib/@python2/copyreg.pyi @@ -1,7 +1,7 @@ from typing import Any, Callable, Hashable, List, Optional, SupportsInt, Tuple, TypeVar, Union _TypeT = TypeVar("_TypeT", bound=type) -_Reduce = Union[Tuple[Callable[..., _TypeT], Tuple[Any, ...]], Tuple[Callable[..., _TypeT], Tuple[Any, ...], Optional[Any]]] +_Reduce = Union[Tuple[Callable[..., _TypeT], Tuple[Any, ...]], Tuple[Callable[..., _TypeT], Tuple[Any, ...], Any | None]] __all__: List[str] diff --git a/stdlib/@python2/csv.pyi b/stdlib/@python2/csv.pyi index 944c04065ae0..9bb659f441fc 100644 --- a/stdlib/@python2/csv.pyi +++ b/stdlib/@python2/csv.pyi @@ -47,8 +47,8 @@ class excel_tab(excel): class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): fieldnames: Optional[Sequence[_T]] - restkey: Optional[str] - restval: Optional[str] + 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[Text], fieldnames: Sequence[_T], - restkey: Optional[str] = ..., - restval: Optional[str] = ..., + restkey: str | None = ..., + restval: str | None = ..., dialect: _DialectLike = ..., *args: Any, **kwds: Any, @@ -68,8 +68,8 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): self: DictReader[str], f: Iterable[Text], fieldnames: Optional[Sequence[str]] = ..., - restkey: Optional[str] = ..., - restval: Optional[str] = ..., + 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, @@ -99,5 +99,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/@python2/ctypes/__init__.pyi b/stdlib/@python2/ctypes/__init__.pyi index 4adaa3975a82..866c1b3ad0b6 100644 --- a/stdlib/@python2/ctypes/__init__.pyi +++ b/stdlib/@python2/ctypes/__init__.pyi @@ -34,7 +34,7 @@ class CDLL(object): _handle: int = ... _FuncPtr: Type[_FuncPointer] = ... def __init__( - self, name: Optional[str], mode: int = ..., handle: Optional[int] = ..., 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: ... @@ -141,11 +141,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, Text], size: Optional[int] = ...) -> Array[c_wchar]: ... +def create_unicode_buffer(init: _UnionT[int, Text], size: int | None = ...) -> Array[c_wchar]: ... if sys.platform == "win32": def DllCanUnloadNow() -> int: ... @@ -189,7 +189,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: ... @@ -202,7 +202,7 @@ 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]]): +class c_char_p(_PointerLike, _SimpleCData[bytes | None]): def __init__(self, value: Optional[_UnionT[int, bytes]] = ...) -> None: ... class c_double(_SimpleCData[float]): ... @@ -227,10 +227,10 @@ 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[Text]): ... -class c_wchar_p(_PointerLike, _SimpleCData[Optional[Text]]): +class c_wchar_p(_PointerLike, _SimpleCData[Text | None]): def __init__(self, value: Optional[_UnionT[int, Text]] = ...) -> None: ... class c_bool(_SimpleCData[bool]): diff --git a/stdlib/@python2/ctypes/util.pyi b/stdlib/@python2/ctypes/util.pyi index 20914c70a05c..5d0a732de9f8 100644 --- a/stdlib/@python2/ctypes/util.pyi +++ b/stdlib/@python2/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/@python2/datetime.pyi b/stdlib/@python2/datetime.pyi index b70fe1fd4f30..a5d8e1a1b994 100644 --- a/stdlib/@python2/datetime.pyi +++ b/stdlib/@python2/datetime.pyi @@ -9,9 +9,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: ... _tzinfo = tzinfo @@ -65,7 +65,7 @@ class time: minute: int = ..., second: int = ..., microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., + tzinfo: _tzinfo | None = ..., ) -> _S: ... @property def hour(self) -> int: ... @@ -76,7 +76,7 @@ class time: @property def microsecond(self) -> int: ... @property - def tzinfo(self) -> Optional[_tzinfo]: ... + def tzinfo(self) -> _tzinfo | None: ... def __le__(self, other: time) -> bool: ... def __lt__(self, other: time) -> bool: ... def __ge__(self, other: time) -> bool: ... @@ -85,11 +85,11 @@ class time: def isoformat(self) -> str: ... def strftime(self, fmt: _Text) -> str: ... def __format__(self, fmt: AnyStr) -> AnyStr: ... - 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] = ... + self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: _tzinfo | None = ... ) -> time: ... _date = date @@ -152,7 +152,7 @@ class datetime(date): minute: int = ..., second: int = ..., microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., + tzinfo: _tzinfo | None = ..., ) -> _S: ... @property def year(self) -> int: ... @@ -169,9 +169,9 @@ class datetime(date): @property def microsecond(self) -> int: ... @property - def tzinfo(self) -> Optional[_tzinfo]: ... + def tzinfo(self) -> _tzinfo | None: ... @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 @@ -205,16 +205,16 @@ class datetime(date): minute: int = ..., second: int = ..., microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., + tzinfo: _tzinfo | None = ..., ) -> datetime: ... def astimezone(self, tz: _tzinfo) -> datetime: ... def ctime(self) -> str: ... def isoformat(self, sep: str = ...) -> str: ... @classmethod def strptime(cls, date_string: _Text, format: _Text) -> 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/@python2/dbm/__init__.pyi b/stdlib/@python2/dbm/__init__.pyi index 284385b6c965..bf2a8bfc41c4 100644 --- a/stdlib/@python2/dbm/__init__.pyi +++ b/stdlib/@python2/dbm/__init__.pyi @@ -15,7 +15,7 @@ class _Database(MutableMapping[_KeyType, bytes]): def __del__(self) -> None: ... def __enter__(self) -> _Database: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... class _error(Exception): ... diff --git a/stdlib/@python2/dbm/dumb.pyi b/stdlib/@python2/dbm/dumb.pyi index fe0ff19ec35b..eb1d5dca807e 100644 --- a/stdlib/@python2/dbm/dumb.pyi +++ b/stdlib/@python2/dbm/dumb.pyi @@ -19,7 +19,7 @@ class _Database(MutableMapping[_KeyType, bytes]): def __del__(self) -> None: ... def __enter__(self) -> _Database: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def open(file: str, flag: str = ..., mode: int = ...) -> _Database: ... diff --git a/stdlib/@python2/dbm/gnu.pyi b/stdlib/@python2/dbm/gnu.pyi index 596f4c71a79b..87eb2e7a1c9a 100644 --- a/stdlib/@python2/dbm/gnu.pyi +++ b/stdlib/@python2/dbm/gnu.pyi @@ -9,8 +9,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: ... @@ -20,10 +20,10 @@ class _gdbm: def __len__(self) -> int: ... def __enter__(self) -> _gdbm: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], 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: bytes | _T) -> bytes | _T: ... def keys(self) -> List[bytes]: ... diff --git a/stdlib/@python2/dbm/ndbm.pyi b/stdlib/@python2/dbm/ndbm.pyi index 3fce371b74f4..54ae1da86699 100644 --- a/stdlib/@python2/dbm/ndbm.pyi +++ b/stdlib/@python2/dbm/ndbm.pyi @@ -19,10 +19,10 @@ class _dbm: def __del__(self) -> None: ... def __enter__(self) -> _dbm: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], 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: bytes | _T) -> bytes | _T: ... def keys(self) -> List[bytes]: ... diff --git a/stdlib/@python2/decimal.pyi b/stdlib/@python2/decimal.pyi index bb16c4453b0b..c058fceff11a 100644 --- a/stdlib/@python2/decimal.pyi +++ b/stdlib/@python2/decimal.pyi @@ -21,7 +21,7 @@ ROUND_HALF_DOWN: str ROUND_05UP: str class DecimalException(ArithmeticError): - def handle(self, context: Context, *args: Any) -> Optional[Decimal]: ... + def handle(self, context: Context, *args: Any) -> Decimal | None: ... class Clamped(DecimalException): ... class InvalidOperation(DecimalException): ... @@ -38,45 +38,45 @@ class Underflow(Inexact, Rounded, Subnormal): ... 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 __nonzero__(self) -> bool: ... - def __div__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rdiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __ne__(self, other: object, context: Optional[Context] = ...) -> bool: ... - def compare(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def __div__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def __rdiv__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def __ne__(self, other: object, context: Context | None = ...) -> bool: ... + def compare(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... def __hash__(self) -> int: ... def as_tuple(self) -> DecimalTuple: ... - def to_eng_string(self, context: Optional[Context] = ...) -> str: ... - def __abs__(self, round: bool = ..., context: Optional[Context] = ...) -> Decimal: ... - def __add__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __divmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... - def __eq__(self, other: object, context: Optional[Context] = ...) -> bool: ... - def __floordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __ge__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __gt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __le__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __lt__(self, other: _ComparableNum, context: Optional[Context] = ...) -> bool: ... - def __mod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __mul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __neg__(self, context: Optional[Context] = ...) -> Decimal: ... - def __pos__(self, context: Optional[Context] = ...) -> Decimal: ... - def __pow__(self, other: _Decimal, modulo: Optional[_Decimal] = ..., context: Optional[Context] = ...) -> Decimal: ... - def __radd__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rdivmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Tuple[Decimal, Decimal]: ... - def __rfloordiv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rmod__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rmul__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rsub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __rtruediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __str__(self, eng: bool = ..., context: Optional[Context] = ...) -> str: ... - def __sub__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def __truediv__(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... - def remainder_near(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def to_eng_string(self, context: Context | None = ...) -> str: ... + def __abs__(self, round: bool = ..., context: Context | None = ...) -> Decimal: ... + def __add__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def __divmod__(self, other: _Decimal, context: Context | None = ...) -> Tuple[Decimal, Decimal]: ... + def __eq__(self, other: object, context: Context | None = ...) -> bool: ... + def __floordiv__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def __ge__(self, other: _ComparableNum, context: Context | None = ...) -> bool: ... + def __gt__(self, other: _ComparableNum, context: Context | None = ...) -> bool: ... + def __le__(self, other: _ComparableNum, context: Context | None = ...) -> bool: ... + def __lt__(self, other: _ComparableNum, context: Context | None = ...) -> bool: ... + def __mod__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def __mul__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def __neg__(self, context: Context | None = ...) -> Decimal: ... + def __pos__(self, context: Context | None = ...) -> Decimal: ... + def __pow__(self, other: _Decimal, modulo: _Decimal | None = ..., context: Context | None = ...) -> Decimal: ... + def __radd__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def __rdivmod__(self, other: _Decimal, context: Context | None = ...) -> Tuple[Decimal, Decimal]: ... + def __rfloordiv__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def __rmod__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def __rmul__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def __rsub__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def __rtruediv__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def __str__(self, eng: bool = ..., context: Context | None = ...) -> str: ... + def __sub__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def __truediv__(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... + def remainder_near(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... def __float__(self) -> float: ... def __int__(self) -> int: ... def __trunc__(self) -> int: ... @@ -87,66 +87,66 @@ class Decimal(object): def conjugate(self) -> Decimal: ... def __complex__(self) -> complex: ... def __long__(self) -> long: ... - 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 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: Optional[str] = ..., context: Optional[Context] = ..., watchexp: bool = ... + self, exp: _Decimal, rounding: str | None = ..., context: Context | None = ..., watchexp: bool = ... ) -> Decimal: ... def same_quantum(self, other: _Decimal) -> 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 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, context: Optional[Context] = ...) -> Decimal: ... - def compare_signal(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... + def canonical(self, context: Context | None = ...) -> Decimal: ... + def compare_signal(self, other: _Decimal, context: Context | None = ...) -> Decimal: ... def compare_total(self, other: _Decimal) -> Decimal: ... def compare_total_mag(self, other: _Decimal) -> Decimal: ... def copy_abs(self) -> Decimal: ... def copy_negate(self) -> Decimal: ... def copy_sign(self, other: _Decimal) -> Decimal: ... - def exp(self, context: Optional[Context] = ...) -> 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: Optional[Type[BaseException]], v: BaseException | None, tb: TracebackType | None) -> None: ... _TrapType = Type[DecimalException] @@ -161,14 +161,14 @@ class Context(object): flags: Dict[_TrapType, bool] def __init__( self, - prec: Optional[int] = ..., - rounding: Optional[str] = ..., + prec: int | None = ..., + rounding: str | None = ..., traps: None | Dict[_TrapType, bool] | Container[_TrapType] = ..., flags: None | Dict[_TrapType, bool] | Container[_TrapType] = ..., - Emin: Optional[int] = ..., - Emax: Optional[int] = ..., - capitals: Optional[int] = ..., - _clamp: Optional[int] = ..., + Emin: int | None = ..., + Emax: int | None = ..., + capitals: int | None = ..., + _clamp: int | None = ..., _ignored_flags: Optional[List[_TrapType]] = ..., ) -> None: ... def clear_flags(self) -> None: ... @@ -224,7 +224,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/@python2/difflib.pyi b/stdlib/@python2/difflib.pyi index 02dbbb64433c..cdf86b96c185 100644 --- a/stdlib/@python2/difflib.pyi +++ b/stdlib/@python2/difflib.pyi @@ -54,7 +54,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[_StrType], b: Sequence[_StrType]) -> Iterator[_StrType]: ... def IS_LINE_JUNK(line: _StrType, pat: Any = ...) -> bool: ... # pat is undocumented @@ -80,16 +80,16 @@ def context_diff( lineterm: _StrType = ..., ) -> Iterator[_StrType]: ... def ndiff( - a: Sequence[_StrType], b: Sequence[_StrType], linejunk: Optional[_JunkCallback] = ..., charjunk: Optional[_JunkCallback] = ... + a: Sequence[_StrType], b: Sequence[_StrType], linejunk: _JunkCallback | None = ..., charjunk: _JunkCallback | None = ... ) -> Iterator[_StrType]: ... 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/@python2/distutils/archive_util.pyi b/stdlib/@python2/distutils/archive_util.pyi index 0e94d3818ae4..9b386ca1861a 100644 --- a/stdlib/@python2/distutils/archive_util.pyi +++ b/stdlib/@python2/distutils/archive_util.pyi @@ -3,10 +3,10 @@ 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 = ..., ) -> str: ... -def make_tarball(base_name: str, base_dir: str, compress: Optional[str] = ..., verbose: int = ..., dry_run: int = ...) -> str: ... +def make_tarball(base_name: str, base_dir: str, compress: str | None = ..., verbose: int = ..., dry_run: int = ...) -> str: ... def make_zipfile(base_name: str, base_dir: str, verbose: int = ..., dry_run: int = ...) -> str: ... diff --git a/stdlib/@python2/distutils/ccompiler.pyi b/stdlib/@python2/distutils/ccompiler.pyi index 0e4adb4f27a9..1721f948797b 100644 --- a/stdlib/@python2/distutils/ccompiler.pyi +++ b/stdlib/@python2/distutils/ccompiler.pyi @@ -1,14 +1,14 @@ from typing import Any, Callable, List, Optional, Tuple, Union -_Macro = Union[Tuple[str], Tuple[str, Optional[str]]] +_Macro = Union[Tuple[str], Tuple[str, str | None]] 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,12 +32,12 @@ 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: 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, @@ -53,8 +53,8 @@ class CCompiler: def compile( self, sources: List[str], - output_dir: Optional[str] = ..., - macros: Optional[_Macro] = ..., + output_dir: str | None = ..., + macros: _Macro | None = ..., include_dirs: Optional[List[str]] = ..., debug: bool = ..., extra_preargs: Optional[List[str]] = ..., @@ -65,16 +65,16 @@ class CCompiler: 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] = ..., + output_dir: str | None = ..., libraries: Optional[List[str]] = ..., library_dirs: Optional[List[str]] = ..., runtime_library_dirs: Optional[List[str]] = ..., @@ -82,27 +82,27 @@ class CCompiler: debug: bool = ..., extra_preargs: Optional[List[str]] = ..., extra_postargs: Optional[List[str]] = ..., - build_temp: Optional[str] = ..., - target_lang: Optional[str] = ..., + build_temp: str | None = ..., + target_lang: str | None = ..., ) -> None: ... def link_executable( self, objects: List[str], output_progname: str, - output_dir: Optional[str] = ..., + output_dir: str | None = ..., libraries: Optional[List[str]] = ..., library_dirs: Optional[List[str]] = ..., runtime_library_dirs: Optional[List[str]] = ..., debug: bool = ..., extra_preargs: Optional[List[str]] = ..., extra_postargs: Optional[List[str]] = ..., - target_lang: Optional[str] = ..., + target_lang: str | None = ..., ) -> None: ... def link_shared_lib( self, objects: List[str], output_libname: str, - output_dir: Optional[str] = ..., + output_dir: str | None = ..., libraries: Optional[List[str]] = ..., library_dirs: Optional[List[str]] = ..., runtime_library_dirs: Optional[List[str]] = ..., @@ -110,14 +110,14 @@ class CCompiler: debug: bool = ..., extra_preargs: Optional[List[str]] = ..., extra_postargs: Optional[List[str]] = ..., - build_temp: Optional[str] = ..., - target_lang: Optional[str] = ..., + build_temp: str | None = ..., + target_lang: str | None = ..., ) -> None: ... def link_shared_object( self, objects: List[str], output_filename: str, - output_dir: Optional[str] = ..., + output_dir: str | None = ..., libraries: Optional[List[str]] = ..., library_dirs: Optional[List[str]] = ..., runtime_library_dirs: Optional[List[str]] = ..., @@ -125,13 +125,13 @@ class CCompiler: debug: bool = ..., extra_preargs: Optional[List[str]] = ..., extra_postargs: Optional[List[str]] = ..., - build_temp: Optional[str] = ..., - target_lang: Optional[str] = ..., + build_temp: str | None = ..., + target_lang: str | None = ..., ) -> None: ... def preprocess( self, source: str, - output_file: Optional[str] = ..., + output_file: str | None = ..., macros: Optional[List[_Macro]] = ..., include_dirs: Optional[List[str]] = ..., extra_preargs: Optional[List[str]] = ..., @@ -141,7 +141,7 @@ class CCompiler: def library_filename(self, libname: str, lib_type: str = ..., strip_dir: int = ..., output_dir: str = ...) -> str: ... def object_filenames(self, source_filenames: List[str], strip_dir: int = ..., output_dir: str = ...) -> List[str]: ... def shared_object_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ... - def execute(self, func: Callable[..., None], args: Tuple[Any, ...], msg: 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/@python2/distutils/cmd.pyi b/stdlib/@python2/distutils/cmd.pyi index a284d183d882..fca99941d8b5 100644 --- a/stdlib/@python2/distutils/cmd.pyi +++ b/stdlib/@python2/distutils/cmd.pyi @@ -13,7 +13,7 @@ class Command: def run(self) -> None: ... def announce(self, msg: Text, level: int = ...) -> None: ... def debug_print(self, msg: Text) -> None: ... - def ensure_string(self, option: str, default: Optional[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: ... @@ -24,7 +24,7 @@ class Command: def run_command(self, command: Text) -> None: ... def get_sub_commands(self) -> List[str]: ... def warn(self, msg: Text) -> None: ... - def execute(self, func: Callable[..., Any], args: Iterable[Any], msg: Optional[Text] = ..., level: int = ...) -> None: ... + def execute(self, func: Callable[..., Any], args: Iterable[Any], msg: Text | 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,10 +50,10 @@ 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, @@ -61,7 +61,7 @@ class Command: 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/@python2/distutils/command/config.pyi b/stdlib/@python2/distutils/command/config.pyi index fc7a7b2f8f23..7c96cd9425d3 100644 --- a/stdlib/@python2/distutils/command/config.pyi +++ b/stdlib/@python2/distutils/command/config.pyi @@ -10,9 +10,9 @@ LANG_EXT: Dict[str, str] class config(Command): description: str = ... # Tuple is full name, short name, description - user_options: Sequence[Tuple[str, Optional[str], str]] = ... - compiler: Optional[str | CCompiler] = ... - cc: Optional[str] = ... + user_options: Sequence[Tuple[str, str | None, str]] = ... + compiler: str | CCompiler | None = ... + cc: str | None = ... include_dirs: Optional[Sequence[str]] = ... libraries: Optional[Sequence[str]] = ... library_dirs: Optional[Sequence[str]] = ... @@ -24,7 +24,7 @@ class config(Command): def run(self) -> None: ... def try_cpp( self, - body: Optional[str] = ..., + body: str | None = ..., headers: Optional[Sequence[str]] = ..., include_dirs: Optional[Sequence[str]] = ..., lang: str = ..., @@ -32,7 +32,7 @@ class config(Command): def search_cpp( self, pattern: Pattern[str] | str, - body: Optional[str] = ..., + body: str | None = ..., headers: Optional[Sequence[str]] = ..., include_dirs: Optional[Sequence[str]] = ..., lang: str = ..., @@ -84,4 +84,4 @@ class config(Command): lang: str = ..., ) -> bool: ... -def dump_file(filename: str, head: Optional[str] = ...) -> None: ... +def dump_file(filename: str, head: str | None = ...) -> None: ... diff --git a/stdlib/@python2/distutils/command/install.pyi b/stdlib/@python2/distutils/command/install.pyi index dc6d96b82a62..ba1a4d68d15e 100644 --- a/stdlib/@python2/distutils/command/install.pyi +++ b/stdlib/@python2/distutils/command/install.pyi @@ -3,10 +3,10 @@ from typing import Optional, Text class install(Command): user: bool - prefix: Optional[Text] - home: Optional[Text] - root: Optional[Text] - install_lib: Optional[Text] + prefix: Text | None + home: Text | None + root: Text | None + install_lib: Text | None def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... def run(self) -> None: ... diff --git a/stdlib/@python2/distutils/command/install_egg_info.pyi b/stdlib/@python2/distutils/command/install_egg_info.pyi index 80ffb19bda74..40ce626e09a3 100644 --- a/stdlib/@python2/distutils/command/install_egg_info.pyi +++ b/stdlib/@python2/distutils/command/install_egg_info.pyi @@ -3,7 +3,7 @@ from typing import ClassVar, List, Optional, Tuple class install_egg_info(Command): description: ClassVar[str] - user_options: ClassVar[List[Tuple[str, Optional[str], str]]] + user_options: ClassVar[List[Tuple[str, str | None, str]]] def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... def run(self) -> None: ... diff --git a/stdlib/@python2/distutils/config.pyi b/stdlib/@python2/distutils/config.pyi index e60507e0b65a..29524d497acb 100644 --- a/stdlib/@python2/distutils/config.pyi +++ b/stdlib/@python2/distutils/config.pyi @@ -9,7 +9,7 @@ class PyPIRCCommand(Command): DEFAULT_REALM: ClassVar[str] repository: None realm: None - user_options: ClassVar[List[Tuple[str, Optional[str], str]]] + user_options: ClassVar[List[Tuple[str, str | None, str]]] boolean_options: ClassVar[List[str]] def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... diff --git a/stdlib/@python2/distutils/dist.pyi b/stdlib/@python2/distutils/dist.pyi index 685423bda6da..33a20d308b04 100644 --- a/stdlib/@python2/distutils/dist.pyi +++ b/stdlib/@python2/distutils/dist.pyi @@ -6,4 +6,4 @@ class Distribution: def __init__(self, attrs: Optional[Mapping[str, Any]] = ...) -> None: ... def get_option_dict(self, command: str) -> Dict[str, Tuple[str, Text]]: ... def parse_config_files(self, filenames: Optional[Iterable[Text]] = ...) -> None: ... - def get_command_obj(self, command: str, create: bool = ...) -> Optional[Command]: ... + def get_command_obj(self, command: str, create: bool = ...) -> Command | None: ... diff --git a/stdlib/@python2/distutils/extension.pyi b/stdlib/@python2/distutils/extension.pyi index 02c1f55617b3..74b362699918 100644 --- a/stdlib/@python2/distutils/extension.pyi +++ b/stdlib/@python2/distutils/extension.pyi @@ -6,7 +6,7 @@ class Extension: name: str, sources: List[str], include_dirs: List[str] = ..., - define_macros: List[Tuple[str, Optional[str]]] = ..., + define_macros: List[Tuple[str, str | None]] = ..., undef_macros: List[str] = ..., library_dirs: List[str] = ..., libraries: List[str] = ..., @@ -15,7 +15,7 @@ class Extension: extra_compile_args: List[str] = ..., extra_link_args: List[str] = ..., export_symbols: List[str] = ..., - swig_opts: Optional[str] = ..., # undocumented + swig_opts: str | None = ..., # undocumented depends: List[str] = ..., language: str = ..., ) -> None: ... diff --git a/stdlib/@python2/distutils/fancy_getopt.pyi b/stdlib/@python2/distutils/fancy_getopt.pyi index fe5505e0649f..7cb98a6a6add 100644 --- a/stdlib/@python2/distutils/fancy_getopt.pyi +++ b/stdlib/@python2/distutils/fancy_getopt.pyi @@ -1,6 +1,6 @@ from typing import Any, List, Mapping, Optional, Tuple, Union, overload -_Option = Tuple[str, Optional[str], str] +_Option = Tuple[str, str | None, str] _GR = Tuple[List[str], OptionDummy] def fancy_getopt( @@ -16,6 +16,6 @@ class FancyGetopt: @overload def getopt(self, args: Optional[List[str]], 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: ... diff --git a/stdlib/@python2/distutils/file_util.pyi b/stdlib/@python2/distutils/file_util.pyi index 018339733df0..8c2b302efa6a 100644 --- a/stdlib/@python2/distutils/file_util.pyi +++ b/stdlib/@python2/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/@python2/distutils/spawn.pyi b/stdlib/@python2/distutils/spawn.pyi index e12eae99bf29..6e51effd858d 100644 --- a/stdlib/@python2/distutils/spawn.pyi +++ b/stdlib/@python2/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/@python2/distutils/sysconfig.pyi b/stdlib/@python2/distutils/sysconfig.pyi index 34add92533b9..42d46ec6ac75 100644 --- a/stdlib/@python2/distutils/sysconfig.pyi +++ b/stdlib/@python2/distutils/sysconfig.pyi @@ -8,7 +8,7 @@ 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: ... def set_python_build() -> None: ... diff --git a/stdlib/@python2/distutils/text_file.pyi b/stdlib/@python2/distutils/text_file.pyi index 3f89b0e73ea8..7160c0f3d3af 100644 --- a/stdlib/@python2/distutils/text_file.pyi +++ b/stdlib/@python2/distutils/text_file.pyi @@ -3,7 +3,7 @@ from typing import IO, List, Optional, Tuple, Union class TextFile: def __init__( self, - filename: Optional[str] = ..., + filename: str | None = ..., file: Optional[IO[str]] = ..., *, strip_comments: bool = ..., @@ -16,6 +16,6 @@ class TextFile: def open(self, filename: str) -> None: ... def close(self) -> None: ... def warn(self, msg: str, line: List[int] | Tuple[int, int] | int = ...) -> None: ... - def readline(self) -> Optional[str]: ... + def readline(self) -> str | None: ... def readlines(self) -> List[str]: ... def unreadline(self, line: str) -> str: ... diff --git a/stdlib/@python2/distutils/util.pyi b/stdlib/@python2/distutils/util.pyi index 0086d726af65..ddf06c033fbb 100644 --- a/stdlib/@python2/distutils/util.pyi +++ b/stdlib/@python2/distutils/util.pyi @@ -7,17 +7,17 @@ def check_environ() -> None: ... def subst_vars(s: str, local_vars: Mapping[str, str]) -> None: ... def split_quoted(s: str) -> List[str]: ... def execute( - func: Callable[..., None], args: Tuple[Any, ...], msg: Optional[str] = ..., verbose: bool = ..., dry_run: bool = ... + func: Callable[..., None], args: Tuple[Any, ...], msg: str | None = ..., verbose: bool = ..., dry_run: bool = ... ) -> None: ... def strtobool(val: str) -> bool: ... def byte_compile( py_files: List[str], optimize: int = ..., force: bool = ..., - prefix: Optional[str] = ..., - base_dir: Optional[str] = ..., + prefix: str | None = ..., + base_dir: str | None = ..., verbose: bool = ..., dry_run: bool = ..., - direct: Optional[bool] = ..., + direct: bool | None = ..., ) -> None: ... def rfc822_escape(header: str) -> str: ... diff --git a/stdlib/@python2/distutils/version.pyi b/stdlib/@python2/distutils/version.pyi index e1dbfee328c7..3d18863f7596 100644 --- a/stdlib/@python2/distutils/version.pyi +++ b/stdlib/@python2/distutils/version.pyi @@ -6,7 +6,7 @@ _T = TypeVar("_T", bound=Version) class Version: def __repr__(self) -> str: ... @abstractmethod - def __init__(self, vstring: Optional[Text] = ...) -> None: ... + def __init__(self, vstring: Text | None = ...) -> None: ... @abstractmethod def parse(self: _T, vstring: Text) -> _T: ... @abstractmethod @@ -18,7 +18,7 @@ class StrictVersion(Version): version_re: Pattern[str] version: Tuple[int, int, int] prerelease: Optional[Tuple[Text, int]] - def __init__(self, vstring: Optional[Text] = ...) -> None: ... + def __init__(self, vstring: Text | None = ...) -> None: ... def parse(self: _T, vstring: Text) -> _T: ... def __str__(self) -> str: ... def __cmp__(self: _T, other: _T | str) -> bool: ... @@ -27,7 +27,7 @@ class LooseVersion(Version): component_re: Pattern[str] vstring: Text version: Tuple[Text | int, ...] - def __init__(self, vstring: Optional[Text] = ...) -> None: ... + def __init__(self, vstring: Text | None = ...) -> None: ... def parse(self: _T, vstring: Text) -> _T: ... def __str__(self) -> str: ... def __cmp__(self: _T, other: _T | str) -> bool: ... diff --git a/stdlib/@python2/doctest.pyi b/stdlib/@python2/doctest.pyi index cd6a99ab31a5..301871e4b00a 100644 --- a/stdlib/@python2/doctest.pyi +++ b/stdlib/@python2/doctest.pyi @@ -31,7 +31,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] @@ -39,7 +39,7 @@ class Example: self, source: str, want: str, - exc_msg: Optional[str] = ..., + exc_msg: str | None = ..., lineno: int = ..., indent: int = ..., options: Optional[Dict[int, bool]] = ..., @@ -50,17 +50,17 @@ 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: ... @@ -68,7 +68,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: 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]: ... @@ -79,7 +79,7 @@ class DocTestFinder: def find( self, obj: object, - name: Optional[str] = ..., + name: str | None = ..., module: None | bool | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., extraglobs: Optional[Dict[str, Any]] = ..., @@ -95,15 +95,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: @@ -124,13 +124,13 @@ class UnexpectedException(Exception): class DebugRunner(DocTestRunner): ... -master: Optional[DocTestRunner] +master: DocTestRunner | None def testmod( - m: Optional[types.ModuleType] = ..., - name: Optional[str] = ..., + m: types.ModuleType | None = ..., + name: str | None = ..., globs: Optional[Dict[str, Any]] = ..., - verbose: Optional[bool] = ..., + verbose: bool | None = ..., report: bool = ..., optionflags: int = ..., extraglobs: Optional[Dict[str, Any]] = ..., @@ -140,23 +140,23 @@ def testmod( def testfile( filename: str, module_relative: bool = ..., - name: Optional[str] = ..., + name: str | None = ..., package: None | str | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., - verbose: Optional[bool] = ..., + verbose: bool | None = ..., report: bool = ..., optionflags: int = ..., extraglobs: Optional[Dict[str, Any]] = ..., 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,7 +168,7 @@ class DocTestCase(unittest.TestCase): optionflags: int = ..., setUp: Optional[Callable[[DocTest], Any]] = ..., tearDown: Optional[Callable[[DocTest], Any]] = ..., - checker: Optional[OutputChecker] = ..., + checker: OutputChecker | None = ..., ) -> None: ... def setUp(self) -> None: ... def tearDown(self) -> None: ... @@ -191,7 +191,7 @@ def DocTestSuite( module: None | str | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., extraglobs: Optional[Dict[str, Any]] = ..., - test_finder: Optional[DocTestFinder] = ..., + test_finder: DocTestFinder | None = ..., **options: Any, ) -> _DocTestSuite: ... @@ -205,7 +205,7 @@ def DocFileTest( package: None | str | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., parser: DocTestParser = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., **options: Any, ) -> DocFileCase: ... def DocFileSuite(*paths: str, **kw: Any) -> _DocTestSuite: ... diff --git a/stdlib/@python2/dummy_thread.pyi b/stdlib/@python2/dummy_thread.pyi index 28041002a708..d27af55b1125 100644 --- a/stdlib/@python2/dummy_thread.pyi +++ b/stdlib/@python2/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] = ...) -> bool: ... - def __enter__(self, waitflag: Optional[bool] = ...) -> bool: ... + def acquire(self, waitflag: bool | None = ...) -> bool: ... + def __enter__(self, waitflag: bool | None = ...) -> bool: ... def __exit__(self, typ: Any, val: Any, tb: Any) -> None: ... def release(self) -> bool: ... def locked(self) -> bool: ... diff --git a/stdlib/@python2/email/_parseaddr.pyi b/stdlib/@python2/email/_parseaddr.pyi index 424ade705f77..3a23a743b162 100644 --- a/stdlib/@python2/email/_parseaddr.pyi +++ b/stdlib/@python2/email/_parseaddr.pyi @@ -26,7 +26,7 @@ class AddrlistClass: def getquote(self): ... def getcomment(self): ... def getdomainliteral(self): ... - def getatom(self, atomends: Optional[Any] = ...): ... + def getatom(self, atomends: Any | None = ...): ... def getphraselist(self): ... class AddressList(AddrlistClass): diff --git a/stdlib/@python2/email/mime/application.pyi b/stdlib/@python2/email/mime/application.pyi index 4245e3e0f980..6f0f58687fd8 100644 --- a/stdlib/@python2/email/mime/application.pyi +++ b/stdlib/@python2/email/mime/application.pyi @@ -1,7 +1,7 @@ from email.mime.nonmultipart import MIMENonMultipart from typing import Callable, Optional, Tuple, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, Tuple[str, str | None, str]] class MIMEApplication(MIMENonMultipart): def __init__( diff --git a/stdlib/@python2/email/utils.pyi b/stdlib/@python2/email/utils.pyi index 257e4b1c947a..e0737b6fc1b8 100644 --- a/stdlib/@python2/email/utils.pyi +++ b/stdlib/@python2/email/utils.pyi @@ -9,13 +9,13 @@ from typing import Any, Optional def formataddr(pair): ... def getaddresses(fieldvalues): ... -def formatdate(timeval: Optional[Any] = ..., localtime: bool = ..., usegmt: bool = ...): ... -def make_msgid(idstring: Optional[Any] = ...): ... +def formatdate(timeval: Any | None = ..., localtime: bool = ..., usegmt: bool = ...): ... +def make_msgid(idstring: Any | None = ...): ... def parsedate(data): ... def parsedate_tz(data): ... def parseaddr(addr): ... def unquote(str): ... def decode_rfc2231(s): ... -def encode_rfc2231(s, charset: Optional[Any] = ..., language: Optional[Any] = ...): ... +def encode_rfc2231(s, charset: Any | None = ..., language: Any | None = ...): ... def decode_params(params): ... def collapse_rfc2231_value(value, errors=..., fallback_charset=...): ... diff --git a/stdlib/@python2/ensurepip/__init__.pyi b/stdlib/@python2/ensurepip/__init__.pyi index 8a22ef546436..876cdcbe59a4 100644 --- a/stdlib/@python2/ensurepip/__init__.pyi +++ b/stdlib/@python2/ensurepip/__init__.pyi @@ -2,7 +2,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/@python2/formatter.pyi b/stdlib/@python2/formatter.pyi index 31c45592a215..28a4ca807cd1 100644 --- a/stdlib/@python2/formatter.pyi +++ b/stdlib/@python2/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: ... @@ -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/@python2/fractions.pyi b/stdlib/@python2/fractions.pyi index 48d53fc917a2..bb759fb66ae2 100644 --- a/stdlib/@python2/fractions.pyi +++ b/stdlib/@python2/fractions.pyi @@ -20,7 +20,7 @@ class Fraction(Rational): def __new__( cls: Type[_T], numerator: int | Rational = ..., - denominator: Optional[int | Rational] = ..., + denominator: int | Rational | None = ..., *, _normalize: bool = ..., ) -> _T: ... diff --git a/stdlib/@python2/ftplib.pyi b/stdlib/@python2/ftplib.pyi index ffdc10206e08..307890127812 100644 --- a/stdlib/@python2/ftplib.pyi +++ b/stdlib/@python2/ftplib.pyi @@ -29,14 +29,14 @@ class FTP: 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[BinaryIO] + file: BinaryIO | None def __init__( self, host: Text = ..., user: Text = ..., passwd: Text = ..., acct: Text = ..., timeout: float = ... ) -> None: ... @@ -61,10 +61,10 @@ class FTP: def makepasv(self) -> Tuple[str, int]: ... def login(self, user: Text = ..., passwd: Text = ..., acct: Text = ...) -> 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: Text, rest: Optional[_IntOrStr] = ...) -> Tuple[socket, int]: ... - def transfercmd(self, cmd: Text, rest: Optional[_IntOrStr] = ...) -> socket: ... + def ntransfercmd(self, cmd: Text, rest: _IntOrStr | None = ...) -> Tuple[socket, int]: ... + def transfercmd(self, cmd: Text, rest: _IntOrStr | None = ...) -> socket: ... def retrbinary( - self, cmd: Text, callback: Callable[[bytes], Any], blocksize: int = ..., rest: Optional[_IntOrStr] = ... + self, cmd: Text, callback: Callable[[bytes], Any], blocksize: int = ..., rest: _IntOrStr | None = ... ) -> str: ... def storbinary( self, @@ -72,7 +72,7 @@ class FTP: fp: SupportsRead[bytes], blocksize: int = ..., callback: Optional[Callable[[bytes], Any]] = ..., - rest: Optional[_IntOrStr] = ..., + rest: _IntOrStr | None = ..., ) -> str: ... def retrlines(self, cmd: Text, callback: Optional[Callable[[str], Any]] = ...) -> str: ... def storlines(self, cmd: Text, fp: SupportsReadline[bytes], callback: Optional[Callable[[bytes], Any]] = ...) -> str: ... @@ -83,7 +83,7 @@ class FTP: def rename(self, fromname: Text, toname: Text) -> str: ... def delete(self, filename: Text) -> str: ... def cwd(self, dirname: Text) -> str: ... - def size(self, filename: Text) -> Optional[int]: ... + def size(self, filename: Text) -> int | None: ... def mkd(self, dirname: Text) -> str: ... def rmd(self, dirname: Text) -> str: ... def pwd(self) -> str: ... @@ -97,15 +97,15 @@ class FTP_TLS(FTP): user: Text = ..., passwd: Text = ..., acct: Text = ..., - 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]] = ..., ) -> None: ... ssl_version: int - keyfile: Optional[str] - certfile: Optional[str] + keyfile: str | None + certfile: str | None context: SSLContext def login(self, user: Text = ..., passwd: Text = ..., acct: Text = ..., secure: bool = ...) -> str: ... def auth(self) -> str: ... @@ -113,13 +113,13 @@ class FTP_TLS(FTP): def prot_c(self) -> str: ... class Netrc: - def __init__(self, filename: Optional[Text] = ...) -> None: ... + def __init__(self, filename: Text | None = ...) -> None: ... def get_hosts(self) -> List[str]: ... - def get_account(self, host: Text) -> Tuple[Optional[str], Optional[str], Optional[str]]: ... + def get_account(self, host: Text) -> Tuple[str | None, str | None, str | None]: ... def get_macros(self) -> List[str]: ... def get_macro(self, macro: Text) -> Tuple[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/@python2/gettext.pyi b/stdlib/@python2/gettext.pyi index d8acebfde6df..8d6c427dafeb 100644 --- a/stdlib/@python2/gettext.pyi +++ b/stdlib/@python2/gettext.pyi @@ -23,9 +23,9 @@ class NullTranslations(object): def lngettext(self, singular: str, plural: str, n: int) -> str: ... def ungettext(self, singular: str | unicode, plural: str | unicode, n: int) -> unicode: ... def info(self) -> Dict[str, str]: ... - def charset(self) -> Optional[str]: ... - def output_charset(self) -> Optional[str]: ... - def set_output_charset(self, charset: Optional[str]) -> None: ... + def charset(self) -> str | None: ... + def output_charset(self) -> str | None: ... + def set_output_charset(self, charset: str | None) -> None: ... def install(self, unicode: bool = ..., names: Container[str] = ...) -> None: ... class GNUTranslations(NullTranslations): @@ -33,16 +33,16 @@ class GNUTranslations(NullTranslations): BE_MAGIC: int def find( - domain: str, localedir: Optional[str] = ..., languages: Optional[Sequence[str]] = ..., all: Any = ... + domain: str, localedir: str | None = ..., languages: Optional[Sequence[str]] = ..., all: Any = ... ) -> Optional[str | List[str]]: ... def translation( domain: str, - localedir: Optional[str] = ..., + localedir: str | None = ..., languages: Optional[Sequence[str]] = ..., class_: Optional[Type[NullTranslations]] = ..., fallback: bool = ..., - codeset: Optional[str] = ..., + codeset: str | None = ..., ) -> NullTranslations: ... def install( - domain: str, localedir: Optional[str] = ..., unicode: bool = ..., codeset: Optional[str] = ..., names: Container[str] = ... + domain: str, localedir: str | None = ..., unicode: bool = ..., codeset: str | None = ..., names: Container[str] = ... ) -> None: ... diff --git a/stdlib/@python2/grp.pyi b/stdlib/@python2/grp.pyi index 8447f21736bb..63b7145d0350 100644 --- a/stdlib/@python2/grp.pyi +++ b/stdlib/@python2/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/@python2/hmac.pyi b/stdlib/@python2/hmac.pyi index 7550163b6707..d8a10741999b 100644 --- a/stdlib/@python2/hmac.pyi +++ b/stdlib/@python2/hmac.pyi @@ -8,10 +8,10 @@ _DigestMod = Union[str, Callable[[], _Hash], ModuleType] digest_size: None -def new(key: bytes, msg: Optional[ReadableBuffer] = ..., digestmod: Optional[_DigestMod] = ...) -> HMAC: ... +def new(key: bytes, msg: ReadableBuffer | None = ..., digestmod: _DigestMod | None = ...) -> HMAC: ... class HMAC: - 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/@python2/httplib.pyi b/stdlib/@python2/httplib.pyi index 6901dfc0f695..321f19c4398e 100644 --- a/stdlib/@python2/httplib.pyi +++ b/stdlib/@python2/httplib.pyi @@ -24,14 +24,14 @@ class HTTPResponse: length: Any will_close: Any def __init__( - self, sock, debuglevel: int = ..., strict: int = ..., method: Optional[Any] = ..., buffering: bool = ... + self, sock, debuglevel: int = ..., strict: int = ..., method: Any | None = ..., buffering: bool = ... ) -> None: ... def begin(self): ... def close(self): ... def isclosed(self): ... - def read(self, amt: Optional[Any] = ...): ... + def read(self, amt: Any | None = ...): ... def fileno(self): ... - def getheader(self, name, default: Optional[Any] = ...): ... + def getheader(self, name, default: Any | None = ...): ... def getheaders(self): ... # This is an API stub only for HTTPConnection and HTTPSConnection, as used in @@ -55,23 +55,23 @@ class HTTPConnection: host: str = ... port: int = ... def __init__( - self, host, port: Optional[Any] = ..., strict: Optional[Any] = ..., timeout=..., source_address: Optional[Any] = ... + self, host, port: Any | None = ..., strict: Any | None = ..., timeout=..., source_address: Any | None = ... ) -> None: ... - def set_tunnel(self, host, port: Optional[Any] = ..., headers: Optional[Any] = ...): ... + def set_tunnel(self, host, port: Any | None = ..., headers: Any | None = ...): ... def set_debuglevel(self, level): ... def connect(self): ... def close(self): ... def send(self, data): ... def putrequest(self, method, url, skip_host: int = ..., skip_accept_encoding: int = ...): ... def putheader(self, header, *values): ... - def endheaders(self, message_body: Optional[Any] = ...): ... - def request(self, method, url, body: Optional[Any] = ..., headers=...): ... + def endheaders(self, message_body: Any | None = ...): ... + def request(self, method, url, body: Any | None = ..., headers=...): ... def getresponse(self, buffering: bool = ...): ... class HTTP: debuglevel: Any - def __init__(self, host: str = ..., port: Optional[Any] = ..., strict: Optional[Any] = ...) -> None: ... - def connect(self, host: Optional[Any] = ..., port: Optional[Any] = ...): ... + def __init__(self, host: str = ..., port: Any | None = ..., strict: Any | None = ...) -> None: ... + def connect(self, host: Any | None = ..., port: Any | None = ...): ... def getfile(self): ... file: Any headers: Any @@ -85,13 +85,13 @@ class HTTPSConnection(HTTPConnection): def __init__( self, host, - port: Optional[Any] = ..., - key_file: Optional[Any] = ..., - cert_file: Optional[Any] = ..., - strict: Optional[Any] = ..., + port: Any | None = ..., + key_file: Any | None = ..., + cert_file: Any | None = ..., + strict: Any | None = ..., timeout=..., - source_address: Optional[Any] = ..., - context: Optional[Any] = ..., + source_address: Any | None = ..., + context: Any | None = ..., ) -> None: ... sock: Any def connect(self): ... @@ -102,11 +102,11 @@ class HTTPS(HTTP): def __init__( self, host: str = ..., - port: Optional[Any] = ..., - key_file: Optional[Any] = ..., - cert_file: Optional[Any] = ..., - strict: Optional[Any] = ..., - context: Optional[Any] = ..., + port: Any | None = ..., + key_file: Any | None = ..., + cert_file: Any | None = ..., + strict: Any | None = ..., + context: Any | None = ..., ) -> None: ... class HTTPException(Exception): ... @@ -125,7 +125,7 @@ class IncompleteRead(HTTPException): args: Any partial: Any expected: Any - def __init__(self, partial, expected: Optional[Any] = ...) -> None: ... + def __init__(self, partial, expected: Any | None = ...) -> None: ... class ImproperConnectionState(HTTPException): ... class CannotSendRequest(ImproperConnectionState): ... @@ -145,9 +145,9 @@ error: Any class LineAndFileWrapper: def __init__(self, line, file) -> None: ... def __getattr__(self, attr): ... - def read(self, amt: Optional[Any] = ...): ... + def read(self, amt: Any | None = ...): ... def readline(self): ... - def readlines(self, size: Optional[Any] = ...): ... + def readlines(self, size: Any | None = ...): ... # Constants diff --git a/stdlib/@python2/imaplib.pyi b/stdlib/@python2/imaplib.pyi index 5f8673f1cb96..1535b50a9117 100644 --- a/stdlib/@python2/imaplib.pyi +++ b/stdlib/@python2/imaplib.pyi @@ -18,7 +18,7 @@ class IMAP4: mustquote: Pattern[Text] = ... debug: int = ... state: str = ... - literal: Optional[Text] = ... + literal: Text | None = ... tagged_commands: Dict[bytes, Optional[List[bytes]]] untagged_responses: Dict[str, List[bytes | Tuple[bytes, bytes]]] continuation_response: str = ... @@ -44,7 +44,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: ... @@ -69,8 +69,8 @@ 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: ... @@ -87,13 +87,13 @@ class IMAP4: class IMAP4_SSL(IMAP4): keyfile: str = ... certfile: str = ... - def __init__(self, host: str = ..., port: int = ..., keyfile: Optional[str] = ..., certfile: Optional[str] = ...) -> None: ... + def __init__(self, host: str = ..., port: int = ..., keyfile: str | None = ..., certfile: str | None = ...) -> None: ... host: str = ... port: int = ... sock: _socket = ... sslobj: SSLSocket = ... file: IO[Any] = ... - 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: ... @@ -111,7 +111,7 @@ class IMAP4_stream(IMAP4): process: subprocess.Popen[bytes] = ... writefile: IO[Any] = ... readfile: IO[Any] = ... - 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: ... diff --git a/stdlib/@python2/imghdr.pyi b/stdlib/@python2/imghdr.pyi index 043a27975ab4..afddb98e2d43 100644 --- a/stdlib/@python2/imghdr.pyi +++ b/stdlib/@python2/imghdr.pyi @@ -8,8 +8,8 @@ class _ReadableBinary(Protocol): _File = Text | _ReadableBinary @overload -def what(file: _File, h: None = ...) -> Optional[str]: ... +def what(file: _File, 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/@python2/importlib.pyi b/stdlib/@python2/importlib.pyi index 8bb179a4bd9a..e64ca53adda2 100644 --- a/stdlib/@python2/importlib.pyi +++ b/stdlib/@python2/importlib.pyi @@ -1,4 +1,4 @@ import types from typing import Optional, Text -def import_module(name: Text, package: Optional[Text] = ...) -> types.ModuleType: ... +def import_module(name: Text, package: Text | None = ...) -> types.ModuleType: ... diff --git a/stdlib/@python2/inspect.pyi b/stdlib/@python2/inspect.pyi index 73d59799dded..400ccabbfcc7 100644 --- a/stdlib/@python2/inspect.pyi +++ b/stdlib/@python2/inspect.pyi @@ -30,8 +30,8 @@ class ModuleInfo(NamedTuple): module_type: int def getmembers(object: object, predicate: Optional[Callable[[Any], bool]] = ...) -> List[Tuple[str, Any]]: ... -def getmoduleinfo(path: str | unicode) -> Optional[ModuleInfo]: ... -def getmodulename(path: AnyStr) -> Optional[AnyStr]: ... +def getmoduleinfo(path: str | unicode) -> ModuleInfo | None: ... +def getmodulename(path: AnyStr) -> AnyStr | None: ... def ismodule(object: object) -> bool: ... def isclass(object: object) -> bool: ... def ismethod(object: object) -> bool: ... @@ -55,11 +55,11 @@ _SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, Trace def findsource(object: _SourceObjectType) -> Tuple[List[str], int]: ... def getabsfile(object: _SourceObjectType) -> str: ... def getblock(lines: Sequence[AnyStr]) -> Sequence[AnyStr]: ... -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) -> Optional[ModuleType]: ... -def getsourcefile(object: _SourceObjectType) -> Optional[str]: ... +def getmodule(object: object) -> ModuleType | None: ... +def getsourcefile(object: _SourceObjectType) -> str | None: ... def getsourcelines(object: _SourceObjectType) -> Tuple[List[str], int]: ... def getsource(object: _SourceObjectType) -> str: ... def cleandoc(doc: AnyStr) -> AnyStr: ... @@ -70,20 +70,20 @@ def getclasstree(classes: List[type], unique: bool = ...) -> List[Union[Tuple[ty class ArgSpec(NamedTuple): args: List[str] - varargs: Optional[str] - keywords: Optional[str] + varargs: str | None + keywords: str | None defaults: Tuple[Any, ...] class ArgInfo(NamedTuple): args: List[str] - varargs: Optional[str] - keywords: Optional[str] + varargs: str | None + keywords: str | None locals: Dict[str, Any] class Arguments(NamedTuple): args: List[str | List[Any]] - varargs: Optional[str] - keywords: Optional[str] + varargs: str | None + keywords: str | None def getargs(co: CodeType) -> Arguments: ... def getargspec(func: object) -> ArgSpec: ... @@ -104,9 +104,9 @@ class Traceback(NamedTuple): lineno: int function: str code_context: Optional[List[str]] - index: Optional[int] # type: ignore + index: int | None # type: ignore -_FrameInfo = Tuple[FrameType, str, int, str, Optional[List[str]], Optional[int]] +_FrameInfo = Tuple[FrameType, str, int, str, Optional[List[str]], int | None] def getouterframes(frame: FrameType, context: int = ...) -> List[_FrameInfo]: ... def getframeinfo(frame: FrameType | TracebackType, context: int = ...) -> Traceback: ... diff --git a/stdlib/@python2/itertools.pyi b/stdlib/@python2/itertools.pyi index 63c38980ce79..cc2b24062fdf 100644 --- a/stdlib/@python2/itertools.pyi +++ b/stdlib/@python2/itertools.pyi @@ -28,9 +28,9 @@ def groupby(iterable: Iterable[_T], key: None = ...) -> Iterator[Tuple[_T, Itera @overload def groupby(iterable: Iterable[_T], key: Callable[[_T], _S]) -> Iterator[Tuple[_S, Iterator[_T]]]: ... @overload -def islice(iterable: Iterable[_T], stop: Optional[int]) -> Iterator[_T]: ... +def islice(iterable: Iterable[_T], stop: int | None) -> Iterator[_T]: ... @overload -def islice(iterable: Iterable[_T], start: Optional[int], stop: Optional[int], step: Optional[int] = ...) -> Iterator[_T]: ... +def islice(iterable: Iterable[_T], start: int | None, stop: int | None, step: int | None = ...) -> Iterator[_T]: ... _T1 = TypeVar("_T1") _T2 = TypeVar("_T2") diff --git a/stdlib/@python2/json.pyi b/stdlib/@python2/json.pyi index 45c6e7503d59..cbc1fdead816 100644 --- a/stdlib/@python2/json.pyi +++ b/stdlib/@python2/json.pyi @@ -8,7 +8,7 @@ def dumps( check_circular: bool = ..., allow_nan: bool = ..., cls: Optional[Type[JSONEncoder]] = ..., - indent: Optional[int] = ..., + indent: int | None = ..., separators: Optional[Tuple[str, str]] = ..., encoding: str = ..., default: Optional[Callable[[Any], Any]] = ..., @@ -23,7 +23,7 @@ def dump( check_circular: bool = ..., allow_nan: bool = ..., cls: Optional[Type[JSONEncoder]] = ..., - indent: Optional[int] = ..., + indent: int | None = ..., separators: Optional[Tuple[str, str]] = ..., encoding: str = ..., default: Optional[Callable[[Any], Any]] = ..., @@ -43,7 +43,7 @@ def loads( ) -> Any: ... def load( fp: SupportsRead[Text | bytes], - encoding: Optional[str] = ..., + encoding: str | None = ..., cls: Optional[Type[JSONDecoder]] = ..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ..., parse_float: Optional[Callable[[str], Any]] = ..., @@ -75,7 +75,7 @@ class JSONEncoder(object): check_circular: bool allow_nan: bool sort_keys: bool - indent: Optional[int] + indent: int | None def __init__( self, skipkeys: bool = ..., @@ -83,7 +83,7 @@ class JSONEncoder(object): check_circular: bool = ..., allow_nan: bool = ..., sort_keys: bool = ..., - indent: Optional[int] = ..., + indent: int | None = ..., separators: Tuple[Text | bytes, Text | bytes] = ..., encoding: Text | bytes = ..., default: Callable[..., Any] = ..., diff --git a/stdlib/@python2/lib2to3/pgen2/driver.pyi b/stdlib/@python2/lib2to3/pgen2/driver.pyi index 841b0e4b1cb3..7268c6c6daa8 100644 --- a/stdlib/@python2/lib2to3/pgen2/driver.pyi +++ b/stdlib/@python2/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[Text], debug: bool = ...) -> _NL: ... def parse_stream(self, stream: IO[Text], debug: bool = ...) -> _NL: ... - def parse_file(self, filename: StrPath, encoding: Optional[Text] = ..., debug: bool = ...) -> _NL: ... + def parse_file(self, filename: StrPath, encoding: Text | None = ..., debug: bool = ...) -> _NL: ... def parse_string(self, text: Text, debug: bool = ...) -> _NL: ... def load_grammar( - gt: Text = ..., gp: Optional[Text] = ..., save: bool = ..., force: bool = ..., logger: Optional[Logger] = ... + gt: Text = ..., gp: Text | None = ..., save: bool = ..., force: bool = ..., logger: Logger | None = ... ) -> Grammar: ... diff --git a/stdlib/@python2/lib2to3/pgen2/grammar.pyi b/stdlib/@python2/lib2to3/pgen2/grammar.pyi index 6ec97ce849d2..db1821868a4d 100644 --- a/stdlib/@python2/lib2to3/pgen2/grammar.pyi +++ b/stdlib/@python2/lib2to3/pgen2/grammar.pyi @@ -2,7 +2,7 @@ from _typeshed import StrPath from typing import Dict, List, Optional, Text, Tuple, TypeVar _P = TypeVar("_P") -_Label = Tuple[int, Optional[Text]] +_Label = Tuple[int, Text | None] _DFA = List[List[Tuple[int, int]]] _DFAS = Tuple[_DFA, Dict[int, int]] diff --git a/stdlib/@python2/lib2to3/pgen2/parse.pyi b/stdlib/@python2/lib2to3/pgen2/parse.pyi index b7018cba9c1d..2c8f2b793035 100644 --- a/stdlib/@python2/lib2to3/pgen2/parse.pyi +++ b/stdlib/@python2/lib2to3/pgen2/parse.pyi @@ -7,20 +7,20 @@ _Context = Sequence[Any] class ParseError(Exception): msg: Text type: int - value: Optional[Text] + value: Text | None context: _Context - def __init__(self, msg: Text, type: int, value: Optional[Text], context: _Context) -> None: ... + def __init__(self, msg: Text, type: int, value: Text | 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[Text] - def __init__(self, grammar: Grammar, convert: Optional[_Convert] = ...) -> None: ... - def setup(self, start: Optional[int] = ...) -> None: ... - def addtoken(self, type: int, value: Optional[Text], context: _Context) -> bool: ... - def classify(self, type: int, value: Optional[Text], context: _Context) -> int: ... - def shift(self, type: int, value: Optional[Text], 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: Text | None, context: _Context) -> bool: ... + def classify(self, type: int, value: Text | None, context: _Context) -> int: ... + def shift(self, type: int, value: Text | 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/@python2/lib2to3/pgen2/pgen.pyi b/stdlib/@python2/lib2to3/pgen2/pgen.pyi index 7920262f4f04..9bc88b26f10e 100644 --- a/stdlib/@python2/lib2to3/pgen2/pgen.pyi +++ b/stdlib/@python2/lib2to3/pgen2/pgen.pyi @@ -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] = ...) -> Text: ... + def expect(self, type: int, value: Any | None = ...) -> Text: ... def gettoken(self) -> None: ... def raise_error(self, msg: str, *args: Any) -> NoReturn: ... class NFAState: - arcs: List[Tuple[Optional[Text], NFAState]] + arcs: List[Tuple[Text | None, NFAState]] def __init__(self) -> None: ... - def addarc(self, next: NFAState, label: Optional[Text] = ...) -> None: ... + def addarc(self, next: NFAState, label: Text | None = ...) -> None: ... class DFAState: nfaset: Dict[NFAState, Any] diff --git a/stdlib/@python2/lib2to3/pytree.pyi b/stdlib/@python2/lib2to3/pytree.pyi index 2236fc716061..9c1e6d2928de 100644 --- a/stdlib/@python2/lib2to3/pytree.pyi +++ b/stdlib/@python2/lib2to3/pytree.pyi @@ -14,7 +14,7 @@ def type_repr(type_num: int) -> Text: ... class Base: type: int - parent: Optional[Node] + parent: Node | None prefix: Text children: List[_NL] was_changed: bool @@ -27,11 +27,11 @@ class Base: 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) -> Text: ... @@ -44,8 +44,8 @@ class Node(Base): self, type: int, children: List[_NL], - context: Optional[Any] = ..., - prefix: Optional[Text] = ..., + context: Any | None = ..., + prefix: Text | None = ..., fixers_applied: Optional[List[Any]] = ..., ) -> None: ... def set_child(self, i: int, child: _NL) -> None: ... @@ -61,8 +61,8 @@ class Leaf(Base): self, type: int, value: Text, - context: Optional[_Context] = ..., - prefix: Optional[Text] = ..., + context: _Context | None = ..., + prefix: Text | None = ..., fixers_applied: List[Any] = ..., ) -> None: ... @@ -70,26 +70,26 @@ def convert(gr: Grammar, raw_node: _RawNode) -> _NL: ... class BasePattern: type: int - content: Optional[Text] - name: Optional[Text] + content: Text | None + name: Text | 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[Text] = ..., name: Optional[Text] = ...) -> None: ... + def __init__(self, type: int | None = ..., content: Text | None = ..., name: Text | None = ...) -> None: ... class NodePattern(BasePattern): wildcards: bool - def __init__(self, type: Optional[int] = ..., content: Optional[Text] = ..., name: Optional[Text] = ...) -> None: ... + def __init__(self, type: int | None = ..., content: Text | None = ..., name: Text | None = ...) -> None: ... class WildcardPattern(BasePattern): min: int max: int - def __init__(self, content: Optional[Text] = ..., min: int = ..., max: int = ..., name: Optional[Text] = ...) -> None: ... + def __init__(self, content: Text | None = ..., min: int = ..., max: int = ..., name: Text | None = ...) -> None: ... class NegatedPattern(BasePattern): - def __init__(self, content: Optional[Text] = ...) -> None: ... + def __init__(self, content: Text | None = ...) -> None: ... def generate_matches(patterns: List[BasePattern], nodes: List[_NL]) -> Iterator[Tuple[int, _Results]]: ... diff --git a/stdlib/@python2/linecache.pyi b/stdlib/@python2/linecache.pyi index 1e5fd821b9f4..f262ff545d82 100644 --- a/stdlib/@python2/linecache.pyi +++ b/stdlib/@python2/linecache.pyi @@ -2,8 +2,8 @@ from typing import Any, Dict, List, Optional, Text _ModuleGlobals = Dict[str, Any] -def getline(filename: Text, lineno: int, module_globals: Optional[_ModuleGlobals] = ...) -> str: ... +def getline(filename: Text, lineno: int, module_globals: _ModuleGlobals | None = ...) -> str: ... def clearcache() -> None: ... -def getlines(filename: Text, module_globals: Optional[_ModuleGlobals] = ...) -> List[str]: ... -def checkcache(filename: Optional[Text] = ...) -> None: ... -def updatecache(filename: Text, module_globals: Optional[_ModuleGlobals] = ...) -> List[str]: ... +def getlines(filename: Text, module_globals: _ModuleGlobals | None = ...) -> List[str]: ... +def checkcache(filename: Text | None = ...) -> None: ... +def updatecache(filename: Text, module_globals: _ModuleGlobals | None = ...) -> List[str]: ... diff --git a/stdlib/@python2/locale.pyi b/stdlib/@python2/locale.pyi index 8ecd44305364..4a828fa1ecab 100644 --- a/stdlib/@python2/locale.pyi +++ b/stdlib/@python2/locale.pyi @@ -77,7 +77,7 @@ class Error(Exception): ... def setlocale(category: int, locale: _str | Iterable[_str] | None = ...) -> _str: ... def localeconv() -> Mapping[_str, int | _str | List[int]]: ... def nl_langinfo(__key: int) -> _str: ... -def getdefaultlocale(envvars: Tuple[_str, ...] = ...) -> Tuple[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: ... diff --git a/stdlib/@python2/logging/__init__.pyi b/stdlib/@python2/logging/__init__.pyi index 85b105906a6e..9cd2adceab9d 100644 --- a/stdlib/@python2/logging/__init__.pyi +++ b/stdlib/@python2/logging/__init__.pyi @@ -4,7 +4,7 @@ from time import struct_time from types import FrameType, TracebackType from typing import IO, Any, Callable, Dict, List, Mapping, MutableMapping, Optional, Sequence, Text, Tuple, Union, overload -_SysExcInfoType = Union[Tuple[type, BaseException, Optional[TracebackType]], Tuple[None, None, None]] +_SysExcInfoType = Union[Tuple[type, BaseException, TracebackType | None], Tuple[None, None, None]] _ExcInfoType = None | bool | _SysExcInfoType _ArgsType = Tuple[Any, ...] | Mapping[str, Any] _FilterType = Union[Filter, Callable[[LogRecord], int]] @@ -14,7 +14,7 @@ raiseExceptions: bool logThreads: bool logMultiprocessing: bool logProcesses: bool -_srcfile: Optional[str] +_srcfile: str | None def currentframe() -> FrameType: ... @@ -63,7 +63,7 @@ class Logger(Filterer): self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any ) -> None: ... def _log( - self, level: int, msg: Any, args: _ArgsType, exc_info: Optional[_ExcInfoType] = ..., extra: Optional[Dict[str, Any]] = ... + self, level: int, msg: Any, args: _ArgsType, exc_info: _ExcInfoType | None = ..., extra: Optional[Dict[str, Any]] = ... ) -> None: ... # undocumented def filter(self, record: LogRecord) -> bool: ... def addHandler(self, hdlr: Handler) -> None: ... @@ -78,8 +78,8 @@ class Logger(Filterer): lno: int, msg: Any, args: _ArgsType, - exc_info: Optional[_SysExcInfoType], - func: Optional[str] = ..., + exc_info: _SysExcInfoType | None, + func: str | None = ..., extra: Optional[Mapping[str, Any]] = ..., ) -> LogRecord: ... @@ -94,9 +94,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 createLock(self) -> None: ... def acquire(self) -> None: ... @@ -112,12 +112,12 @@ class Handler(Filterer): def emit(self, record: LogRecord) -> None: ... class Formatter: - converter: Callable[[Optional[float]], struct_time] - _fmt: Optional[str] - datefmt: Optional[str] - def __init__(self, fmt: Optional[str] = ..., datefmt: Optional[str] = ...) -> None: ... + converter: Callable[[float | None], struct_time] + _fmt: str | None + datefmt: str | None + def __init__(self, fmt: str | None = ..., datefmt: str | None = ...) -> 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: ... class Filter: @@ -128,8 +128,8 @@ class LogRecord: args: _ArgsType asctime: str created: int - exc_info: Optional[_SysExcInfoType] - exc_text: Optional[str] + exc_info: _SysExcInfoType | None + exc_text: str | None filename: str funcName: str levelname: str @@ -154,8 +154,8 @@ class LogRecord: lineno: int, msg: Any, args: _ArgsType, - exc_info: Optional[_SysExcInfoType], - func: Optional[str] = ..., + exc_info: _SysExcInfoType | None, + func: str | None = ..., ) -> None: ... def getMessage(self) -> str: ... @@ -220,11 +220,11 @@ def basicConfig() -> None: ... @overload def basicConfig( *, - filename: Optional[str] = ..., + filename: str | None = ..., filemode: str = ..., format: str = ..., - datefmt: Optional[str] = ..., - level: Optional[_Level] = ..., + datefmt: str | None = ..., + level: _Level | None = ..., stream: IO[str] = ..., ) -> None: ... def shutdown(handlerList: Sequence[Any] = ...) -> None: ... # handlerList is undocumented @@ -238,9 +238,9 @@ class StreamHandler(Handler): class FileHandler(StreamHandler): baseFilename: str # undocumented mode: str # undocumented - encoding: Optional[str] # undocumented + encoding: str | None # undocumented delay: bool # undocumented - 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 _open(self) -> IO[Any]: ... class NullHandler(Handler): ... diff --git a/stdlib/@python2/logging/handlers.pyi b/stdlib/@python2/logging/handlers.pyi index 0640c8a79710..b4ed36de3653 100644 --- a/stdlib/@python2/logging/handlers.pyi +++ b/stdlib/@python2/logging/handlers.pyi @@ -13,7 +13,7 @@ SYSLOG_TCP_PORT: int class WatchedFileHandler(FileHandler): dev: int ino: int - 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: ... class RotatingFileHandler(Handler): @@ -23,7 +23,7 @@ class RotatingFileHandler(Handler): mode: str = ..., maxBytes: int = ..., backupCount: int = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., delay: bool = ..., ) -> None: ... def doRollover(self) -> None: ... @@ -35,7 +35,7 @@ class TimedRotatingFileHandler(Handler): when: str = ..., interval: int = ..., backupCount: int = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., delay: bool = ..., utc: bool = ..., ) -> None: ... @@ -91,13 +91,13 @@ class SysLogHandler(Handler): 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: Optional[SocketKind] = ... + 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: ... 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: ... @@ -122,7 +122,7 @@ class BufferingHandler(Handler): def shouldFlush(self, record: LogRecord) -> bool: ... class MemoryHandler(BufferingHandler): - def __init__(self, capacity: int, flushLevel: int = ..., target: Optional[Handler] = ...) -> None: ... + def __init__(self, capacity: int, flushLevel: int = ..., target: Handler | None = ...) -> None: ... def setTarget(self, target: Handler) -> None: ... class HTTPHandler(Handler): diff --git a/stdlib/@python2/macpath.pyi b/stdlib/@python2/macpath.pyi index 74e3315f6481..b3836d0f12cc 100644 --- a/stdlib/@python2/macpath.pyi +++ b/stdlib/@python2/macpath.pyi @@ -29,7 +29,7 @@ from posixpath import ( ) from typing import AnyStr, Optional, Text, Tuple, overload -altsep: Optional[str] +altsep: str | None def basename(s: AnyStr) -> AnyStr: ... def dirname(s: AnyStr) -> AnyStr: ... diff --git a/stdlib/@python2/mailbox.pyi b/stdlib/@python2/mailbox.pyi index 4500f5af28ef..2477e0a6480e 100644 --- a/stdlib/@python2/mailbox.pyi +++ b/stdlib/@python2/mailbox.pyi @@ -46,7 +46,7 @@ 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) -> _MessageT | _T: ... def __getitem__(self, key: str) -> _MessageT: ... @@ -66,7 +66,7 @@ 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 = ...) -> _MessageT | _T: ... def popitem(self) -> Tuple[str, _MessageT]: ... @@ -88,7 +88,7 @@ class Maildir(Mailbox[MaildirMessage]): def add_folder(self, folder: Text) -> Maildir: ... def remove_folder(self, folder: Text) -> None: ... def clean(self) -> None: ... - def next(self) -> Optional[str]: ... + def next(self) -> str | None: ... class _singlefileMailbox(Mailbox[_MessageT]): ... @@ -120,7 +120,7 @@ class Babyl(_singlefileMailbox[BabylMessage]): 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: ... @@ -164,18 +164,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) -> _ProxyFile[AnyStr]: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], exc: BaseException | None, tb: TracebackType | None ) -> None: ... def readable(self) -> bool: ... def writable(self) -> bool: ... @@ -185,7 +185,7 @@ class _ProxyFile(Generic[AnyStr]): def closed(self) -> bool: ... 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/@python2/mailcap.pyi b/stdlib/@python2/mailcap.pyi index 8a721168e06b..34a863f04477 100644 --- a/stdlib/@python2/mailcap.pyi +++ b/stdlib/@python2/mailcap.pyi @@ -4,5 +4,5 @@ _Cap = Dict[str, 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/@python2/mimetypes.pyi b/stdlib/@python2/mimetypes.pyi index 5412a5c7c21b..d1fa53c0f871 100644 --- a/stdlib/@python2/mimetypes.pyi +++ b/stdlib/@python2/mimetypes.pyi @@ -1,9 +1,9 @@ import sys from typing import IO, Dict, List, Optional, Sequence, Text, Tuple -def guess_type(url: Text, strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... +def guess_type(url: Text, 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 guess_extension(type: str, strict: bool = ...) -> str | None: ... def init(files: Optional[Sequence[str]] = ...) -> None: ... def read_mime_types(file: str) -> Optional[Dict[str, str]]: ... def add_type(type: str, ext: str, strict: bool = ...) -> None: ... @@ -21,8 +21,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/@python2/mmap.pyi b/stdlib/@python2/mmap.pyi index 1fa8121d7a9c..a41dae68accc 100644 --- a/stdlib/@python2/mmap.pyi +++ b/stdlib/@python2/mmap.pyi @@ -26,7 +26,7 @@ if sys.platform != "win32": class _mmap(Generic[AnyStr]): 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__( @@ -50,6 +50,6 @@ class mmap(_mmap[bytes], Sequence[bytes]): def read(self, num: int) -> bytes: ... def write(self, string: bytes) -> None: ... def __getitem__(self, index: int | slice) -> bytes: ... - def __getslice__(self, i: Optional[int], j: Optional[int]) -> bytes: ... + def __getslice__(self, i: int | None, j: int | None) -> bytes: ... def __delitem__(self, index: int | slice) -> None: ... def __setitem__(self, index: int | slice, object: bytes) -> None: ... diff --git a/stdlib/@python2/modulefinder.pyi b/stdlib/@python2/modulefinder.pyi index 6fb953242b72..4e7b2f5fd12c 100644 --- a/stdlib/@python2/modulefinder.pyi +++ b/stdlib/@python2/modulefinder.pyi @@ -17,7 +17,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: @@ -42,21 +42,21 @@ 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: Optional[List[str]] = ..., 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_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[Optional[IO[Any]], 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/@python2/msilib/__init__.pyi b/stdlib/@python2/msilib/__init__.pyi index 9a0089d53373..ea3eaa1b8b8b 100644 --- a/stdlib/@python2/msilib/__init__.pyi +++ b/stdlib/@python2/msilib/__init__.pyi @@ -31,7 +31,7 @@ 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: int | Type[_Unspecified] = ..., cond: str | Type[_Unspecified] = ..., @@ -62,11 +62,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, @@ -76,19 +76,19 @@ 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 remove_pyc(self) -> None: ... @@ -108,8 +108,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: ... @@ -118,7 +118,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): @@ -126,7 +126,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 @@ -158,16 +158,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, @@ -177,9 +177,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, @@ -189,7 +189,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/@python2/msilib/schema.pyi b/stdlib/@python2/msilib/schema.pyi index 10b65088cf80..f7f71edff390 100644 --- a/stdlib/@python2/msilib/schema.pyi +++ b/stdlib/@python2/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/@python2/msilib/sequence.pyi b/stdlib/@python2/msilib/sequence.pyi index e4f400d33233..25ec9aa71a87 100644 --- a/stdlib/@python2/msilib/sequence.pyi +++ b/stdlib/@python2/msilib/sequence.pyi @@ -3,7 +3,7 @@ from typing import List, Optional, Tuple if sys.platform == "win32": - _SequenceType = List[Tuple[str, Optional[str], int]] + _SequenceType = List[Tuple[str, str | None, int]] AdminExecuteSequence: _SequenceType AdminUISequence: _SequenceType diff --git a/stdlib/@python2/msilib/text.pyi b/stdlib/@python2/msilib/text.pyi index e338b8b5ba3d..79e166eed550 100644 --- a/stdlib/@python2/msilib/text.pyi +++ b/stdlib/@python2/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/@python2/multiprocessing/__init__.pyi b/stdlib/@python2/multiprocessing/__init__.pyi index b4f58920f574..e71d1c9c77b4 100644 --- a/stdlib/@python2/multiprocessing/__init__.pyi +++ b/stdlib/@python2/multiprocessing/__init__.pyi @@ -13,8 +13,8 @@ _T = TypeVar("_T") class Queue(_BaseQueue[_T]): def __init__(self, maxsize: int = ...) -> None: ... - def get(self, block: bool = ..., timeout: Optional[float] = ...) -> _T: ... - def put(self, item: _T, block: bool = ..., timeout: Optional[float] = ...) -> None: ... + def get(self, block: bool = ..., timeout: float | None = ...) -> _T: ... + def put(self, item: _T, block: bool = ..., timeout: float | None = ...) -> None: ... def qsize(self) -> int: ... def empty(self) -> bool: ... def full(self) -> bool: ... @@ -29,11 +29,11 @@ def Pipe(duplex: bool = ...): ... def cpu_count() -> int: ... def freeze_support(): ... def get_logger(): ... -def log_to_stderr(level: Optional[Any] = ...): ... +def log_to_stderr(level: Any | None = ...): ... def allow_connection_pickling(): ... def Lock(): ... def RLock(): ... -def Condition(lock: Optional[Any] = ...): ... +def Condition(lock: Any | None = ...): ... def Semaphore(value: int = ...): ... def BoundedSemaphore(value: int = ...): ... def Event(): ... @@ -43,8 +43,8 @@ def RawArray(typecode_or_type, size_or_initializer): ... def Value(typecode_or_type, *args, **kwds): ... def Array(typecode_or_type, size_or_initializer, **kwds): ... def Pool( - processes: Optional[int] = ..., + processes: int | None = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ..., - maxtasksperchild: Optional[int] = ..., + maxtasksperchild: int | None = ..., ) -> pool.Pool: ... diff --git a/stdlib/@python2/multiprocessing/dummy/__init__.pyi b/stdlib/@python2/multiprocessing/dummy/__init__.pyi index dd0b5f5246b7..b6ee38e359c3 100644 --- a/stdlib/@python2/multiprocessing/dummy/__init__.pyi +++ b/stdlib/@python2/multiprocessing/dummy/__init__.pyi @@ -11,7 +11,7 @@ class DummyProcess(threading.Thread): _start_called: bool def __init__(self, group=..., target=..., name=..., args=..., kwargs=...) -> None: ... @property - def exitcode(self) -> Optional[int]: ... + def exitcode(self) -> int | None: ... Process = DummyProcess diff --git a/stdlib/@python2/multiprocessing/pool.pyi b/stdlib/@python2/multiprocessing/pool.pyi index b20618ca0291..b517073eb88e 100644 --- a/stdlib/@python2/multiprocessing/pool.pyi +++ b/stdlib/@python2/multiprocessing/pool.pyi @@ -3,24 +3,24 @@ from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Type _T = TypeVar("_T", bound=Pool) class AsyncResult: - def get(self, timeout: Optional[float] = ...) -> Any: ... - def wait(self, timeout: Optional[float] = ...) -> None: ... + def get(self, timeout: float | None = ...) -> Any: ... + def wait(self, timeout: float | None = ...) -> None: ... def ready(self) -> bool: ... def successful(self) -> bool: ... class IMapIterator(Iterator[Any]): def __iter__(self) -> Iterator[Any]: ... - def next(self, timeout: Optional[float] = ...) -> Any: ... + def next(self, timeout: float | None = ...) -> Any: ... class IMapUnorderedIterator(IMapIterator): ... class Pool(object): def __init__( self, - processes: Optional[int] = ..., + processes: int | None = ..., initializer: Optional[Callable[..., None]] = ..., initargs: Iterable[Any] = ..., - maxtasksperchild: Optional[int] = ..., + maxtasksperchild: int | None = ..., ) -> None: ... def apply(self, func: Callable[..., Any], args: Iterable[Any] = ..., kwds: Dict[str, Any] = ...) -> Any: ... def apply_async( @@ -30,17 +30,17 @@ class Pool(object): kwds: Dict[str, Any] = ..., callback: Optional[Callable[..., None]] = ..., ) -> AsyncResult: ... - def map(self, func: Callable[..., Any], iterable: Iterable[Any] = ..., chunksize: Optional[int] = ...) -> List[Any]: ... + def map(self, func: Callable[..., Any], iterable: Iterable[Any] = ..., chunksize: int | None = ...) -> List[Any]: ... def map_async( self, func: Callable[..., Any], iterable: Iterable[Any] = ..., - chunksize: Optional[int] = ..., + chunksize: int | None = ..., callback: Optional[Callable[..., None]] = ..., ) -> AsyncResult: ... - def imap(self, func: Callable[..., Any], iterable: Iterable[Any] = ..., chunksize: Optional[int] = ...) -> IMapIterator: ... + def imap(self, func: Callable[..., Any], iterable: Iterable[Any] = ..., chunksize: int | None = ...) -> IMapIterator: ... def imap_unordered( - self, func: Callable[..., Any], iterable: Iterable[Any] = ..., chunksize: Optional[int] = ... + self, func: Callable[..., Any], iterable: Iterable[Any] = ..., chunksize: int | None = ... ) -> IMapIterator: ... def close(self) -> None: ... def terminate(self) -> None: ... @@ -48,5 +48,5 @@ class Pool(object): class ThreadPool(Pool): def __init__( - self, processes: Optional[int] = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ... + self, processes: int | None = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ... ) -> None: ... diff --git a/stdlib/@python2/multiprocessing/process.pyi b/stdlib/@python2/multiprocessing/process.pyi index 9ab9628e0e32..263070e5c1c4 100644 --- a/stdlib/@python2/multiprocessing/process.pyi +++ b/stdlib/@python2/multiprocessing/process.pyi @@ -5,12 +5,12 @@ def active_children(): ... class Process: def __init__( - self, group: Optional[Any] = ..., target: Optional[Any] = ..., name: Optional[Any] = ..., args=..., kwargs=... + self, group: Any | None = ..., target: Any | None = ..., name: Any | None = ..., args=..., kwargs=... ): ... def run(self): ... def start(self): ... def terminate(self): ... - def join(self, timeout: Optional[Any] = ...): ... + def join(self, timeout: Any | None = ...): ... def is_alive(self): ... @property def name(self): ... diff --git a/stdlib/@python2/multiprocessing/util.pyi b/stdlib/@python2/multiprocessing/util.pyi index 9520022e2962..4bccc6e6ab46 100644 --- a/stdlib/@python2/multiprocessing/util.pyi +++ b/stdlib/@python2/multiprocessing/util.pyi @@ -9,13 +9,13 @@ def debug(msg, *args): ... def info(msg, *args): ... def sub_warning(msg, *args): ... def get_logger(): ... -def log_to_stderr(level: Optional[Any] = ...): ... +def log_to_stderr(level: Any | None = ...): ... def get_temp_dir(): ... def register_after_fork(obj, func): ... class Finalize: - def __init__(self, obj, callback, args=..., kwargs: Optional[Any] = ..., exitpriority: Optional[Any] = ...): ... - def __call__(self, wr: Optional[Any] = ...): ... + def __init__(self, obj, callback, args=..., kwargs: Any | None = ..., exitpriority: Any | None = ...): ... + def __call__(self, wr: Any | None = ...): ... def cancel(self): ... def still_active(self): ... diff --git a/stdlib/@python2/netrc.pyi b/stdlib/@python2/netrc.pyi index 2ee3c522516a..06a8520f1c51 100644 --- a/stdlib/@python2/netrc.pyi +++ b/stdlib/@python2/netrc.pyi @@ -1,16 +1,16 @@ from typing import Dict, List, Optional, Text, 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[Text] = ..., lineno: Optional[int] = ...) -> None: ... + def __init__(self, msg: str, filename: Text | None = ..., lineno: int | None = ...) -> None: ... # (login, account, password) tuple -_NetrcTuple = Tuple[str, Optional[str], Optional[str]] +_NetrcTuple = Tuple[str, str | None, str | None] class netrc: hosts: Dict[str, _NetrcTuple] macros: Dict[str, List[str]] - def __init__(self, file: Optional[Text] = ...) -> None: ... - def authenticators(self, host: str) -> Optional[_NetrcTuple]: ... + def __init__(self, file: Text | None = ...) -> None: ... + def authenticators(self, host: str) -> _NetrcTuple | None: ... diff --git a/stdlib/@python2/nntplib.pyi b/stdlib/@python2/nntplib.pyi index 4ce76e0ced9a..bd7524dd8bbf 100644 --- a/stdlib/@python2/nntplib.pyi +++ b/stdlib/@python2/nntplib.pyi @@ -44,7 +44,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: _SelfT) -> _SelfT: ... def __exit__(self, *args: Any) -> None: ... def getwelcome(self) -> str: ... @@ -56,7 +56,7 @@ class _NNTPBase: def newnews( 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]: ... @@ -79,8 +79,8 @@ class _NNTPBase: 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 @@ -89,9 +89,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: ... @@ -102,10 +102,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/@python2/ntpath.pyi b/stdlib/@python2/ntpath.pyi index 07bd9653efd9..e957604a6aff 100644 --- a/stdlib/@python2/ntpath.pyi +++ b/stdlib/@python2/ntpath.pyi @@ -14,7 +14,7 @@ sep: str if sys.platform == "win32": altsep: str else: - altsep: Optional[str] + altsep: str | None extsep: str pathsep: str defpath: str @@ -68,9 +68,9 @@ def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ... @overload def join(__p1: Text, *p: Text) -> Text: ... @overload -def relpath(path: str, start: Optional[str] = ...) -> str: ... +def relpath(path: str, start: str | None = ...) -> str: ... @overload -def relpath(path: Text, start: Optional[Text] = ...) -> Text: ... +def relpath(path: Text, start: Text | None = ...) -> Text: ... def samefile(f1: Text, f2: Text) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ... def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... diff --git a/stdlib/@python2/numbers.pyi b/stdlib/@python2/numbers.pyi index fa0c0a17b8a7..8d14aec08295 100644 --- a/stdlib/@python2/numbers.pyi +++ b/stdlib/@python2/numbers.pyi @@ -89,7 +89,7 @@ class Integral(Rational): def __long__(self) -> long: ... 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/@python2/optparse.pyi b/stdlib/@python2/optparse.pyi index 386c8e4d947c..ac723a745849 100644 --- a/stdlib/@python2/optparse.pyi +++ b/stdlib/@python2/optparse.pyi @@ -46,7 +46,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) -> _Text: ... def format_description(self, description: _Text) -> _Text: ... @@ -63,14 +63,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: _Text) -> _Text: ... def format_usage(self, usage: _Text) -> _Text: ... 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: _Text) -> _Text: ... def format_usage(self, usage: _Text) -> _Text: ... @@ -88,23 +88,23 @@ class Option: _long_opts: List[_Text] _short_opts: List[_Text] action: _Text - dest: Optional[_Text] + dest: _Text | None default: Any nargs: int type: Any callback: Optional[Callable[..., Any]] callback_args: Optional[Tuple[Any, ...]] callback_kwargs: Optional[Dict[_Text, Any]] - help: Optional[_Text] - metavar: Optional[_Text] - def __init__(self, *opts: Optional[_Text], **attrs: Any) -> None: ... + help: _Text | None + metavar: _Text | None + def __init__(self, *opts: _Text | 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[_Text]]) -> List[_Text]: ... + def _check_opt_strings(self, opts: Iterable[_Text | None]) -> List[_Text]: ... def _check_type(self) -> None: ... def _set_attrs(self, attrs: Dict[_Text, Any]) -> None: ... def _set_opt_strings(self, opts: Iterable[_Text]) -> None: ... @@ -131,14 +131,14 @@ class OptionContainer: @overload def add_option(self, opt: Option) -> Option: ... @overload - def add_option(self, *args: Optional[_Text], **kwargs: Any) -> Any: ... + def add_option(self, *args: _Text | 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]) -> _Text: ... - def format_option_help(self, formatter: Optional[HelpFormatter]) -> _Text: ... + def format_description(self, formatter: HelpFormatter | None) -> Any: ... + def format_help(self, formatter: HelpFormatter | None) -> _Text: ... + def format_option_help(self, formatter: HelpFormatter | None) -> _Text: ... def get_description(self) -> Any: ... - def get_option(self, opt_str: _Text) -> Optional[Option]: ... + def get_option(self, opt_str: _Text) -> Option | None: ... def has_option(self, opt_str: _Text) -> bool: ... def remove_option(self, opt_str: _Text) -> None: ... def set_conflict_handler(self, handler: Any) -> None: ... @@ -148,7 +148,7 @@ class OptionGroup(OptionContainer): option_list: List[Option] parser: OptionParser title: _Text - def __init__(self, parser: OptionParser, title: _Text, description: Optional[_Text] = ...) -> None: ... + def __init__(self, parser: OptionParser, title: _Text, description: _Text | None = ...) -> None: ... def _create_option_list(self) -> None: ... def set_title(self, title: _Text) -> None: ... @@ -165,30 +165,30 @@ class Values: class OptionParser(OptionContainer): allow_interspersed_args: bool - epilog: Optional[_Text] + epilog: _Text | None formatter: HelpFormatter largs: Optional[List[_Text]] option_groups: List[OptionGroup] option_list: List[Option] process_default_values: Any - prog: Optional[_Text] + prog: _Text | None rargs: Optional[List[Any]] standard_option_list: List[Option] - usage: Optional[_Text] - values: Optional[Values] + usage: _Text | None + values: Values | None version: _Text def __init__( self, - usage: Optional[_Text] = ..., + usage: _Text | None = ..., option_list: Optional[Iterable[Option]] = ..., option_class: Type[Option] = ..., - version: Optional[_Text] = ..., + version: _Text | None = ..., conflict_handler: _Text = ..., - description: Optional[_Text] = ..., - formatter: Optional[HelpFormatter] = ..., + description: _Text | None = ..., + formatter: HelpFormatter | None = ..., add_help_option: bool = ..., - prog: Optional[_Text] = ..., - epilog: Optional[_Text] = ..., + prog: _Text | None = ..., + epilog: _Text | None = ..., ) -> None: ... def _add_help_option(self) -> None: ... def _add_version_option(self) -> None: ... @@ -209,18 +209,18 @@ class OptionParser(OptionContainer): def disable_interspersed_args(self) -> None: ... def enable_interspersed_args(self) -> None: ... def error(self, msg: _Text) -> None: ... - def exit(self, status: int = ..., msg: Optional[str] = ...) -> None: ... - def expand_prog_name(self, s: Optional[_Text]) -> Any: ... + def exit(self, status: int = ..., msg: str | None = ...) -> None: ... + def expand_prog_name(self, s: _Text | None) -> Any: ... def format_epilog(self, formatter: HelpFormatter) -> Any: ... - def format_help(self, formatter: Optional[HelpFormatter] = ...) -> _Text: ... - def format_option_help(self, formatter: Optional[HelpFormatter] = ...) -> _Text: ... + def format_help(self, formatter: HelpFormatter | None = ...) -> _Text: ... + def format_option_help(self, formatter: HelpFormatter | None = ...) -> _Text: ... def get_default_values(self) -> Values: ... def get_option_group(self, opt_str: _Text) -> Any: ... def get_prog_name(self) -> _Text: ... def get_usage(self) -> _Text: ... def get_version(self) -> _Text: ... def parse_args( - self, args: Optional[Sequence[AnyStr]] = ..., values: Optional[Values] = ... + self, args: Optional[Sequence[AnyStr]] = ..., 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: ... diff --git a/stdlib/@python2/os/__init__.pyi b/stdlib/@python2/os/__init__.pyi index 7f37ee837f90..91f05a2b781f 100644 --- a/stdlib/@python2/os/__init__.pyi +++ b/stdlib/@python2/os/__init__.pyi @@ -77,7 +77,7 @@ sep: str if sys.platform == "win32": altsep: str else: - altsep: Optional[str] + altsep: str | None extsep: str pathsep: str defpath: str @@ -185,7 +185,7 @@ if sys.platform != "win32": def uname() -> Tuple[str, str, str, str, str]: ... @overload -def getenv(key: Text) -> Optional[str]: ... +def getenv(key: Text) -> str | None: ... @overload def getenv(key: Text, default: _T) -> str | _T: ... def putenv(key: bytes | Text, value: bytes | Text) -> None: ... @@ -303,7 +303,7 @@ def waitpid(pid: int, options: int) -> Tuple[int, int]: ... def urandom(n: int) -> bytes: ... if sys.platform == "win32": - def startfile(path: Text, operation: Optional[str] = ...) -> None: ... + def startfile(path: Text, operation: str | None = ...) -> None: ... else: # Unix only @@ -322,7 +322,7 @@ else: def WEXITSTATUS(status: int) -> int: ... def WSTOPSIG(status: int) -> int: ... def WTERMSIG(status: int) -> int: ... - def confstr(name: str | int) -> Optional[str]: ... + def confstr(name: str | int) -> str | None: ... def getloadavg() -> Tuple[float, float, float]: ... def sysconf(name: str | int) -> int: ... diff --git a/stdlib/@python2/os/path.pyi b/stdlib/@python2/os/path.pyi index 124385f1301d..fce71b521ce7 100644 --- a/stdlib/@python2/os/path.pyi +++ b/stdlib/@python2/os/path.pyi @@ -13,7 +13,7 @@ sep: str if sys.platform == "win32": altsep: str else: - altsep: Optional[str] + altsep: str | None extsep: str pathsep: str defpath: str @@ -68,9 +68,9 @@ def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ... @overload def join(__p1: Text, *p: Text) -> Text: ... @overload -def relpath(path: str, start: Optional[str] = ...) -> str: ... +def relpath(path: str, start: str | None = ...) -> str: ... @overload -def relpath(path: Text, start: Optional[Text] = ...) -> Text: ... +def relpath(path: Text, start: Text | None = ...) -> Text: ... def samefile(f1: Text, f2: Text) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ... def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... diff --git a/stdlib/@python2/os2emxpath.pyi b/stdlib/@python2/os2emxpath.pyi index 07bd9653efd9..e957604a6aff 100644 --- a/stdlib/@python2/os2emxpath.pyi +++ b/stdlib/@python2/os2emxpath.pyi @@ -14,7 +14,7 @@ sep: str if sys.platform == "win32": altsep: str else: - altsep: Optional[str] + altsep: str | None extsep: str pathsep: str defpath: str @@ -68,9 +68,9 @@ def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ... @overload def join(__p1: Text, *p: Text) -> Text: ... @overload -def relpath(path: str, start: Optional[str] = ...) -> str: ... +def relpath(path: str, start: str | None = ...) -> str: ... @overload -def relpath(path: Text, start: Optional[Text] = ...) -> Text: ... +def relpath(path: Text, start: Text | None = ...) -> Text: ... def samefile(f1: Text, f2: Text) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ... def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... diff --git a/stdlib/@python2/pdb.pyi b/stdlib/@python2/pdb.pyi index d1e3649c5a5e..f639098985e4 100644 --- a/stdlib/@python2/pdb.pyi +++ b/stdlib/@python2/pdb.pyi @@ -12,9 +12,9 @@ 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 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: ... 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): @@ -30,11 +30,11 @@ 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, @@ -44,10 +44,10 @@ class Pdb(Bdb, Cmd): skip: Optional[Iterable[str]] = ..., ) -> 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: ... @@ -56,38 +56,38 @@ class Pdb(Bdb, Cmd): 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 diff --git a/stdlib/@python2/pickle.pyi b/stdlib/@python2/pickle.pyi index 8272caeeed23..07e32e64b449 100644 --- a/stdlib/@python2/pickle.pyi +++ b/stdlib/@python2/pickle.pyi @@ -3,8 +3,8 @@ from typing import IO, Any, Callable, Iterator, Optional, Tuple, Type, Union HIGHEST_PROTOCOL: int bytes_types: Tuple[Type[Any], ...] # undocumented -def dump(obj: Any, file: IO[bytes], protocol: Optional[int] = ...) -> None: ... -def dumps(obj: Any, protocol: Optional[int] = ...) -> bytes: ... +def dump(obj: Any, file: IO[bytes], protocol: int | None = ...) -> None: ... +def dumps(obj: Any, protocol: int | None = ...) -> bytes: ... def load(file: IO[bytes]) -> Any: ... def loads(string: bytes) -> Any: ... @@ -22,7 +22,7 @@ _reducedtype = Union[ class Pickler: fast: bool - def __init__(self, file: IO[bytes], protocol: Optional[int] = ...) -> None: ... + def __init__(self, file: IO[bytes], protocol: int | None = ...) -> None: ... def dump(self, __obj: Any) -> None: ... def clear_memo(self) -> None: ... def persistent_id(self, obj: Any) -> Any: ... diff --git a/stdlib/@python2/pickletools.pyi b/stdlib/@python2/pickletools.pyi index 423ece56286a..678aed72ec23 100644 --- a/stdlib/@python2/pickletools.pyi +++ b/stdlib/@python2/pickletools.pyi @@ -99,7 +99,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 @@ -108,7 +108,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, @@ -117,7 +117,7 @@ class OpcodeInfo(object): opcodes: List[OpcodeInfo] -def genops(pickle: bytes | IO[bytes]) -> Iterator[Tuple[OpcodeInfo, Optional[Any], Optional[int]]]: ... +def genops(pickle: bytes | IO[bytes]) -> Iterator[Tuple[OpcodeInfo, Any | None, int | None]]: ... def optimize(p: bytes | IO[bytes]) -> bytes: ... def dis( pickle: bytes | IO[bytes], diff --git a/stdlib/@python2/pkgutil.pyi b/stdlib/@python2/pkgutil.pyi index 6a630dc1e16a..2e335061051f 100644 --- a/stdlib/@python2/pkgutil.pyi +++ b/stdlib/@python2/pkgutil.pyi @@ -10,13 +10,13 @@ _ModuleInfoLike = Tuple[MetaPathFinder | PathEntryFinder, str, 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[MetaPathFinder | PathEntryFinder]: ... def iter_modules(path: Optional[Iterable[str]] = ..., prefix: str = ...) -> Iterator[_ModuleInfoLike]: ... @@ -24,4 +24,4 @@ def read_code(stream: SupportsRead[bytes]) -> Any: ... # undocumented def walk_packages( path: Optional[Iterable[str]] = ..., prefix: str = ..., onerror: Optional[Callable[[str], None]] = ... ) -> Iterator[_ModuleInfoLike]: ... -def get_data(package: str, resource: str) -> Optional[bytes]: ... +def get_data(package: str, resource: str) -> bytes | None: ... diff --git a/stdlib/@python2/platform.pyi b/stdlib/@python2/platform.pyi index 44bbe4d62aa9..ab3ff734f3a6 100644 --- a/stdlib/@python2/platform.pyi +++ b/stdlib/@python2/platform.pyi @@ -12,13 +12,13 @@ class _popen: pipe: Any bufsize: Any mode: Any - def __init__(self, cmd, mode=..., bufsize: Optional[Any] = ...): ... + def __init__(self, cmd, mode=..., bufsize: Any | None = ...): ... def read(self): ... def readlines(self): ... def close(self, remove=..., error=...): ... __del__: Any -def popen(cmd, mode=..., bufsize: Optional[Any] = ...): ... +def popen(cmd, mode=..., bufsize: Any | None = ...): ... def win32_ver(release: str = ..., version: str = ..., csd: str = ..., ptype: str = ...) -> Tuple[str, str, str, str]: ... def mac_ver( release: str = ..., versioninfo: Tuple[str, str, str] = ..., machine: str = ... diff --git a/stdlib/@python2/popen2.pyi b/stdlib/@python2/popen2.pyi index 8830533cb909..9dc92e7072b0 100644 --- a/stdlib/@python2/popen2.pyi +++ b/stdlib/@python2/popen2.pyi @@ -8,7 +8,7 @@ class Popen3: pid: int tochild: TextIO fromchild: TextIO - childerr: Optional[TextIO] + childerr: TextIO | None def __init__(self, cmd: Iterable[Any] = ..., capturestderr: bool = ..., bufsize: int = ...) -> None: ... def __del__(self) -> None: ... def poll(self, _deadstate: _T = ...) -> int | _T: ... diff --git a/stdlib/@python2/poplib.pyi b/stdlib/@python2/poplib.pyi index 603093d419a2..2cb08c864310 100644 --- a/stdlib/@python2/poplib.pyi +++ b/stdlib/@python2/poplib.pyi @@ -23,7 +23,7 @@ class POP3: def user(self, user: Text) -> bytes: ... def pass_(self, pswd: Text) -> 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: ... @@ -41,5 +41,5 @@ class POP3: class POP3_SSL(POP3): def __init__( - self, host: Text, port: int = ..., keyfile: Optional[Text] = ..., certfile: Optional[Text] = ..., timeout: float = ... + self, host: Text, port: int = ..., keyfile: Text | None = ..., certfile: Text | None = ..., timeout: float = ... ) -> None: ... diff --git a/stdlib/@python2/posixpath.pyi b/stdlib/@python2/posixpath.pyi index 07bd9653efd9..e957604a6aff 100644 --- a/stdlib/@python2/posixpath.pyi +++ b/stdlib/@python2/posixpath.pyi @@ -14,7 +14,7 @@ sep: str if sys.platform == "win32": altsep: str else: - altsep: Optional[str] + altsep: str | None extsep: str pathsep: str defpath: str @@ -68,9 +68,9 @@ def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ... @overload def join(__p1: Text, *p: Text) -> Text: ... @overload -def relpath(path: str, start: Optional[str] = ...) -> str: ... +def relpath(path: str, start: str | None = ...) -> str: ... @overload -def relpath(path: Text, start: Optional[Text] = ...) -> Text: ... +def relpath(path: Text, start: Text | None = ...) -> Text: ... def samefile(f1: Text, f2: Text) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ... def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... diff --git a/stdlib/@python2/pprint.pyi b/stdlib/@python2/pprint.pyi index bdf750407d12..3935536370c0 100644 --- a/stdlib/@python2/pprint.pyi +++ b/stdlib/@python2/pprint.pyi @@ -1,8 +1,8 @@ from typing import IO, Any, Dict, Optional, Tuple -def pformat(object: object, indent: int = ..., width: int = ..., depth: Optional[int] = ...) -> str: ... +def pformat(object: object, indent: int = ..., width: int = ..., depth: int | None = ...) -> str: ... def pprint( - object: object, stream: Optional[IO[str]] = ..., indent: int = ..., width: int = ..., depth: Optional[int] = ... + object: object, stream: Optional[IO[str]] = ..., indent: int = ..., width: int = ..., depth: int | None = ... ) -> None: ... def isreadable(object: object) -> bool: ... def isrecursive(object: object) -> bool: ... @@ -10,7 +10,7 @@ def saferepr(object: object) -> str: ... class PrettyPrinter: def __init__( - self, indent: int = ..., width: int = ..., depth: Optional[int] = ..., stream: Optional[IO[str]] = ... + self, indent: int = ..., width: int = ..., depth: int | None = ..., stream: Optional[IO[str]] = ... ) -> None: ... def pformat(self, object: object) -> str: ... def pprint(self, object: object) -> None: ... diff --git a/stdlib/@python2/profile.pyi b/stdlib/@python2/profile.pyi index 215693a0c2d8..38d5af235434 100644 --- a/stdlib/@python2/profile.pyi +++ b/stdlib/@python2/profile.pyi @@ -1,8 +1,8 @@ from typing import Any, Callable, Dict, Optional, Text, Tuple, TypeVar, Union -def run(statement: str, filename: Optional[str] = ..., sort: 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: str | int = ... + statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: str | None = ..., sort: str | int = ... ) -> None: ... _SelfT = TypeVar("_SelfT", bound=Profile) @@ -12,7 +12,7 @@ _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: Optional[Callable[[], float]] = ..., bias: int | None = ...) -> None: ... def set_cmd(self, cmd: str) -> None: ... def simulate_call(self, name: str) -> None: ... def simulate_cmd_complete(self) -> None: ... diff --git a/stdlib/@python2/py_compile.pyi b/stdlib/@python2/py_compile.pyi index 1785aaaf7b99..cf77352bbee3 100644 --- a/stdlib/@python2/py_compile.pyi +++ b/stdlib/@python2/py_compile.pyi @@ -10,6 +10,6 @@ class PyCompileError(Exception): def __init__(self, exc_type: Type[BaseException], exc_value: BaseException, file: str, msg: str = ...) -> None: ... def compile( - file: _EitherStr, cfile: Optional[_EitherStr] = ..., dfile: Optional[_EitherStr] = ..., doraise: bool = ... + file: _EitherStr, cfile: _EitherStr | None = ..., dfile: _EitherStr | None = ..., doraise: bool = ... ) -> None: ... def main(args: Optional[List[Text]] = ...) -> int: ... diff --git a/stdlib/@python2/pydoc.pyi b/stdlib/@python2/pydoc.pyi index 37ad2200e05b..625fd3b32497 100644 --- a/stdlib/@python2/pydoc.pyi +++ b/stdlib/@python2/pydoc.pyi @@ -21,7 +21,7 @@ from typing import ( from repr import Repr # the return type of sys.exc_info(), used by ErrorDuringImport.__init__ -_Exc_Info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_Exc_Info = Tuple[Optional[Type[BaseException]], BaseException | None, TracebackType | None] __author__: str __date__: str @@ -37,17 +37,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: Optional[Container[str]] = ..., 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] + value: BaseException | None + tb: TracebackType | None def __init__(self, filename: str, exc_info: _Exc_Info) -> None: ... def importfile(path: str) -> ModuleType: ... @@ -55,15 +55,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 @@ -93,7 +93,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: ... @@ -113,14 +113,14 @@ class HTMLDoc(Doc): 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[Union[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, @@ -129,20 +129,20 @@ 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 filelink(self, url: str, path: str) -> str: ... @@ -168,29 +168,29 @@ class TextDoc(Doc): self, tree: List[Union[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: ... @@ -210,12 +210,12 @@ html: HTMLDoc class _OldStyleClass: ... def resolve(thing: str | object, forceload: bool = ...) -> Optional[Tuple[object, str]]: ... -def render_doc(thing: str | object, title: str = ..., forceload: bool = ..., renderer: Optional[Doc] = ...) -> str: ... +def render_doc(thing: str | object, title: str = ..., forceload: bool = ..., renderer: Doc | None = ...) -> str: ... def doc( thing: str | object, title: str = ..., forceload: bool = ..., output: Optional[SupportsWrite[str]] = ... ) -> None: ... def writedoc(thing: str | object, forceload: bool = ...) -> None: ... -def writedocs(dir: str, pkgpath: str = ..., done: Optional[Any] = ...) -> None: ... +def writedocs(dir: str, pkgpath: str = ..., done: Any | None = ...) -> None: ... class Helper: keywords: Dict[str, str | Tuple[str, str]] @@ -252,8 +252,8 @@ class ModuleScanner: quit: bool def run( self, - callback: Callable[[Optional[str], str, str], None], - key: Optional[Any] = ..., + callback: Callable[[str | None, str, str], None], + key: Any | None = ..., completer: Optional[Callable[[], None]] = ..., onerror: Optional[Callable[[str], None]] = ..., ) -> None: ... diff --git a/stdlib/@python2/pyexpat/__init__.pyi b/stdlib/@python2/pyexpat/__init__.pyi index 6fe73d1576a5..b291b5b513f1 100644 --- a/stdlib/@python2/pyexpat/__init__.pyi +++ b/stdlib/@python2/pyexpat/__init__.pyi @@ -19,15 +19,15 @@ XML_PARAM_ENTITY_PARSING_NEVER: int XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE: int XML_PARAM_ENTITY_PARSING_ALWAYS: int -_Model = Tuple[int, int, Optional[str], Tuple[Any, ...]] +_Model = Tuple[int, int, str | None, Tuple[Any, ...]] class XMLParserType(object): def Parse(self, __data: Text | bytes, __isfinal: bool = ...) -> int: ... def ParseFile(self, __file: SupportsRead[bytes]) -> int: ... def SetBase(self, __base: Text) -> None: ... - def GetBase(self) -> Optional[str]: ... - def GetInputContext(self) -> Optional[bytes]: ... - def ExternalEntityParserCreate(self, __context: Optional[Text], __encoding: Text = ...) -> XMLParserType: ... + def GetBase(self) -> str | None: ... + def GetInputContext(self) -> bytes | None: ... + def ExternalEntityParserCreate(self, __context: Text | None, __encoding: Text = ...) -> XMLParserType: ... def SetParamEntityParsing(self, __flag: int) -> int: ... def UseForeignDTD(self, __flag: bool = ...) -> None: ... buffer_size: int @@ -43,11 +43,11 @@ 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]] + XmlDeclHandler: Optional[Callable[[str, str | None, int], Any]] + StartDoctypeDeclHandler: Optional[Callable[[str, str | None, str | None, bool], Any]] EndDoctypeDeclHandler: Optional[Callable[[], Any]] ElementDeclHandler: Optional[Callable[[str, _Model], Any]] - AttlistDeclHandler: Optional[Callable[[str, str, str, Optional[str], bool], Any]] + AttlistDeclHandler: Optional[Callable[[str, str, str, str | None, bool], Any]] StartElementHandler: Optional[ Union[ Callable[[str, Dict[str, str]], Any], @@ -58,9 +58,9 @@ class XMLParserType(object): 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]] + UnparsedEntityDeclHandler: Optional[Callable[[str, str | None, str, str | None, str], Any]] + EntityDeclHandler: Optional[Callable[[str, bool, str | None, str | None, str, str | None, str | None], Any]] + NotationDeclHandler: Optional[Callable[[str, str | None, str, str | None], Any]] StartNamespaceDeclHandler: Optional[Callable[[str, str], Any]] EndNamespaceDeclHandler: Optional[Callable[[str], Any]] CommentHandler: Optional[Callable[[str], Any]] @@ -69,11 +69,11 @@ class XMLParserType(object): 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]] + ExternalEntityRefHandler: Optional[Callable[[str, str | None, str | None, str | None], int]] def ErrorString(__code: int) -> str: ... # intern is undocumented def ParserCreate( - encoding: Optional[Text] = ..., namespace_separator: Optional[Text] = ..., intern: Optional[Dict[str, Any]] = ... + encoding: Text | None = ..., namespace_separator: Text | None = ..., intern: Optional[Dict[str, Any]] = ... ) -> XMLParserType: ... diff --git a/stdlib/@python2/readline.pyi b/stdlib/@python2/readline.pyi index 579308f75bc1..1d9d4017b2ce 100644 --- a/stdlib/@python2/readline.pyi +++ b/stdlib/@python2/readline.pyi @@ -1,15 +1,15 @@ from typing import Callable, Optional, Sequence, Text -_CompleterT = Optional[Callable[[str, int], Optional[str]]] +_CompleterT = Optional[Callable[[str, int], str | None]] _CompDispT = Optional[Callable[[str, Sequence[str], int], None]] def parse_and_bind(__string: str) -> None: ... -def read_init_file(__filename: Optional[Text] = ...) -> None: ... +def read_init_file(__filename: Text | None = ...) -> None: ... def get_line_buffer() -> str: ... def insert_text(__string: str) -> None: ... def redisplay() -> None: ... -def read_history_file(__filename: Optional[Text] = ...) -> None: ... -def write_history_file(__filename: Optional[Text] = ...) -> None: ... +def read_history_file(__filename: Text | None = ...) -> None: ... +def write_history_file(__filename: Text | None = ...) -> None: ... def get_history_length() -> int: ... def set_history_length(__length: int) -> None: ... def clear_history() -> None: ... diff --git a/stdlib/@python2/rfc822.pyi b/stdlib/@python2/rfc822.pyi index f536568b807d..c61bacfd8e6d 100644 --- a/stdlib/@python2/rfc822.pyi +++ b/stdlib/@python2/rfc822.pyi @@ -18,7 +18,7 @@ class Message: def getallmatchingheaders(self, name): ... def getfirstmatchingheader(self, name): ... def getrawheader(self, name): ... - def getheader(self, name, default: Optional[Any] = ...): ... + def getheader(self, name, default: Any | None = ...): ... get: Any def getheaders(self, name): ... def getaddr(self, name): ... @@ -57,7 +57,7 @@ class AddrlistClass: def getquote(self): ... def getcomment(self): ... def getdomainliteral(self): ... - def getatom(self, atomends: Optional[Any] = ...): ... + def getatom(self, atomends: Any | None = ...): ... def getphraselist(self): ... class AddressList(AddrlistClass): diff --git a/stdlib/@python2/rlcompleter.pyi b/stdlib/@python2/rlcompleter.pyi index b4ef2d1011d8..57c6682c72bf 100644 --- a/stdlib/@python2/rlcompleter.pyi +++ b/stdlib/@python2/rlcompleter.pyi @@ -4,4 +4,4 @@ _Text = str | unicode class Completer: def __init__(self, namespace: Optional[Dict[str, Any]] = ...) -> None: ... - def complete(self, text: _Text, state: int) -> Optional[str]: ... + def complete(self, text: _Text, state: int) -> str | None: ... diff --git a/stdlib/@python2/runpy.pyi b/stdlib/@python2/runpy.pyi index 6674af077d5d..8a6b38a1324d 100644 --- a/stdlib/@python2/runpy.pyi +++ b/stdlib/@python2/runpy.pyi @@ -13,5 +13,5 @@ class _ModifiedArgv0: def __enter__(self): ... def __exit__(self, *args): ... -def run_module(mod_name, init_globals: Optional[Any] = ..., run_name: Optional[Any] = ..., alter_sys: bool = ...): ... -def run_path(path_name, init_globals: Optional[Any] = ..., run_name: Optional[Any] = ...): ... +def run_module(mod_name, init_globals: Any | None = ..., run_name: Any | None = ..., alter_sys: bool = ...): ... +def run_path(path_name, init_globals: Any | None = ..., run_name: Any | None = ...): ... diff --git a/stdlib/@python2/select.pyi b/stdlib/@python2/select.pyi index 716c34a378ca..6bc40c8ce4c2 100644 --- a/stdlib/@python2/select.pyi +++ b/stdlib/@python2/select.pyi @@ -21,10 +21,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]]: ... class error(Exception): ... @@ -53,7 +53,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: Optional[Iterable[kevent]], __maxevents: int, __timeout: float | None = ... ) -> List[kevent]: ... def fileno(self) -> int: ... @classmethod @@ -106,7 +106,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 diff --git a/stdlib/@python2/shelve.pyi b/stdlib/@python2/shelve.pyi index 442c3fe3d52e..d69a5e46be88 100644 --- a/stdlib/@python2/shelve.pyi +++ b/stdlib/@python2/shelve.pyi @@ -3,7 +3,7 @@ from typing import Any, Dict, Iterator, List, Optional, Tuple class Shelf(collections.MutableMapping[Any, Any]): def __init__( - self, dict: Dict[Any, Any], protocol: Optional[int] = ..., writeback: bool = ..., keyencoding: str = ... + self, dict: Dict[Any, Any], protocol: int | None = ..., writeback: bool = ..., keyencoding: str = ... ) -> None: ... def __iter__(self) -> Iterator[str]: ... def keys(self) -> List[Any]: ... @@ -22,7 +22,7 @@ class Shelf(collections.MutableMapping[Any, Any]): class BsdDbShelf(Shelf): def __init__( - self, dict: Dict[Any, Any], protocol: Optional[int] = ..., writeback: bool = ..., keyencoding: str = ... + self, dict: Dict[Any, Any], protocol: int | None = ..., writeback: bool = ..., keyencoding: str = ... ) -> None: ... def set_location(self, key: Any) -> Tuple[str, Any]: ... def next(self) -> Tuple[str, Any]: ... @@ -31,6 +31,6 @@ class BsdDbShelf(Shelf): def last(self) -> Tuple[str, Any]: ... class DbfilenameShelf(Shelf): - 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 = ...) -> DbfilenameShelf: ... +def open(filename: str, flag: str = ..., protocol: int | None = ..., writeback: bool = ...) -> DbfilenameShelf: ... diff --git a/stdlib/@python2/shlex.pyi b/stdlib/@python2/shlex.pyi index ae048fc4c079..5e9f71f9b6ee 100644 --- a/stdlib/@python2/shlex.pyi +++ b/stdlib/@python2/shlex.pyi @@ -1,6 +1,6 @@ from typing import IO, Any, List, Optional, Text, TypeVar, Union -def split(s: Optional[str], comments: bool = ..., posix: bool = ...) -> List[str]: ... +def split(s: str | None, comments: bool = ..., posix: bool = ...) -> List[str]: ... _SLT = TypeVar("_SLT", bound=shlex) @@ -8,7 +8,7 @@ class shlex: def __init__(self, instream: IO[Any] | Text = ..., infile: IO[Any] = ..., posix: bool = ...) -> None: ... def __iter__(self: _SLT) -> _SLT: ... def next(self) -> str: ... - def get_token(self) -> Optional[str]: ... + def get_token(self) -> str | None: ... def push_token(self, _str: str) -> None: ... def read_token(self) -> str: ... def sourcehook(self, filename: str) -> None: ... @@ -23,8 +23,8 @@ class shlex: escapedquotes: str whitespace_split: bool infile: IO[Any] - source: Optional[str] + source: str | None debug: int lineno: int token: Any - eof: Optional[str] + eof: str | None diff --git a/stdlib/@python2/shutil.pyi b/stdlib/@python2/shutil.pyi index 62bd64f7b4ea..40c6fb288762 100644 --- a/stdlib/@python2/shutil.pyi +++ b/stdlib/@python2/shutil.pyi @@ -27,13 +27,13 @@ def move(src: Text, dst: Text) -> _PathReturn: ... def make_archive( base_name: _AnyStr, format: str, - root_dir: Optional[Text] = ..., - base_dir: Optional[Text] = ..., + root_dir: Text | None = ..., + base_dir: Text | None = ..., verbose: bool = ..., dry_run: bool = ..., - owner: Optional[str] = ..., - group: Optional[str] = ..., - logger: Optional[Any] = ..., + owner: str | None = ..., + group: str | None = ..., + logger: Any | None = ..., ) -> _AnyStr: ... def get_archive_formats() -> List[Tuple[str, str]]: ... def register_archive_format( diff --git a/stdlib/@python2/site.pyi b/stdlib/@python2/site.pyi index db7bbefcc794..9c8c3e363770 100644 --- a/stdlib/@python2/site.pyi +++ b/stdlib/@python2/site.pyi @@ -1,9 +1,9 @@ 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: ... diff --git a/stdlib/@python2/smtpd.pyi b/stdlib/@python2/smtpd.pyi index dae5df22ade8..c935571d0d95 100644 --- a/stdlib/@python2/smtpd.pyi +++ b/stdlib/@python2/smtpd.pyi @@ -30,16 +30,16 @@ class SMTPServer(asyncore.dispatcher): def handle_accepted(self, conn: socket.socket, addr: Any) -> None: ... def process_message( self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: bytes | str, **kwargs: Any - ) -> Optional[str]: ... + ) -> str | None: ... class DebuggingServer(SMTPServer): ... class PureProxy(SMTPServer): def process_message( # type: ignore self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: bytes | str - ) -> Optional[str]: ... + ) -> str | None: ... class MailmanProxy(PureProxy): def process_message( # type: ignore self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: bytes | str - ) -> Optional[str]: ... + ) -> str | None: ... diff --git a/stdlib/@python2/sndhdr.pyi b/stdlib/@python2/sndhdr.pyi index 1c368591ca52..31d97d83716d 100644 --- a/stdlib/@python2/sndhdr.pyi +++ b/stdlib/@python2/sndhdr.pyi @@ -2,5 +2,5 @@ from typing import Optional, Text, Tuple, Union _SndHeaders = Tuple[str, int, int, int, int | str] -def what(filename: Text) -> Optional[_SndHeaders]: ... -def whathdr(filename: Text) -> Optional[_SndHeaders]: ... +def what(filename: Text) -> _SndHeaders | None: ... +def whathdr(filename: Text) -> _SndHeaders | None: ... diff --git a/stdlib/@python2/socket.pyi b/stdlib/@python2/socket.pyi index 9fb44aee9e33..5098d459164c 100644 --- a/stdlib/@python2/socket.pyi +++ b/stdlib/@python2/socket.pyi @@ -402,7 +402,7 @@ class socket: def getsockopt(self, level: int, optname: int) -> int: ... @overload def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ... - 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]) -> None: ... def listen(self, __backlog: int) -> None: ... @@ -419,7 +419,7 @@ class socket: @overload def sendto(self, data: bytes, flags: int, address: _Address) -> int: ... def setblocking(self, flag: bool) -> None: ... - def settimeout(self, value: Optional[float]) -> None: ... + def settimeout(self, value: float | None) -> None: ... def setsockopt(self, level: int, optname: int, value: int | bytes) -> None: ... if sys.platform == "win32": def share(self, process_id: int) -> bytes: ... @@ -428,15 +428,15 @@ class socket: # ----- Functions ----- def create_connection( - address: Tuple[Optional[str], int], - timeout: Optional[float] = ..., + address: Tuple[str | None, int], + timeout: float | None = ..., source_address: Optional[Tuple[bytearray | bytes | Text, int]] = ..., ) -> socket: ... def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ... # the 5th tuple item is an address def getaddrinfo( - host: Optional[bytearray | bytes | Text], + host: bytearray | bytes | Text | None, port: str | int | None, family: int = ..., socktype: int = ..., @@ -457,7 +457,7 @@ if sys.platform == "win32": def socketpair(family: int = ..., type: int = ..., proto: int = ...) -> Tuple[socket, socket]: ... else: - def socketpair(family: Optional[int] = ..., type: int = ..., proto: int = ...) -> Tuple[socket, socket]: ... + def socketpair(family: int | None = ..., type: int = ..., proto: int = ...) -> Tuple[socket, socket]: ... def ntohl(x: int) -> int: ... # param & ret val are 32-bit ints def ntohs(x: int) -> int: ... # param & ret val are 16-bit ints @@ -467,5 +467,5 @@ def inet_aton(ip_string: str) -> bytes: ... # ret val 4 bytes in length def inet_ntoa(packed_ip: bytes) -> str: ... def inet_pton(address_family: int, ip_string: str) -> bytes: ... def inet_ntop(address_family: int, packed_ip: bytes) -> str: ... -def getdefaulttimeout() -> Optional[float]: ... -def setdefaulttimeout(timeout: Optional[float]) -> None: ... +def getdefaulttimeout() -> float | None: ... +def setdefaulttimeout(timeout: float | None) -> None: ... diff --git a/stdlib/@python2/sqlite3/dbapi2.pyi b/stdlib/@python2/sqlite3/dbapi2.pyi index 46073e601e27..e78d3cb2a435 100644 --- a/stdlib/@python2/sqlite3/dbapi2.pyi +++ b/stdlib/@python2/sqlite3/dbapi2.pyi @@ -65,7 +65,7 @@ def connect( database: bytes | Text, timeout: float = ..., detect_types: int = ..., - isolation_level: Optional[str] = ..., + isolation_level: str | None = ..., check_same_thread: bool = ..., factory: Optional[Type[Connection]] = ..., cached_statements: int = ..., @@ -106,7 +106,7 @@ class Connection(object): def create_aggregate(self, name: str, n_arg: int, aggregate_class: Callable[[], _AggregateProtocol]) -> None: ... def create_collation(self, __name: str, __callback: Any) -> None: ... 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: ... @@ -127,7 +127,7 @@ class Connection(object): def load_extension(self, path: str) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... def __enter__(self) -> Connection: ... - 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 @@ -145,7 +145,7 @@ class Cursor(Iterator[Any]): def executemany(self, __sql: str, __seq_of_parameters: Iterable[Iterable[Any]]) -> Cursor: ... def executescript(self, __sql_script: bytes | Text) -> 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/@python2/sre_parse.pyi b/stdlib/@python2/sre_parse.pyi index 3ec611bd9c0d..d02af97122f0 100644 --- a/stdlib/@python2/sre_parse.pyi +++ b/stdlib/@python2/sre_parse.pyi @@ -21,7 +21,7 @@ class Pattern: def closegroup(self, gid: int) -> None: ... def checkgroup(self, gid: int) -> bool: ... -_OpSubpatternType = Tuple[Optional[int], int, int, SubPattern] +_OpSubpatternType = Tuple[int | None, int, int, SubPattern] _OpGroupRefExistsType = Tuple[int, SubPattern, SubPattern] _OpInType = List[Tuple[str, int]] _OpBranchType = Tuple[None, List[SubPattern]] @@ -31,7 +31,7 @@ _CodeType = str | _AvType class SubPattern: pattern: str data: List[_CodeType] - width: Optional[int] + width: int | None def __init__(self, pattern, data: List[_CodeType] = ...) -> None: ... def dump(self, level: int = ...) -> None: ... def __len__(self) -> int: ... @@ -47,8 +47,8 @@ class Tokenizer: index: int def __init__(self, string: str) -> None: ... def match(self, char: str, skip: int = ...) -> int: ... - def get(self) -> Optional[str]: ... - def tell(self) -> Tuple[int, Optional[str]]: ... + def get(self) -> str | None: ... + def tell(self) -> Tuple[int, str | None]: ... def seek(self, index: int) -> None: ... def isident(char: str) -> bool: ... @@ -56,7 +56,7 @@ def isdigit(char: str) -> bool: ... def isname(name: str) -> bool: ... def parse(str: str, flags: int = ..., pattern: Pattern = ...) -> SubPattern: ... -_Template = Tuple[List[Tuple[int, int]], List[Optional[int]]] +_Template = Tuple[List[Tuple[int, int]], List[int | None]] def parse_template(source: str, pattern: _Pattern[Any]) -> _Template: ... def expand_template(template: _Template, match: Match[Any]) -> str: ... diff --git a/stdlib/@python2/ssl.pyi b/stdlib/@python2/ssl.pyi index 3451ff3116f1..35d0d54c6f49 100644 --- a/stdlib/@python2/ssl.pyi +++ b/stdlib/@python2/ssl.pyi @@ -12,7 +12,7 @@ _EnumRetType = List[Tuple[bytes, str, Set[str] | bool]] _PasswordType = Union[Callable[[], str | bytes], str, bytes] _SC1ArgT = SSLSocket -_SrvnmeCbType = Callable[[_SC1ArgT, Optional[str], SSLSocket], Optional[int]] +_SrvnmeCbType = Callable[[_SC1ArgT, str | None, SSLSocket], int | None] class SSLError(OSError): library: str @@ -27,29 +27,29 @@ class CertificateError(ValueError): ... 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: Text | bytes | None = ... + purpose: Any = ..., *, cafile: str | None = ..., capath: str | None = ..., cadata: Text | bytes | None = ... ) -> SSLContext: ... 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] = ..., + certfile: str | None = ..., + keyfile: str | None = ..., + cafile: str | None = ..., + capath: str | None = ..., cadata: Text | bytes | None = ..., ) -> SSLContext: ... @@ -60,7 +60,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: ... @@ -157,57 +157,57 @@ class Purpose(_ASN1Object): class SSLSocket(socket.socket): context: SSLContext server_side: bool - server_hostname: Optional[str] + server_hostname: str | None 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] = ..., + ciphers: str | None = ..., + server_hostname: str | None = ..., + _context: SSLContext | None = ..., + _session: Any | None = ..., ) -> None: ... 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: socket._WriteBuffer, nbytes: Optional[int] = ..., flags: int = ...) -> int: ... + def recv_into(self, buffer: socket._WriteBuffer, nbytes: int | None = ..., flags: int = ...) -> int: ... def recvfrom(self, buflen: int = ..., flags: int = ...) -> tuple[bytes, socket._RetAddress]: ... def recvfrom_into( - self, buffer: socket._WriteBuffer, nbytes: Optional[int] = ..., flags: int = ... + self, buffer: socket._WriteBuffer, nbytes: int | None = ..., flags: int = ... ) -> tuple[int, socket._RetAddress]: ... @overload def sendto(self, data: bytes, flags_or_addr: socket._Address) -> int: ... @overload - def sendto(self, data: bytes, flags_or_addr: int | socket._Address, addr: Optional[socket._Address] = ...) -> int: ... - def read(self, len: int = ..., buffer: Optional[bytearray] = ...) -> bytes: ... + def sendto(self, data: bytes, flags_or_addr: int | socket._Address, addr: socket._Address | None = ...) -> int: ... + 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 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 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: ... class SSLContext: @@ -221,18 +221,18 @@ 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: Text | bytes | None = ... + self, cafile: StrPath | None = ..., capath: StrPath | None = ..., cadata: Text | bytes | None = ... ) -> None: ... def get_ca_certs(self, binary_form: bool = ...) -> List[_PeerCertRetDictType] | List[bytes]: ... 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: ... - 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( @@ -241,7 +241,7 @@ class SSLContext: server_side: bool = ..., do_handshake_on_connect: bool = ..., suppress_ragged_eofs: bool = ..., - server_hostname: Optional[str] = ..., + server_hostname: str | None = ..., ) -> SSLSocket: ... def session_stats(self) -> Dict[str, int]: ... diff --git a/stdlib/@python2/subprocess.pyi b/stdlib/@python2/subprocess.pyi index d978531c51a0..0d26eaf63efb 100644 --- a/stdlib/@python2/subprocess.pyi +++ b/stdlib/@python2/subprocess.pyi @@ -16,8 +16,8 @@ def call( preexec_fn: Callable[[], Any] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[_TXT] = ..., - env: Optional[_ENV] = ..., + cwd: _TXT | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -32,8 +32,8 @@ def check_call( preexec_fn: Callable[[], Any] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[_TXT] = ..., - env: Optional[_ENV] = ..., + cwd: _TXT | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -49,8 +49,8 @@ def check_output( preexec_fn: Callable[[], Any] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[_TXT] = ..., - env: Optional[_ENV] = ..., + cwd: _TXT | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -63,9 +63,9 @@ class CalledProcessError(Exception): returncode: int # morally: _CMD cmd: Any - # morally: Optional[bytes] + # morally: bytes | None output: bytes - def __init__(self, returncode: int, cmd: _CMD, output: Optional[bytes] = ...) -> None: ... + def __init__(self, returncode: int, cmd: _CMD, output: bytes | None = ...) -> None: ... # We use a dummy type variable used to make Popen generic like it is in python 3 _T = TypeVar("_T", bound=bytes) @@ -80,23 +80,23 @@ class Popen(Generic[_T]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[_TXT] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., + executable: _TXT | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[_TXT] = ..., - env: Optional[_ENV] = ..., + cwd: _TXT | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., - startupinfo: Optional[Any] = ..., + startupinfo: Any | None = ..., creationflags: int = ..., ) -> Popen[bytes]: ... - def poll(self) -> Optional[int]: ... + def poll(self) -> int | None: ... def wait(self) -> int: ... - # morally: -> Tuple[Optional[bytes], Optional[bytes]] - def communicate(self, input: Optional[_TXT] = ...) -> Tuple[bytes, bytes]: ... + # morally: -> Tuple[bytes | None, bytes | None] + def communicate(self, input: _TXT | None = ...) -> Tuple[bytes, bytes]: ... def send_signal(self, signal: int) -> None: ... def terminate(self) -> None: ... def kill(self) -> None: ... diff --git a/stdlib/@python2/sunau.pyi b/stdlib/@python2/sunau.pyi index ec632897fdd8..049416505bb3 100644 --- a/stdlib/@python2/sunau.pyi +++ b/stdlib/@python2/sunau.pyi @@ -37,7 +37,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: ... @@ -61,6 +61,6 @@ 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: ... openfp = open diff --git a/stdlib/@python2/sys.pyi b/stdlib/@python2/sys.pyi index c258e0f22f41..93170da49388 100644 --- a/stdlib/@python2/sys.pyi +++ b/stdlib/@python2/sys.pyi @@ -86,7 +86,7 @@ path_hooks: List[Any] path_importer_cache: Dict[str, Any] displayhook: Callable[[object], Any] excepthook: Callable[[Type[BaseException], BaseException, TracebackType], Any] -exc_type: Optional[type] +exc_type: type | None exc_value: BaseException | ClassType exc_traceback: TracebackType @@ -120,8 +120,8 @@ def getfilesystemencoding() -> str: ... # In practice, never returns None def getrefcount(arg: Any) -> int: ... def getrecursionlimit() -> int: ... def getsizeof(obj: object, default: int = ...) -> int: ... -def getprofile() -> Optional[Any]: ... -def gettrace() -> Optional[Any]: ... +def getprofile() -> Any | None: ... +def gettrace() -> Any | None: ... def setcheckinterval(interval: int) -> None: ... # deprecated def setdlopenflags(n: int) -> None: ... def setdefaultencoding(encoding: Text) -> None: ... # only exists after reload(sys) diff --git a/stdlib/@python2/sysconfig.pyi b/stdlib/@python2/sysconfig.pyi index b8044bcaa615..bd923405e4e0 100644 --- a/stdlib/@python2/sysconfig.pyi +++ b/stdlib/@python2/sysconfig.pyi @@ -1,13 +1,13 @@ 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 = ...) -> Optional[str]: ... +def get_path(name: str, scheme: str = ..., vars: Optional[Dict[str, Any]] = ..., expand: bool = ...) -> str | None: ... def get_paths(scheme: str = ..., vars: Optional[Dict[str, Any]] = ..., expand: bool = ...) -> Dict[str, str]: ... def get_python_version() -> str: ... def get_platform() -> str: ... diff --git a/stdlib/@python2/tarfile.pyi b/stdlib/@python2/tarfile.pyi index 0b0a40215a02..f6ef8cafe65f 100644 --- a/stdlib/@python2/tarfile.pyi +++ b/stdlib/@python2/tarfile.pyi @@ -50,21 +50,21 @@ TAR_PLAIN: int TAR_GZIPPED: int def open( - name: Optional[Text] = ..., + name: Text | None = ..., mode: str = ..., fileobj: Optional[IO[bytes]] = ..., bufsize: int = ..., *, - format: Optional[int] = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + 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] = ..., + debug: int | None = ..., + errorlevel: int | None = ..., + compresslevel: int | None = ..., ) -> TarFile: ... class ExFileObject(io.BufferedReader): @@ -72,133 +72,133 @@ class ExFileObject(io.BufferedReader): class TarFile(Iterable[TarInfo]): OPEN_METH: Mapping[str, str] - name: Optional[Text] + name: Text | None mode: str fileobj: Optional[IO[bytes]] - format: Optional[int] + 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] + debug: int | None + errorlevel: int | None offset: int # undocumented posix: bool def __init__( self, - name: Optional[Text] = ..., + name: Text | None = ..., mode: str = ..., fileobj: Optional[IO[bytes]] = ..., - format: Optional[int] = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + 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 + debug: int | None = ..., + errorlevel: int | None = ..., + copybufsize: int | None = ..., # undocumented ) -> None: ... def __enter__(self) -> TarFile: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __iter__(self) -> Iterator[TarInfo]: ... @classmethod def open( cls, - name: Optional[Text] = ..., + name: Text | None = ..., mode: str = ..., fileobj: Optional[IO[bytes]] = ..., bufsize: int = ..., *, - format: Optional[int] = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., errors: str = ..., pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... @classmethod def taropen( cls, - name: Optional[Text], + name: Text | None, mode: str = ..., fileobj: Optional[IO[bytes]] = ..., *, compresslevel: int = ..., - format: Optional[int] = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... @classmethod def gzopen( cls, - name: Optional[Text], + name: Text | None, mode: str = ..., fileobj: Optional[IO[bytes]] = ..., compresslevel: int = ..., *, - format: Optional[int] = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... @classmethod def bz2open( cls, - name: Optional[Text], + name: Text | None, mode: str = ..., fileobj: Optional[IO[bytes]] = ..., compresslevel: int = ..., *, - format: Optional[int] = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... @classmethod def xzopen( cls, - name: Optional[Text], + name: Text | None, mode: str = ..., fileobj: Optional[IO[bytes]] = ..., - preset: Optional[int] = ..., + preset: int | None = ..., *, - format: Optional[int] = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... def getmember(self, name: str) -> TarInfo: ... def getmembers(self) -> List[TarInfo]: ... def getnames(self) -> List[str]: ... def list(self, verbose: bool = ...) -> None: ... - def next(self) -> Optional[TarInfo]: ... + def next(self) -> TarInfo | None: ... def extractall(self, path: Text = ..., members: Optional[Iterable[TarInfo]] = ...) -> None: ... def extract(self, member: str | TarInfo, path: Text = ...) -> None: ... def extractfile(self, member: str | TarInfo) -> Optional[IO[bytes]]: ... @@ -214,14 +214,14 @@ class TarFile(Iterable[TarInfo]): def add( self, name: str, - arcname: Optional[str] = ..., + arcname: str | None = ..., recursive: bool = ..., exclude: Optional[Callable[[str], bool]] = ..., - filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ..., + filter: Optional[Callable[[TarInfo], TarInfo | None]] = ..., ) -> None: ... def addfile(self, tarinfo: TarInfo, fileobj: Optional[IO[bytes]] = ...) -> None: ... def gettarinfo( - self, name: Optional[str] = ..., arcname: Optional[str] = ..., fileobj: Optional[IO[bytes]] = ... + self, name: str | None = ..., arcname: str | None = ..., fileobj: Optional[IO[bytes]] = ... ) -> TarInfo: ... def close(self) -> None: ... @@ -248,8 +248,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 @@ -268,7 +268,7 @@ class TarInfo: @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 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 ) -> bytes: ... diff --git a/stdlib/@python2/telnetlib.pyi b/stdlib/@python2/telnetlib.pyi index 1f471689d9a0..552606e93a93 100644 --- a/stdlib/@python2/telnetlib.pyi +++ b/stdlib/@python2/telnetlib.pyi @@ -81,8 +81,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: ... @@ -90,7 +90,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: ... @@ -107,5 +107,5 @@ class Telnet: def mt_interact(self) -> None: ... def listener(self) -> None: ... def expect( - self, list: Sequence[Pattern[bytes] | bytes], timeout: Optional[float] = ... + self, list: Sequence[Pattern[bytes] | bytes], timeout: float | None = ... ) -> Tuple[int, Optional[Match[bytes]], bytes]: ... diff --git a/stdlib/@python2/tempfile.pyi b/stdlib/@python2/tempfile.pyi index c6b94da4befd..40774d904d67 100644 --- a/stdlib/@python2/tempfile.pyi +++ b/stdlib/@python2/tempfile.pyi @@ -5,7 +5,7 @@ from typing import IO, Any, AnyStr, Iterable, Iterator, List, Optional, Text, Tu TMP_MAX: int tempdir: str template: str -_name_sequence: Optional[_RandomNameSequence] +_name_sequence: _RandomNameSequence | None class _RandomNameSequence: characters: str = ... @@ -24,7 +24,7 @@ class _TemporaryFileWrapper(IO[str]): def __init__(self, file: IO[str], name: Any, delete: bool = ...) -> None: ... def __del__(self) -> None: ... def __enter__(self) -> _TemporaryFileWrapper: ... - def __exit__(self, exc, value, tb) -> Optional[bool]: ... + def __exit__(self, exc, value, tb) -> bool | None: ... def __getattr__(self, name: unicode) -> Any: ... def close(self) -> None: ... def unlink(self, path: unicode) -> None: ... @@ -43,7 +43,7 @@ class _TemporaryFileWrapper(IO[str]): 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: Text) -> int: ... def writelines(self, lines: Iterable[str]) -> None: ... @@ -86,17 +86,17 @@ class TemporaryDirectory: @overload def mkstemp() -> Tuple[int, str]: ... @overload -def mkstemp(suffix: AnyStr = ..., prefix: AnyStr = ..., dir: Optional[AnyStr] = ..., text: bool = ...) -> Tuple[int, AnyStr]: ... +def mkstemp(suffix: AnyStr = ..., prefix: AnyStr = ..., dir: AnyStr | None = ..., text: bool = ...) -> Tuple[int, AnyStr]: ... @overload def mkdtemp() -> str: ... @overload -def mkdtemp(suffix: AnyStr = ..., prefix: AnyStr = ..., dir: Optional[AnyStr] = ...) -> AnyStr: ... +def mkdtemp(suffix: AnyStr = ..., prefix: AnyStr = ..., dir: AnyStr | None = ...) -> AnyStr: ... @overload def mktemp() -> str: ... @overload -def mktemp(suffix: AnyStr = ..., prefix: AnyStr = ..., dir: Optional[AnyStr] = ...) -> AnyStr: ... +def mktemp(suffix: AnyStr = ..., prefix: AnyStr = ..., dir: AnyStr | None = ...) -> AnyStr: ... def gettempdir() -> str: ... def gettempprefix() -> str: ... def _candidate_tempdir_list() -> List[str]: ... -def _get_candidate_names() -> Optional[_RandomNameSequence]: ... +def _get_candidate_names() -> _RandomNameSequence | None: ... def _get_default_tempdir() -> str: ... diff --git a/stdlib/@python2/threading.pyi b/stdlib/@python2/threading.pyi index 06392616484e..44b81fe337bf 100644 --- a/stdlib/@python2/threading.pyi +++ b/stdlib/@python2/threading.pyi @@ -15,7 +15,7 @@ def current_thread() -> Thread: ... def currentThread() -> Thread: ... def enumerate() -> List[Thread]: ... def settrace(func: _TF) -> None: ... -def setprofile(func: Optional[_PF]) -> None: ... +def setprofile(func: _PF | None) -> None: ... def stack_size(size: int = ...) -> int: ... class ThreadError(Exception): ... @@ -27,19 +27,19 @@ 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[Text] = ..., + name: Text | None = ..., args: Iterable[Any] = ..., kwargs: Optional[Mapping[Text, Any]] = ..., ) -> 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: Text) -> None: ... def is_alive(self) -> bool: ... @@ -53,8 +53,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: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... def locked(self) -> bool: ... @@ -63,8 +63,8 @@ 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: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... @@ -74,11 +74,11 @@ class Condition: 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: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... - def wait(self, timeout: Optional[float] = ...) -> bool: ... + def wait(self, timeout: float | None = ...) -> bool: ... def notify(self, n: int = ...) -> None: ... def notify_all(self) -> None: ... def notifyAll(self) -> None: ... @@ -86,8 +86,8 @@ 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]: ... + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def __enter__(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... @@ -100,7 +100,7 @@ class Event: def isSet(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 Timer(Thread): def __init__( diff --git a/stdlib/@python2/time.pyi b/stdlib/@python2/time.pyi index b2a916c454d0..7563a9bb63d7 100644 --- a/stdlib/@python2/time.pyi +++ b/stdlib/@python2/time.pyi @@ -32,9 +32,9 @@ class struct_time(_struct_time): def asctime(t: _TimeTuple | struct_time = ...) -> str: ... def clock() -> float: ... -def ctime(secs: Optional[float] = ...) -> str: ... -def gmtime(secs: Optional[float] = ...) -> struct_time: ... -def localtime(secs: Optional[float] = ...) -> struct_time: ... +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: _TimeTuple | struct_time = ...) -> str: ... diff --git a/stdlib/@python2/trace.pyi b/stdlib/@python2/trace.pyi index 1e60b392e565..7e42db7afa8f 100644 --- a/stdlib/@python2/trace.pyi +++ b/stdlib/@python2/trace.pyi @@ -4,21 +4,21 @@ from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple, Type _T = TypeVar("_T") _localtrace = Callable[[types.FrameType, str, Any], Callable[..., Any]] -_fileModuleFunction = Tuple[str, Optional[str], str] +_fileModuleFunction = Tuple[str, str | None, str] class CoverageResults: def __init__( self, counts: Optional[Dict[Tuple[str, int], int]] = ..., calledfuncs: Optional[Dict[_fileModuleFunction, int]] = ..., - infile: Optional[StrPath] = ..., + infile: StrPath | None = ..., callers: Optional[Dict[Tuple[_fileModuleFunction, _fileModuleFunction], int]] = ..., - outfile: Optional[StrPath] = ..., + 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]: ... class Trace: @@ -30,8 +30,8 @@ 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: str | types.CodeType) -> None: ... diff --git a/stdlib/@python2/traceback.pyi b/stdlib/@python2/traceback.pyi index 3144fdd6700b..0917b3a7a132 100644 --- a/stdlib/@python2/traceback.pyi +++ b/stdlib/@python2/traceback.pyi @@ -1,27 +1,27 @@ from types import FrameType, TracebackType from typing import IO, List, Optional, Tuple, Type -_PT = Tuple[str, int, str, Optional[str]] +_PT = Tuple[str, int, str, str | None] -def print_tb(tb: Optional[TracebackType], limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... +def print_tb(tb: TracebackType | None, limit: int | None = ..., file: Optional[IO[str]] = ...) -> None: ... def print_exception( etype: Optional[Type[BaseException]], - value: Optional[BaseException], - tb: Optional[TracebackType], - limit: Optional[int] = ..., + value: BaseException | None, + tb: TracebackType | None, + limit: int | None = ..., file: Optional[IO[str]] = ..., ) -> None: ... -def print_exc(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... -def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... -def print_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... -def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[_PT]: ... -def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[_PT]: ... +def print_exc(limit: int | None = ..., file: Optional[IO[str]] = ...) -> None: ... +def print_last(limit: int | None = ..., file: Optional[IO[str]] = ...) -> None: ... +def print_stack(f: FrameType | None = ..., limit: int | None = ..., file: Optional[IO[str]] = ...) -> None: ... +def extract_tb(tb: TracebackType | None, limit: int | None = ...) -> List[_PT]: ... +def extract_stack(f: FrameType | None = ..., limit: int | None = ...) -> List[_PT]: ... def format_list(extracted_list: List[_PT]) -> List[str]: ... -def format_exception_only(etype: Optional[Type[BaseException]], value: Optional[BaseException]) -> List[str]: ... +def format_exception_only(etype: Optional[Type[BaseException]], value: BaseException | None) -> List[str]: ... def format_exception( - etype: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[TracebackType], limit: Optional[int] = ... + etype: Optional[Type[BaseException]], value: BaseException | None, tb: TracebackType | None, limit: int | None = ... ) -> List[str]: ... -def format_exc(limit: Optional[int] = ...) -> 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 = ...) -> str: ... +def format_tb(tb: TracebackType | None, limit: int | None = ...) -> List[str]: ... +def format_stack(f: FrameType | None = ..., limit: int | None = ...) -> List[str]: ... def tb_lineno(tb: TracebackType) -> int: ... diff --git a/stdlib/@python2/turtle.pyi b/stdlib/@python2/turtle.pyi index 5f3c3055012f..5e9e7444355a 100644 --- a/stdlib/@python2/turtle.pyi +++ b/stdlib/@python2/turtle.pyi @@ -34,7 +34,7 @@ class TurtleGraphicsError(Exception): ... class Shape(object): def __init__(self, type_: str, data: _PolygonCoords | PhotoImage | None = ...) -> None: ... - def addcomponent(self, poly: _PolygonCoords, fill: _Color, outline: Optional[_Color] = ...) -> 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: ... @@ -60,7 +60,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 @@ -70,9 +70,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: ... @@ -82,7 +82,7 @@ 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 @@ -121,7 +121,7 @@ class TNavigator(object): 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 @@ -178,7 +178,7 @@ class TPen(object): @overload def pen( self, - pen: Optional[_PenState] = ..., + pen: _PenState | None = ..., *, shown: bool = ..., pendown: bool = ..., @@ -206,7 +206,7 @@ class RawTurtle(TPen, TNavigator): 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: ... @@ -219,7 +219,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: ... def settiltangle(self, angle: float) -> None: ... @overload @@ -232,21 +232,21 @@ class RawTurtle(TPen, TNavigator): # we return Any. def stamp(self) -> Any: ... def clearstamp(self, stampid: int | Tuple[int, ...]) -> None: ... - def clearstamps(self, n: Optional[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 @@ -257,8 +257,8 @@ class _Screen(TurtleScreen): self, width: int | float = ..., height: int | float = ..., - startx: Optional[int] = ..., - starty: Optional[int] = ..., + startx: int | None = ..., + starty: int | None = ..., ) -> None: ... def title(self, titlestring: str) -> None: ... def bye(self) -> None: ... @@ -311,7 +311,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 @@ -321,9 +321,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: ... @@ -332,7 +332,7 @@ 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 @@ -340,7 +340,7 @@ clearscreen = clear addshape = register_shape # 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: ... @@ -374,7 +374,7 @@ def towards(x: TNavigator | Tuple[float, float], y: None = ...) -> float: ... 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 @@ -431,7 +431,7 @@ def isvisible() -> bool: ... def pen() -> _PenState: ... # type: ignore @overload def pen( - pen: Optional[_PenState] = ..., + pen: _PenState | None = ..., *, shown: bool = ..., pendown: bool = ..., @@ -455,7 +455,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: ... @@ -466,7 +466,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: ... def settiltangle(angle: float) -> None: ... @overload def tiltangle(angle: None = ...) -> float: ... @@ -479,22 +479,22 @@ def tilt(angle: float) -> None: ... # we return Any. def stamp() -> Any: ... def clearstamp(stampid: int | Tuple[int, ...]) -> None: ... -def clearstamps(n: Optional[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/@python2/types.pyi b/stdlib/@python2/types.pyi index 5d87f75f9ef0..e0596ae0f49f 100644 --- a/stdlib/@python2/types.pyi +++ b/stdlib/@python2/types.pyi @@ -31,7 +31,7 @@ class FunctionType: func_code: CodeType = ... func_defaults: Optional[Tuple[Any, ...]] = ... func_dict: Dict[str, Any] = ... - func_doc: Optional[str] = ... + func_doc: str | None = ... func_globals: Dict[str, Any] = ... func_name: str = ... __closure__ = func_closure @@ -44,12 +44,12 @@ class FunctionType: self, code: CodeType, globals: Dict[str, Any], - name: Optional[str] = ..., + name: str | None = ..., argdefs: Optional[Tuple[object, ...]] = ..., closure: Optional[Tuple[_Cell, ...]] = ..., ) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... - def __get__(self, obj: Optional[object], type: Optional[type]) -> UnboundMethodType: ... + def __get__(self, obj: object | None, type: type | None) -> UnboundMethodType: ... LambdaType = FunctionType @@ -96,10 +96,10 @@ class GeneratorType: def send(self, __arg: Any) -> Any: ... @overload def throw( - self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: Optional[TracebackType] = ... + self, __typ: Type[BaseException], __val: 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 ClassType: ... @@ -118,19 +118,19 @@ class InstanceType(object): ... MethodType = UnboundMethodType class BuiltinFunctionType: - __self__: Optional[object] + __self__: object | None def __call__(self, *args: Any, **kwargs: Any) -> Any: ... BuiltinMethodType = BuiltinFunctionType class ModuleType: - __doc__: Optional[str] - __file__: Optional[str] + __doc__: str | None + __file__: str | None __name__: str - __package__: Optional[str] + __package__: str | None __path__: Optional[Iterable[str]] __dict__: Dict[str, Any] - def __init__(self, name: str, doc: Optional[str] = ...) -> None: ... + def __init__(self, name: str, doc: str | None = ...) -> None: ... FileType = file XRangeType = xrange diff --git a/stdlib/@python2/typing.pyi b/stdlib/@python2/typing.pyi index ed598a0e0a8b..4e4fbd6dd146 100644 --- a/stdlib/@python2/typing.pyi +++ b/stdlib/@python2/typing.pyi @@ -144,11 +144,11 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]): @overload @abstractmethod def throw( - self, __typ: Type[BaseException], __val: 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: ... @property @@ -265,9 +265,9 @@ class ContextManager(Protocol[_T_co]): def __exit__( self, __exc_type: Optional[Type[BaseException]], - __exc_value: Optional[BaseException], - __traceback: Optional[TracebackType], - ) -> Optional[bool]: ... + __exc_value: BaseException | None, + __traceback: TracebackType | None, + ) -> bool | None: ... class Mapping(Iterable[_KT], Container[_KT], Generic[_KT, _VT_co]): # TODO: We wish the key type could also be covariant, but that doesn't work, @@ -276,7 +276,7 @@ class Mapping(Iterable[_KT], Container[_KT], Generic[_KT, _VT_co]): def __getitem__(self, k: _KT) -> _VT_co: ... # Mixin methods @overload - def get(self, k: _KT) -> Optional[_VT_co]: ... + def get(self, k: _KT) -> _VT_co | None: ... @overload def get(self, k: _KT, default: _VT_co | _T) -> _VT_co | _T: ... def keys(self) -> list[_KT]: ... @@ -346,7 +346,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: ... # TODO buffer objects @@ -362,8 +362,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: Optional[Type[BaseException]], value: BaseException | None, traceback: TracebackType | None + ) -> bool | None: ... class BinaryIO(IO[str]): # TODO readinto @@ -379,7 +379,7 @@ class TextIO(IO[unicode]): @property def encoding(self) -> str: ... @property - def errors(self) -> Optional[str]: ... + def errors(self) -> str | None: ... @property def line_buffering(self) -> bool: ... @property @@ -392,7 +392,7 @@ class ByteString(Sequence[int], metaclass=ABCMeta): ... class Match(Generic[AnyStr]): pos: int endpos: int - lastindex: Optional[int] + lastindex: int | None string: AnyStr # The regular expression object whose match() or search() method produced @@ -404,7 +404,7 @@ class Match(Generic[AnyStr]): re: Pattern[Any] # Can be None if there are no groups or if the last group was unnamed; # otherwise matches the type of the pattern. - lastgroup: Optional[Any] + lastgroup: Any | None def expand(self, template: str | Text) -> Any: ... @overload def group(self, group1: int = ...) -> AnyStr: ... diff --git a/stdlib/@python2/unittest.pyi b/stdlib/@python2/unittest.pyi index fae03ac84074..4fd12b43df3d 100644 --- a/stdlib/@python2/unittest.pyi +++ b/stdlib/@python2/unittest.pyi @@ -79,7 +79,7 @@ class _AssertRaisesContext(_AssertRaisesBaseContext): class TestCase(Testable): failureException: Type[BaseException] longMessage: bool - maxDiff: Optional[int] + maxDiff: int | None # undocumented _testMethodName: str def __init__(self, methodName: str = ...) -> None: ... @@ -187,7 +187,7 @@ class TestCase(Testable): def addCleanup(self, function: Any, *args: Any, **kwargs: Any) -> None: ... def doCleanups(self) -> bool: ... def skipTest(self, reason: Any) -> None: ... - def _formatMessage(self, msg: Optional[Text], standardMsg: Text) -> str: ... # undocumented + def _formatMessage(self, msg: Text | None, standardMsg: Text) -> str: ... # undocumented def _getAssertEqualityFunc(self, first: Any, second: Any) -> Callable[..., None]: ... # undocumented class FunctionTestCase(TestCase): @@ -196,7 +196,7 @@ class FunctionTestCase(TestCase): testFunc: Callable[[], None], setUp: Optional[Callable[[], None]] = ..., tearDown: Optional[Callable[[], None]] = ..., - description: Optional[str] = ..., + description: str | None = ..., ) -> None: ... def debug(self) -> None: ... def countTestCases(self) -> int: ... @@ -216,9 +216,9 @@ class TestLoader: suiteClass: Callable[[List[TestCase]], TestSuite] def loadTestsFromTestCase(self, testCaseClass: Type[TestCase]) -> TestSuite: ... def loadTestsFromModule(self, module: types.ModuleType = ..., use_load_tests: bool = ...) -> TestSuite: ... - def loadTestsFromName(self, name: str = ..., module: Optional[types.ModuleType] = ...) -> TestSuite: ... - def loadTestsFromNames(self, names: List[str] = ..., module: Optional[types.ModuleType] = ...) -> TestSuite: ... - def discover(self, start_dir: str, pattern: str = ..., top_level_dir: Optional[str] = ...) -> TestSuite: ... + def loadTestsFromName(self, name: str = ..., module: types.ModuleType | None = ...) -> TestSuite: ... + def loadTestsFromNames(self, names: List[str] = ..., module: types.ModuleType | None = ...) -> TestSuite: ... + def discover(self, start_dir: str, pattern: str = ..., top_level_dir: str | None = ...) -> TestSuite: ... def getTestCaseNames(self, testCaseClass: Type[TestCase] = ...) -> List[str]: ... defaultTestLoader: TestLoader @@ -232,7 +232,7 @@ class TextTestResult(TestResult): class TextTestRunner: def __init__( self, - stream: Optional[TextIO] = ..., + stream: TextIO | None = ..., descriptions: bool = ..., verbosity: int = ..., failfast: bool = ..., @@ -257,17 +257,17 @@ class TestProgram: def main( module: None | Text | types.ModuleType = ..., - defaultTest: Optional[str] = ..., + defaultTest: str | None = ..., argv: Optional[Sequence[str]] = ..., testRunner: Type[TextTestRunner] | TextTestRunner | None = ..., testLoader: TestLoader = ..., exit: bool = ..., verbosity: int = ..., - failfast: Optional[bool] = ..., - catchbreak: Optional[bool] = ..., - buffer: Optional[bool] = ..., + failfast: bool | None = ..., + catchbreak: bool | None = ..., + buffer: bool | None = ..., ) -> TestProgram: ... -def load_tests(loader: TestLoader, tests: TestSuite, pattern: Optional[Text]) -> TestSuite: ... +def load_tests(loader: TestLoader, tests: TestSuite, pattern: Text | None) -> TestSuite: ... def installHandler() -> None: ... def registerResult(result: TestResult) -> None: ... def removeResult(result: TestResult) -> bool: ... diff --git a/stdlib/@python2/urllib.pyi b/stdlib/@python2/urllib.pyi index c719c1faa693..390b2fd9a717 100644 --- a/stdlib/@python2/urllib.pyi +++ b/stdlib/@python2/urllib.pyi @@ -84,7 +84,7 @@ class addbase: def read(self, n: int = ...) -> bytes: ... def readline(self, limit: int = ...) -> bytes: ... def readlines(self, hint: int = ...) -> List[bytes]: ... - def fileno(self) -> int: ... # Optional[int], but that is rare + def fileno(self) -> int: ... # int | None, but that is rare def __iter__(self: _AIUT) -> _AIUT: ... def next(self) -> bytes: ... def __init__(self, fp) -> None: ... diff --git a/stdlib/@python2/urllib2.pyi b/stdlib/@python2/urllib2.pyi index 1a06c240e23b..eb2deda32590 100644 --- a/stdlib/@python2/urllib2.pyi +++ b/stdlib/@python2/urllib2.pyi @@ -19,16 +19,16 @@ class Request(object): data: str headers: Dict[str, str] unverifiable: bool - type: Optional[str] + type: str | None origin_req_host = ... unredirected_hdrs: Dict[str, str] - timeout: Optional[float] # Undocumented, only set after __init__() by OpenerDirector.open() + timeout: float | None # Undocumented, only set after __init__() by OpenerDirector.open() def __init__( self, url: str, - data: Optional[str] = ..., + data: str | None = ..., headers: Dict[str, str] = ..., - origin_req_host: Optional[str] = ..., + origin_req_host: str | None = ..., unverifiable: bool = ..., ) -> None: ... def __getattr__(self, attr): ... @@ -47,27 +47,27 @@ class Request(object): def add_header(self, key: str, val: str) -> None: ... def add_unredirected_header(self, key: str, val: str) -> None: ... def has_header(self, header_name: str) -> bool: ... - def get_header(self, header_name: str, default: Optional[str] = ...) -> str: ... + def get_header(self, header_name: str, default: str | None = ...) -> str: ... def header_items(self): ... class OpenerDirector(object): addheaders: List[Tuple[str, str]] def add_handler(self, handler: BaseHandler) -> None: ... def open( - self, fullurl: Request | _string, data: Optional[_string] = ..., timeout: Optional[float] = ... - ) -> Optional[addinfourl]: ... + self, fullurl: Request | _string, data: _string | None = ..., timeout: float | None = ... + ) -> addinfourl | None: ... def error(self, proto: _string, *args: Any): ... # Note that this type is somewhat a lie. The return *can* be None if # a custom opener has been installed that fails to handle the request. def urlopen( url: Request | _string, - data: Optional[_string] = ..., - timeout: Optional[float] = ..., - cafile: Optional[_string] = ..., - capath: Optional[_string] = ..., + data: _string | None = ..., + timeout: float | None = ..., + cafile: _string | None = ..., + capath: _string | None = ..., cadefault: bool = ..., - context: Optional[ssl.SSLContext] = ..., + context: ssl.SSLContext | None = ..., ) -> addinfourl: ... def install_opener(opener: OpenerDirector) -> None: ... def build_opener(*handlers: BaseHandler | Type[BaseHandler]) -> OpenerDirector: ... @@ -102,16 +102,16 @@ class ProxyHandler(BaseHandler): class HTTPPasswordMgr: def __init__(self) -> None: ... - def add_password(self, realm: Optional[Text], uri: Text | Sequence[Text], user: Text, passwd: Text) -> None: ... - def find_user_password(self, realm: Optional[Text], authuri: Text) -> Tuple[Any, Any]: ... + def add_password(self, realm: Text | None, uri: Text | Sequence[Text], user: Text, passwd: Text) -> None: ... + def find_user_password(self, realm: Text | None, authuri: Text) -> Tuple[Any, Any]: ... def reduce_uri(self, uri: _string, default_port: bool = ...) -> Tuple[Any, Any]: ... def is_suburi(self, base: _string, test: _string) -> bool: ... class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr): ... class AbstractBasicAuthHandler: - def __init__(self, password_mgr: Optional[HTTPPasswordMgr] = ...) -> None: ... - def add_password(self, realm: Optional[Text], uri: Text | Sequence[Text], user: Text, passwd: Text) -> None: ... + def __init__(self, password_mgr: HTTPPasswordMgr | None = ...) -> None: ... + def add_password(self, realm: Text | None, uri: Text | Sequence[Text], user: Text, passwd: Text) -> None: ... def http_error_auth_reqed(self, authreq, host, req: Request, headers: Mapping[str, str]): ... def retry_http_basic_auth(self, host, req: Request, realm): ... @@ -124,15 +124,15 @@ class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler): def http_error_407(self, req: Request, fp: addinfourl, code: int, msg: str, headers: Mapping[str, str]): ... class AbstractDigestAuthHandler: - def __init__(self, passwd: Optional[HTTPPasswordMgr] = ...) -> None: ... - def add_password(self, realm: Optional[Text], uri: Text | Sequence[Text], user: Text, passwd: Text) -> None: ... + def __init__(self, passwd: HTTPPasswordMgr | None = ...) -> None: ... + def add_password(self, realm: Text | None, uri: Text | Sequence[Text], user: Text, passwd: Text) -> None: ... def reset_retry_count(self) -> None: ... def http_error_auth_reqed(self, auth_header: str, host: str, req: Request, headers: Mapping[str, str]) -> None: ... - def retry_http_digest_auth(self, req: Request, auth: str) -> Optional[HTTPResponse]: ... + def retry_http_digest_auth(self, req: Request, auth: str) -> HTTPResponse | 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: str @@ -148,19 +148,19 @@ class AbstractHTTPHandler(BaseHandler): # undocumented def __init__(self, debuglevel: int = ...) -> None: ... def set_http_debuglevel(self, level: int) -> None: ... def do_request_(self, request: Request) -> Request: ... - def do_open(self, http_class: HTTPConnectionProtocol, req: Request, **http_conn_args: Optional[Any]) -> addinfourl: ... + def do_open(self, http_class: HTTPConnectionProtocol, req: Request, **http_conn_args: Any | None) -> addinfourl: ... class HTTPHandler(AbstractHTTPHandler): def http_open(self, req: Request) -> addinfourl: ... def http_request(self, request: Request) -> Request: ... # undocumented class HTTPSHandler(AbstractHTTPHandler): - def __init__(self, debuglevel: int = ..., context: Optional[ssl.SSLContext] = ...) -> None: ... + def __init__(self, debuglevel: int = ..., context: ssl.SSLContext | None = ...) -> None: ... def https_open(self, req: Request) -> addinfourl: ... def https_request(self, request: Request) -> Request: ... # undocumented class HTTPCookieProcessor(BaseHandler): - def __init__(self, cookiejar: Optional[Any] = ...): ... + def __init__(self, cookiejar: Any | None = ...): ... def http_request(self, request: Request): ... def http_response(self, request: Request, response): ... @@ -178,7 +178,7 @@ class FTPHandler(BaseHandler): class CacheFTPHandler(FTPHandler): def __init__(self) -> None: ... - def setTimeout(self, t: Optional[float]): ... + def setTimeout(self, t: float | None): ... def setMaxConns(self, m: int): ... def check_cache(self): ... def clear_cache(self): ... diff --git a/stdlib/@python2/urlparse.pyi b/stdlib/@python2/urlparse.pyi index 9cd32b3f38fe..17f79e17183b 100644 --- a/stdlib/@python2/urlparse.pyi +++ b/stdlib/@python2/urlparse.pyi @@ -15,13 +15,13 @@ def clear_cache() -> None: ... class ResultMixin(object): @property - def username(self) -> Optional[str]: ... + def username(self) -> str | None: ... @property - def password(self) -> Optional[str]: ... + def password(self) -> str | None: ... @property - def hostname(self) -> Optional[str]: ... + def hostname(self) -> str | None: ... @property - def port(self) -> Optional[int]: ... + def port(self) -> int | None: ... class _SplitResult(NamedTuple): scheme: str diff --git a/stdlib/@python2/uu.pyi b/stdlib/@python2/uu.pyi index 5a04f9881700..06c6e0a9943f 100644 --- a/stdlib/@python2/uu.pyi +++ b/stdlib/@python2/uu.pyi @@ -4,5 +4,5 @@ _File = Text | BinaryIO class Error(Exception): ... -def encode(in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ...) -> None: ... -def decode(in_file: _File, out_file: Optional[_File] = ..., mode: Optional[int] = ..., quiet: int = ...) -> None: ... +def encode(in_file: _File, out_file: _File, name: str | None = ..., mode: int | None = ...) -> None: ... +def decode(in_file: _File, out_file: _File | None = ..., mode: int | None = ..., quiet: int = ...) -> None: ... diff --git a/stdlib/@python2/uuid.pyi b/stdlib/@python2/uuid.pyi index 791268a18475..91477e4266f3 100644 --- a/stdlib/@python2/uuid.pyi +++ b/stdlib/@python2/uuid.pyi @@ -8,12 +8,12 @@ _FieldsType = Tuple[int, int, int, int, int, int] class UUID: def __init__( self, - hex: Optional[Text] = ..., - bytes: Optional[_Bytes] = ..., - bytes_le: Optional[_Bytes] = ..., - fields: Optional[_FieldsType] = ..., - int: Optional[_Int] = ..., - version: Optional[_Int] = ..., + hex: Text | None = ..., + bytes: _Bytes | None = ..., + bytes_le: _Bytes | None = ..., + fields: _FieldsType | None = ..., + int: _Int | None = ..., + version: _Int | None = ..., ) -> None: ... @property def bytes(self) -> _Bytes: ... @@ -46,7 +46,7 @@ class UUID: @property def variant(self) -> str: ... @property - def version(self) -> Optional[_Int]: ... + def version(self) -> _Int | None: ... def __int__(self) -> _Int: ... def get_bytes(self) -> _Bytes: ... def get_bytes_le(self) -> _Bytes: ... @@ -62,11 +62,11 @@ class UUID: def get_time_mid(self) -> _Int: ... def get_urn(self) -> str: ... def get_variant(self) -> str: ... - def get_version(self) -> Optional[_Int]: ... + def get_version(self) -> _Int | None: ... def __cmp__(self, other: Any) -> _Int: ... 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/@python2/warnings.pyi b/stdlib/@python2/warnings.pyi index 3e65a337eca2..3bc6b87e9108 100644 --- a/stdlib/@python2/warnings.pyi +++ b/stdlib/@python2/warnings.pyi @@ -9,11 +9,11 @@ def showwarning( category: Type[Warning], filename: str, lineno: int, - file: Optional[TextIO] = ..., - line: Optional[str] = ..., + file: TextIO | None = ..., + line: str | None = ..., ) -> None: ... def formatwarning( - message: 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 = ... @@ -28,28 +28,28 @@ class WarningMessage: category: Type[Warning] filename: str lineno: int - file: Optional[TextIO] - line: Optional[str] + file: TextIO | None + line: str | None def __init__( self, message: Warning | str, category: Type[Warning], filename: str, lineno: int, - file: Optional[TextIO] = ..., - line: Optional[str] = ..., + file: TextIO | None = ..., + line: str | 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 __new__(cls, *, record: bool, module: ModuleType | None = ...) -> catch_warnings: ... def __enter__(self) -> Optional[List[WarningMessage]]: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... class _catch_warnings_without_records(catch_warnings): diff --git a/stdlib/@python2/wave.pyi b/stdlib/@python2/wave.pyi index cfcdf97e8b90..1660458012db 100644 --- a/stdlib/@python2/wave.pyi +++ b/stdlib/@python2/wave.pyi @@ -10,7 +10,7 @@ _wave_params = Tuple[int, int, int, int, str, str] class Wave_read: def __init__(self, f: _File) -> None: ... - def getfp(self) -> Optional[BinaryIO]: ... + def getfp(self) -> BinaryIO | None: ... def rewind(self) -> None: ... def close(self) -> None: ... def tell(self) -> int: ... @@ -51,6 +51,6 @@ 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: ... openfp = open diff --git a/stdlib/@python2/webbrowser.pyi b/stdlib/@python2/webbrowser.pyi index d0dd0d8d7912..2095d9200c29 100644 --- a/stdlib/@python2/webbrowser.pyi +++ b/stdlib/@python2/webbrowser.pyi @@ -4,9 +4,9 @@ from typing import Callable, List, Optional, Sequence, Text, Union class Error(Exception): ... def register( - name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., update_tryorder: int = ... + name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: BaseBrowser | None = ..., update_tryorder: int = ... ) -> None: ... -def get(using: Optional[Text] = ...) -> BaseBrowser: ... +def get(using: Text | None = ...) -> BaseBrowser: ... def open(url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... def open_new(url: Text) -> bool: ... def open_new_tab(url: Text) -> bool: ... diff --git a/stdlib/@python2/whichdb.pyi b/stdlib/@python2/whichdb.pyi index 67542096d712..19720c6a5b3a 100644 --- a/stdlib/@python2/whichdb.pyi +++ b/stdlib/@python2/whichdb.pyi @@ -1,3 +1,3 @@ from typing import Optional, Text -def whichdb(filename: Text) -> Optional[str]: ... +def whichdb(filename: Text) -> str | None: ... diff --git a/stdlib/@python2/winsound.pyi b/stdlib/@python2/winsound.pyi index d6e72ac78d44..91ec0b717157 100644 --- a/stdlib/@python2/winsound.pyi +++ b/stdlib/@python2/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[str | bytes], flags: int) -> None: ... + def PlaySound(sound: str | bytes | None, flags: int) -> None: ... def MessageBeep(type: int = ...) -> None: ... diff --git a/stdlib/@python2/wsgiref/handlers.pyi b/stdlib/@python2/wsgiref/handlers.pyi index e8d32bea3f7b..580764a160c0 100644 --- a/stdlib/@python2/wsgiref/handlers.pyi +++ b/stdlib/@python2/wsgiref/handlers.pyi @@ -6,9 +6,9 @@ from .headers import Headers from .types import ErrorStream, InputStream, StartResponse, WSGIApplication, WSGIEnvironment from .util import FileWrapper -_exc_info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_exc_info = Tuple[Optional[Type[BaseException]], BaseException | None, TracebackType | None] -def format_date_time(timestamp: Optional[float]) -> str: ... # undocumented +def format_date_time(timestamp: float | None) -> str: ... # undocumented class BaseHandler: wsgi_version: Tuple[int, int] # undocumented @@ -18,14 +18,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]] headers_class: Type[Headers] # undocumented - traceback_limit: Optional[int] + traceback_limit: int | None error_status: str error_headers: List[Tuple[Text, Text]] error_body: bytes @@ -36,7 +36,7 @@ class BaseHandler: def set_content_length(self) -> None: ... def cleanup_headers(self) -> None: ... def start_response( - self, status: Text, headers: List[Tuple[Text, Text]], exc_info: Optional[_exc_info] = ... + self, status: Text, headers: List[Tuple[Text, Text]], exc_info: _exc_info | None = ... ) -> Callable[[bytes], None]: ... def send_preamble(self) -> None: ... def write(self, data: bytes) -> None: ... diff --git a/stdlib/@python2/wsgiref/headers.pyi b/stdlib/@python2/wsgiref/headers.pyi index b1c0d4f56fe6..f9382c4c4e2d 100644 --- a/stdlib/@python2/wsgiref/headers.pyi +++ b/stdlib/@python2/wsgiref/headers.pyi @@ -9,16 +9,16 @@ class Headers: 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 has_key(self, name: str) -> bool: ... 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 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/@python2/wsgiref/simple_server.pyi b/stdlib/@python2/wsgiref/simple_server.pyi index 7e18442f6055..3eb240042bb8 100644 --- a/stdlib/@python2/wsgiref/simple_server.pyi +++ b/stdlib/@python2/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/@python2/wsgiref/util.pyi b/stdlib/@python2/wsgiref/util.pyi index e1179ebab365..aa2e8dbb3c51 100644 --- a/stdlib/@python2/wsgiref/util.pyi +++ b/stdlib/@python2/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/@python2/wsgiref/validate.pyi b/stdlib/@python2/wsgiref/validate.pyi index 5918374d5fd8..1d2c4b2869a5 100644 --- a/stdlib/@python2/wsgiref/validate.pyi +++ b/stdlib/@python2/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/@python2/xml/dom/domreg.pyi b/stdlib/@python2/xml/dom/domreg.pyi index bf63ff09e106..2bd58e5e3d2a 100644 --- a/stdlib/@python2/xml/dom/domreg.pyi +++ b/stdlib/@python2/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: Union[str, Iterable[Tuple[str, str | None]]] = ... ) -> DOMImplementation: ... diff --git a/stdlib/@python2/xml/dom/minicompat.pyi b/stdlib/@python2/xml/dom/minicompat.pyi index aa8efd03b19f..3dcfe095ea93 100644 --- a/stdlib/@python2/xml/dom/minicompat.pyi +++ b/stdlib/@python2/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/@python2/xml/dom/minidom.pyi b/stdlib/@python2/xml/dom/minidom.pyi index 599fcb763c50..91881f587336 100644 --- a/stdlib/@python2/xml/dom/minidom.pyi +++ b/stdlib/@python2/xml/dom/minidom.pyi @@ -5,19 +5,19 @@ from xml.sax.xmlreader import XMLReader _T = TypeVar("_T") -def parse(file: str | IO[Any], parser: Optional[XMLReader] = ..., bufsize: Optional[int] = ...): ... -def parseString(string: bytes | _Text, parser: Optional[XMLReader] = ...): ... +def parse(file: str | IO[Any], parser: XMLReader | None = ..., bufsize: int | None = ...): ... +def parseString(string: bytes | _Text, 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 - 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): ... @@ -50,14 +50,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: ... @@ -70,7 +70,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: ... @@ -101,11 +101,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): ... @@ -289,6 +289,6 @@ class Document(Node, DocumentLS): def isSupported(self, feature, version): ... def importNode(self, node, deep): ... 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/@python2/xml/etree/ElementInclude.pyi b/stdlib/@python2/xml/etree/ElementInclude.pyi index 43ac953ba00b..878355842492 100644 --- a/stdlib/@python2/xml/etree/ElementInclude.pyi +++ b/stdlib/@python2/xml/etree/ElementInclude.pyi @@ -7,7 +7,7 @@ XINCLUDE_FALLBACK: str class FatalIncludeError(SyntaxError): ... -def default_loader(href: str | bytes | int, parse: str, encoding: Optional[str] = ...) -> 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 diff --git a/stdlib/@python2/xml/etree/ElementPath.pyi b/stdlib/@python2/xml/etree/ElementPath.pyi index 6e0674cb6e55..f73c4afb6a14 100644 --- a/stdlib/@python2/xml/etree/ElementPath.pyi +++ b/stdlib/@python2/xml/etree/ElementPath.pyi @@ -26,8 +26,8 @@ class _SelectorContext: _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 find(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) -> Element | None: ... def findall(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) -> List[Element]: ... def findtext( - elem: Element, path: str, default: Optional[_T] = ..., namespaces: Optional[Dict[str, str]] = ... + elem: Element, path: str, default: _T | None = ..., namespaces: Optional[Dict[str, str]] = ... ) -> _T | str: ... diff --git a/stdlib/@python2/xml/etree/ElementTree.pyi b/stdlib/@python2/xml/etree/ElementTree.pyi index e8eb622e0e22..e9c7dfb3e1b0 100644 --- a/stdlib/@python2/xml/etree/ElementTree.pyi +++ b/stdlib/@python2/xml/etree/ElementTree.pyi @@ -55,8 +55,8 @@ _file_or_filename = Text | FileDescriptor | IO[Any] class Element(MutableSequence[Element]): tag: _str_result_type attrib: Dict[_str_result_type, _str_result_type] - text: Optional[_str_result_type] - tail: Optional[_str_result_type] + text: _str_result_type | None + tail: _str_result_type | None def __init__( self, tag: _str_argument_type | Callable[..., Element], @@ -68,7 +68,7 @@ class Element(MutableSequence[Element]): def extend(self, __elements: Iterable[Element]) -> None: ... def find( self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... - ) -> Optional[Element]: ... + ) -> Element | None: ... def findall( self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... ) -> List[Element]: ... @@ -78,18 +78,18 @@ class Element(MutableSequence[Element]): path: _str_argument_type, default: None = ..., namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ..., - ) -> Optional[_str_result_type]: ... + ) -> _str_result_type | None: ... @overload def findtext( self, path: _str_argument_type, default: _T, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... ) -> _T | _str_result_type: ... @overload - def get(self, key: _str_argument_type, default: None = ...) -> Optional[_str_result_type]: ... + def get(self, key: _str_argument_type, default: None = ...) -> _str_result_type | None: ... @overload def get(self, key: _str_argument_type, default: _T) -> _str_result_type | _T: ... def insert(self, __index: int, __element: Element) -> None: ... def items(self) -> ItemsView[_str_result_type, _str_result_type]: ... - def iter(self, tag: Optional[_str_argument_type] = ...) -> Generator[Element, None, None]: ... + def iter(self, tag: _str_argument_type | None = ...) -> Generator[Element, None, None]: ... def iterfind( self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... ) -> Generator[Element, None, None]: ... @@ -109,7 +109,7 @@ class Element(MutableSequence[Element]): @overload def __setitem__(self, s: slice, o: Iterable[Element]) -> None: ... def getchildren(self) -> List[Element]: ... - def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ... + def getiterator(self, tag: _str_argument_type | None = ...) -> List[Element]: ... def SubElement( parent: Element, @@ -117,31 +117,31 @@ def SubElement( attrib: Dict[_str_argument_type, _str_argument_type] = ..., **extra: _str_argument_type, ) -> Element: ... -def Comment(text: Optional[_str_argument_type] = ...) -> Element: ... -def ProcessingInstruction(target: _str_argument_type, text: Optional[_str_argument_type] = ...) -> Element: ... +def Comment(text: _str_argument_type | None = ...) -> Element: ... +def ProcessingInstruction(target: _str_argument_type, text: _str_argument_type | None = ...) -> Element: ... PI: Callable[..., Element] class QName: text: str - def __init__(self, text_or_uri: _str_argument_type, tag: Optional[_str_argument_type] = ...) -> None: ... + def __init__(self, text_or_uri: _str_argument_type, tag: _str_argument_type | None = ...) -> None: ... class ElementTree: - def __init__(self, element: Optional[Element] = ..., file: Optional[_file_or_filename] = ...) -> None: ... + def __init__(self, element: Element | None = ..., file: _file_or_filename | None = ...) -> None: ... def getroot(self) -> Element: ... - def parse(self, source: _file_or_filename, parser: Optional[XMLParser] = ...) -> Element: ... - def iter(self, tag: Optional[_str_argument_type] = ...) -> Generator[Element, None, None]: ... - def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ... + def parse(self, source: _file_or_filename, parser: XMLParser | None = ...) -> Element: ... + def iter(self, tag: _str_argument_type | None = ...) -> Generator[Element, None, None]: ... + def getiterator(self, tag: _str_argument_type | None = ...) -> List[Element]: ... def find( self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... - ) -> Optional[Element]: ... + ) -> Element | None: ... @overload def findtext( self, path: _str_argument_type, default: None = ..., namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ..., - ) -> Optional[_str_result_type]: ... + ) -> _str_result_type | None: ... @overload def findtext( self, path: _str_argument_type, default: _T, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... @@ -155,28 +155,28 @@ class ElementTree: def write( self, file_or_filename: _file_or_filename, - encoding: Optional[str] = ..., - xml_declaration: Optional[bool] = ..., - default_namespace: Optional[_str_argument_type] = ..., - method: Optional[str] = ..., + encoding: str | None = ..., + xml_declaration: bool | None = ..., + default_namespace: _str_argument_type | None = ..., + method: str | None = ..., ) -> None: ... def write_c14n(self, file: _file_or_filename) -> None: ... def register_namespace(prefix: _str_argument_type, uri: _str_argument_type) -> None: ... -def tostring(element: Element, encoding: Optional[str] = ..., method: Optional[str] = ...) -> bytes: ... -def tostringlist(element: Element, encoding: Optional[str] = ..., method: Optional[str] = ...) -> List[bytes]: ... +def tostring(element: Element, encoding: str | None = ..., method: str | None = ...) -> bytes: ... +def tostringlist(element: Element, encoding: str | None = ..., method: str | None = ...) -> List[bytes]: ... def dump(elem: Element) -> None: ... -def parse(source: _file_or_filename, parser: Optional[XMLParser] = ...) -> ElementTree: ... +def parse(source: _file_or_filename, parser: XMLParser | None = ...) -> ElementTree: ... def iterparse( - source: _file_or_filename, events: Optional[Sequence[str]] = ..., parser: Optional[XMLParser] = ... + source: _file_or_filename, events: Optional[Sequence[str]] = ..., parser: XMLParser | None = ... ) -> Iterator[Tuple[str, Any]]: ... -def XML(text: _parser_input_type, parser: Optional[XMLParser] = ...) -> Element: ... -def XMLID(text: _parser_input_type, parser: Optional[XMLParser] = ...) -> Tuple[Element, Dict[_str_result_type, Element]]: ... +def XML(text: _parser_input_type, parser: XMLParser | None = ...) -> Element: ... +def XMLID(text: _parser_input_type, parser: XMLParser | None = ...) -> Tuple[Element, Dict[_str_result_type, Element]]: ... # This is aliased to XML in the source. fromstring = XML -def fromstringlist(sequence: Sequence[_parser_input_type], parser: Optional[XMLParser] = ...) -> Element: ... +def fromstringlist(sequence: Sequence[_parser_input_type], 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 @@ -190,7 +190,7 @@ def fromstringlist(sequence: Sequence[_parser_input_type], parser: Optional[XMLP _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: _parser_input_type) -> None: ... def start(self, __tag: _parser_input_type, __attrs: Dict[_parser_input_type, _parser_input_type]) -> Element: ... @@ -202,7 +202,7 @@ class XMLParser: # TODO-what is entity used for??? entity: Any version: str - 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: _parser_input_type) -> None: ... diff --git a/stdlib/@python2/xml/sax/__init__.pyi b/stdlib/@python2/xml/sax/__init__.pyi index f450d7fe73c0..c5284f0c9054 100644 --- a/stdlib/@python2/xml/sax/__init__.pyi +++ b/stdlib/@python2/xml/sax/__init__.pyi @@ -3,7 +3,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: ... @@ -23,5 +23,5 @@ default_parser_list: List[str] def make_parser(parser_list: List[str] = ...) -> XMLReader: ... def parse(source: str | IO[str] | IO[bytes], handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ... -def parseString(string: bytes | Text, handler: ContentHandler, errorHandler: Optional[ErrorHandler] = ...) -> None: ... +def parseString(string: bytes | Text, handler: ContentHandler, errorHandler: ErrorHandler | None = ...) -> None: ... def _create_parser(parser_name: str) -> XMLReader: ... diff --git a/stdlib/@python2/xml/sax/saxutils.pyi b/stdlib/@python2/xml/sax/saxutils.pyi index 3f2671eaacfe..4ddb63f61f22 100644 --- a/stdlib/@python2/xml/sax/saxutils.pyi +++ b/stdlib/@python2/xml/sax/saxutils.pyi @@ -27,7 +27,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/@python2/xml/sax/xmlreader.pyi b/stdlib/@python2/xml/sax/xmlreader.pyi index 9dd6b75fd52f..1cba860017a5 100644 --- a/stdlib/@python2/xml/sax/xmlreader.pyi +++ b/stdlib/@python2/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/@python2/xmlrpclib.pyi b/stdlib/@python2/xmlrpclib.pyi index d6b1166df4d9..e1d6c68bc47a 100644 --- a/stdlib/@python2/xmlrpclib.pyi +++ b/stdlib/@python2/xmlrpclib.pyi @@ -67,7 +67,7 @@ class DateTime: class Binary: data: str - def __init__(self, data: Optional[str] = ...) -> None: ... + def __init__(self, data: str | None = ...) -> None: ... def __cmp__(self, other: Any) -> int: ... def decode(self, data: str) -> None: ... def encode(self, out: IO[str]) -> None: ... @@ -97,10 +97,10 @@ class SlowParser: class Marshaller: memo: MutableMapping[int, Any] - data: Optional[str] - encoding: Optional[str] + data: str | None + encoding: str | None allow_none: bool - def __init__(self, encoding: Optional[str] = ..., allow_none: bool = ...) -> None: ... + def __init__(self, encoding: str | None = ..., allow_none: bool = ...) -> None: ... dispatch: Mapping[type, Callable[[Marshaller, str, Callable[[str], None]], None]] def dumps( self, @@ -155,7 +155,7 @@ class Unmarshaller: def append(self, object: Any) -> None: ... def __init__(self, use_datetime: bool = ...) -> None: ... def close(self) -> Tuple[Any, ...]: ... - def getmethodname(self) -> Optional[str]: ... + def getmethodname(self) -> str | None: ... def xml(self, encoding: str, standalone: bool) -> None: ... def start(self, tag: str, attrs: Any) -> None: ... def data(self, text: str) -> None: ... @@ -190,12 +190,12 @@ class MultiCall: def getparser(use_datetime: bool = ...) -> Tuple[ExpatParser | SlowParser, Unmarshaller]: ... def dumps( params: Tuple[Any, ...] | Fault, - methodname: Optional[str] = ..., - methodresponse: Optional[bool] = ..., - encoding: Optional[str] = ..., + methodname: str | None = ..., + methodresponse: bool | None = ..., + encoding: str | None = ..., allow_none: bool = ..., ) -> str: ... -def loads(data: str, use_datetime: bool = ...) -> Tuple[Tuple[Any, ...], Optional[str]]: ... +def loads(data: str, use_datetime: bool = ...) -> Tuple[Tuple[Any, ...], str | None]: ... def gzip_encode(data: str) -> str: ... def gzip_decode(data: str, max_decode: int = ...) -> str: ... @@ -212,7 +212,7 @@ class _Method: class Transport: user_agent: str accept_gzip_encoding: bool - encode_threshold: Optional[int] + encode_threshold: int | None def __init__(self, use_datetime: bool = ...) -> None: ... def request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> Tuple[Any, ...]: ... verbose: bool @@ -228,21 +228,21 @@ class Transport: def parse_response(self, response: HTTPResponse) -> Tuple[Any, ...]: ... class SafeTransport(Transport): - def __init__(self, use_datetime: bool = ..., context: Optional[SSLContext] = ...) -> None: ... + def __init__(self, use_datetime: bool = ..., context: SSLContext | None = ...) -> None: ... def make_connection(self, host: _hostDesc) -> HTTPSConnection: ... 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 = ..., - context: Optional[SSLContext] = ..., + context: SSLContext | None = ..., ) -> None: ... def __getattr__(self, name: str) -> _Method: ... - def __call__(self, attr: str) -> Optional[Transport]: ... + def __call__(self, attr: str) -> Transport | None: ... Server = ServerProxy diff --git a/stdlib/@python2/zipfile.pyi b/stdlib/@python2/zipfile.pyi index 19adc6c19402..9af96ada8800 100644 --- a/stdlib/@python2/zipfile.pyi +++ b/stdlib/@python2/zipfile.pyi @@ -29,17 +29,17 @@ class ZipExtFile(io.BufferedIOBase): decrypter: Optional[Callable[[Sequence[int]], bytes]] = ..., close_fileobj: bool = ..., ) -> 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) -> Any: ... class ZipFile: - filename: Optional[Text] + filename: Text | None debug: int comment: bytes filelist: List[ZipInfo] @@ -51,23 +51,23 @@ class ZipFile: ) -> None: ... def __enter__(self) -> ZipFile: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def close(self) -> None: ... def getinfo(self, name: Text) -> ZipInfo: ... def infolist(self) -> List[ZipInfo]: ... def namelist(self) -> List[Text]: ... - def open(self, name: _SZI, mode: Text = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... - def extract(self, member: _SZI, path: Optional[StrPath] = ..., pwd: Optional[bytes] = ...) -> str: ... + def open(self, name: _SZI, mode: Text = ..., pwd: bytes | None = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... + def extract(self, member: _SZI, path: StrPath | None = ..., pwd: bytes | None = ...) -> str: ... def extractall( - self, path: Optional[StrPath] = ..., members: Optional[Iterable[Text]] = ..., pwd: Optional[bytes] = ... + self, path: StrPath | None = ..., members: Optional[Iterable[Text]] = ..., pwd: bytes | None = ... ) -> None: ... def printdir(self) -> None: ... def setpassword(self, pwd: bytes) -> None: ... - def read(self, name: _SZI, pwd: Optional[bytes] = ...) -> bytes: ... - def testzip(self) -> Optional[str]: ... - def write(self, filename: StrPath, arcname: Optional[StrPath] = ..., compress_type: Optional[int] = ...) -> None: ... - def writestr(self, zinfo_or_arcname: _SZI, bytes: bytes, compress_type: Optional[int] = ...) -> None: ... + def read(self, name: _SZI, pwd: bytes | None = ...) -> bytes: ... + def testzip(self) -> str | None: ... + def write(self, filename: StrPath, arcname: StrPath | None = ..., compress_type: int | None = ...) -> None: ... + def writestr(self, zinfo_or_arcname: _SZI, bytes: bytes, compress_type: int | None = ...) -> None: ... class PyZipFile(ZipFile): def writepy(self, pathname: Text, basename: Text = ...) -> None: ... @@ -90,11 +90,11 @@ class ZipInfo: CRC: int compress_size: int file_size: int - def __init__(self, filename: Optional[Text] = ..., date_time: Optional[_DT] = ...) -> None: ... - def FileHeader(self, zip64: Optional[bool] = ...) -> bytes: ... + def __init__(self, filename: Text | None = ..., date_time: _DT | None = ...) -> None: ... + 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]: ... def is_zipfile(filename: StrPath | IO[bytes]) -> bool: ... diff --git a/stdlib/@python2/zipimport.pyi b/stdlib/@python2/zipimport.pyi index 61529f6d21c2..10c3b07d97a3 100644 --- a/stdlib/@python2/zipimport.pyi +++ b/stdlib/@python2/zipimport.pyi @@ -7,10 +7,10 @@ class zipimporter(object): archive: str prefix: str def __init__(self, path: str | bytes) -> None: ... - def find_module(self, fullname: str, path: Optional[str] = ...) -> Optional[zipimporter]: ... + 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: ... - def get_source(self, fullname: str) -> Optional[str]: ... + 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/_ast.pyi b/stdlib/_ast.pyi index 2d0d92d83032..eb6dfa061539 100644 --- a/stdlib/_ast.pyi +++ b/stdlib/_ast.pyi @@ -17,9 +17,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): ... @@ -49,14 +49,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 @@ -66,7 +66,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] @@ -83,7 +83,7 @@ class AugAssign(stmt): class AnnAssign(stmt): target: expr annotation: expr - value: Optional[expr] + value: expr | None simple: int class For(stmt): @@ -117,8 +117,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] @@ -128,13 +128,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 @@ -175,7 +175,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): @@ -202,7 +202,7 @@ class Await(expr): value: expr class Yield(expr): - value: Optional[expr] + value: expr | None class YieldFrom(expr): value: expr @@ -219,8 +219,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] @@ -238,7 +238,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 @@ -260,9 +260,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): @@ -346,35 +346,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): @@ -385,27 +385,27 @@ 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 class MatchSingleton(pattern): - value: Optional[bool] + value: bool | None 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..cae60c8fed46 100644 --- a/stdlib/_bisect.pyi +++ b/stdlib/_bisect.pyi @@ -6,16 +6,16 @@ _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: Optional[Callable[[_T], SupportsLessThan]] = ... ) -> 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: Optional[Callable[[_T], SupportsLessThan]] = ... ) -> int: ... def insort_left( a: MutableSequence[_T], x: _T, lo: int = ..., - hi: Optional[int] = ..., + hi: int | None = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ..., ) -> None: ... @@ -23,13 +23,13 @@ if sys.version_info >= (3, 10): a: MutableSequence[_T], x: _T, lo: int = ..., - hi: Optional[int] = ..., + hi: int | None = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ..., ) -> 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 49d2e140cfb9..1fb3e5fb6add 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: 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: 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: str | bytes, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... -def unicode_escape_decode(__data: 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: str | bytes, __errors: Optional[str] = ...) -> Tuple[str, int]: ... - def unicode_internal_encode(__obj: 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/_csv.pyi b/stdlib/_csv.pyi index 475db75ffd7c..0bd901c2e912 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 7c54e2de56ab..6db5a5d35faf 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: ... 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 5d59eecc64e0..f5770df80dde 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] = ..., + name: str | None = ..., args: Iterable[Any] = ..., kwargs: Optional[Mapping[str, Any]] = ..., *, - 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: Optional[Type[BaseException]], 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,8 +77,8 @@ 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: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... @@ -88,12 +88,12 @@ class Condition: 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: Optional[Type[BaseException]], 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: Optional[Type[BaseException]], 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 @@ -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: Optional[Callable[[], 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..ca4e081eefe5 100644 --- a/stdlib/_json.pyi +++ b/stdlib/_json.pyi @@ -14,7 +14,7 @@ class make_encoder: markers: Optional[Dict[int, Any]], 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 a026d4259c1e..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,7 +15,7 @@ if sys.platform == "win32": __init__: None # type: ignore # Actual typename Summary, not exposed by the implementation class _Summary: - def GetProperty(self, propid: int) -> Optional[str | bytes]: ... + def GetProperty(self, propid: int) -> str | bytes | None: ... def GetPropertyCount(self) -> int: ... def SetProperty(self, propid: int, value: str | bytes) -> None: ... def Persist(self) -> None: ... diff --git a/stdlib/_osx_support.pyi b/stdlib/_osx_support.pyi index 90d7015bb16e..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 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 f7f727b13e0d..9483413bdbf5 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: ... @@ -614,7 +614,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..7ea76f25bb7c 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: Optional[Type[BaseException]], 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/_typeshed/tkinter.pyi b/stdlib/_typeshed/tkinter.pyi index 2fe0c4255e03..e43ae2243748 100644 --- a/stdlib/_typeshed/tkinter.pyi +++ b/stdlib/_typeshed/tkinter.pyi @@ -4,4 +4,4 @@ from tkinter import Event, Misc, Widget from typing import 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: Optional[Event[Misc]]) -> None: ... 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..0712786e5639 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: Optional[Type[Warning]] = ..., 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] = ..., + module: str | None = ..., registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., module_globals: Optional[Dict[str, Any]] = ..., - source: Optional[Any] = ..., + source: Any | None = ..., ) -> None: ... @overload def warn_explicit( @@ -25,8 +25,8 @@ def warn_explicit( category: Any, filename: str, lineno: int, - module: Optional[str] = ..., + module: str | None = ..., registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., module_globals: Optional[Dict[str, Any]] = ..., - source: Optional[Any] = ..., + source: Any | None = ..., ) -> None: ... diff --git a/stdlib/_weakref.pyi b/stdlib/_weakref.pyi index 01974c522369..9ad22ed61dd1 100644 --- a/stdlib/_weakref.pyi +++ b/stdlib/_weakref.pyi @@ -16,7 +16,7 @@ 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 __call__(self) -> _T | None: ... def __hash__(self) -> int: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... diff --git a/stdlib/_winapi.pyi b/stdlib/_winapi.pyi index b573870fa0ae..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( @@ -114,7 +114,7 @@ def ReadFile(handle: int, size: int, overlapped: Literal[False] = ...) -> Tuple[ @overload 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: ... @@ -131,4 +131,4 @@ 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 d3327526a0ae..e97f2654d29d 100644 --- a/stdlib/aifc.pyi +++ b/stdlib/aifc.pyi @@ -20,7 +20,7 @@ class Aifc_read: def __init__(self, f: _File) -> None: ... def __enter__(self) -> Aifc_read: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def initfp(self, file: IO[bytes]) -> None: ... def getfp(self) -> IO[bytes]: ... @@ -44,7 +44,7 @@ class Aifc_write: def __del__(self) -> None: ... def __enter__(self) -> Aifc_write: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def initfp(self, file: IO[bytes]) -> None: ... def aiff(self) -> None: ... @@ -75,7 +75,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 @@ -83,4 +83,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 27e8c97ba7f8..e1de7d37093b 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: ... @@ -71,9 +71,9 @@ class _ActionsContainer: type: Union[Callable[[str], _T], Callable[[str], _T], FileType] = ..., choices: Iterable[_T] = ..., required: bool = ..., - help: Optional[str] = ..., + help: str | None = ..., metavar: Optional[str | Tuple[str, ...]] = ..., - dest: Optional[str] = ..., + dest: str | None = ..., version: str = ..., **kwargs: Any, ) -> Action: ... @@ -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 = ..., @@ -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 format_usage(self) -> str: ... def format_help(self) -> str: ... def parse_known_args( - self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ... + self, args: Optional[Sequence[str]] = ..., 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: Optional[Sequence[str]] = ..., namespace: Namespace | None = ... ) -> Namespace: ... def parse_known_intermixed_args( - self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ... + self, args: Optional[Sequence[str]] = ..., namespace: Namespace | None = ... ) -> Tuple[Namespace, List[str]]: ... # undocumented def _get_optional_actions(self) -> List[Action]: ... @@ -205,8 +205,8 @@ 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) -> Optional[Tuple[Action | None, str, str | 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: ... @@ -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,25 +269,25 @@ class MetavarTypeHelpFormatter(HelpFormatter): ... class Action(_AttributeHolder): option_strings: Sequence[str] dest: str - nargs: Optional[int | str] + nargs: int | str | None const: Any default: Any type: Union[Callable[[str], Any], FileType, None] choices: Optional[Iterable[Any]] required: bool - help: Optional[str] + help: str | None metavar: Optional[str | Tuple[str, ...]] def __init__( self, option_strings: Sequence[str], dest: str, - nargs: Optional[int | str] = ..., - const: Optional[_T] = ..., + nargs: int | str | None = ..., + const: _T | None = ..., default: _T | str | None = ..., type: Optional[Union[Callable[[str], _T], Callable[[str], _T], FileType]] = ..., choices: Optional[Iterable[_T]] = ..., required: bool = ..., - help: Optional[str] = ..., + help: str | None = ..., metavar: Optional[str | Tuple[str, ...]] = ..., ) -> None: ... def __call__( @@ -295,7 +295,7 @@ class Action(_AttributeHolder): parser: ArgumentParser, namespace: Namespace, values: str | Sequence[Any] | None, - option_string: Optional[str] = ..., + option_string: str | None = ..., ) -> None: ... if sys.version_info >= (3, 9): def format_usage(self) -> str: ... @@ -310,7 +310,7 @@ if sys.version_info >= (3, 9): type: Optional[Union[Callable[[str], _T], Callable[[str], _T], FileType]] = ..., choices: Optional[Iterable[_T]] = ..., required: bool = ..., - help: Optional[str] = ..., + help: str | None = ..., metavar: Optional[str | Tuple[str, ...]] = ..., ) -> None: ... @@ -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] = ..., + help: str | None = ..., metavar: Optional[str | Tuple[str, ...]] = ..., ) -> 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] = ..., + help: str | None = ..., metavar: Optional[str | Tuple[str, ...]] = ..., ) -> 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,7 +422,7 @@ class _SubParsersAction(Action): parser_class: Type[ArgumentParser], dest: str = ..., required: bool = ..., - help: Optional[str] = ..., + help: str | None = ..., metavar: Optional[str | Tuple[str, ...]] = ..., ) -> None: ... else: @@ -432,7 +432,7 @@ class _SubParsersAction(Action): prog: str, parser_class: Type[ArgumentParser], dest: str = ..., - help: Optional[str] = ..., + help: str | None = ..., metavar: Optional[str | Tuple[str, ...]] = ..., ) -> None: ... # TODO: Type keyword args properly. @@ -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/ast.pyi b/stdlib/ast.pyi index d0f108ba3ef0..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) @@ -195,13 +195,13 @@ 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: 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 7cb08c363b30..4fabf46f4ed6 100644 --- a/stdlib/asynchat.pyi +++ b/stdlib/asynchat.pyi @@ -10,7 +10,7 @@ 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 diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index 58e4357f7b43..344ee3acda01 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: ... @@ -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: ... @@ -83,7 +83,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): def get_task_factory(self) -> Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]: ... # 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,7 +91,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): # Network I/O methods returning Futures. async def getaddrinfo( self, - host: Optional[str], + host: str | None, port: str | int | None, *, family: int = ..., @@ -116,10 +116,10 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): 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] = ..., + 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 @@ -153,8 +153,8 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): flags: int = ..., sock: None = ..., local_addr: Optional[Tuple[str, int]] = ..., - server_hostname: Optional[str] = ..., - ssl_handshake_timeout: Optional[float] = ..., + 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 @@ -186,7 +186,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): flags: int = ..., sock: None = ..., local_addr: Optional[Tuple[str, int]] = ..., - server_hostname: Optional[str] = ..., + server_hostname: str | None = ..., ) -> _TransProtPair: ... @overload async def create_connection( @@ -201,11 +201,11 @@ 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( @@ -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,8 +265,8 @@ 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 @@ -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 = ... @@ -311,10 +311,10 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): 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: ... @@ -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 bc834cd94cce..ac33850d0f38 100644 --- a/stdlib/asyncio/base_subprocess.pyi +++ b/stdlib/asyncio/base_subprocess.pyi @@ -11,8 +11,8 @@ class BaseSubprocessTransport(transports.SubprocessTransport): _protocol: protocols.SubprocessProtocol # undocumented _loop: events.AbstractEventLoop # undocumented _proc: Optional[subprocess.Popen[Any]] # undocumented - _pid: Optional[int] # undocumented - _returncode: Optional[int] # 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 @@ -28,7 +28,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport): stderr: _File, bufsize: int, waiter: Optional[futures.Future[Any]] = ..., - extra: Optional[Any] = ..., + extra: Any | None = ..., **kwargs: Any, ) -> None: ... def _start( @@ -45,8 +45,8 @@ 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 @@ -54,17 +54,17 @@ class BaseSubprocessTransport(transports.SubprocessTransport): def kill(self) -> None: ... async def _connect_pipes(self, waiter: Optional[futures.Future[Any]]) -> 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 8db74edc57f8..87d80cd34edf 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -26,7 +26,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: ... @@ -44,7 +44,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: ... @@ -99,7 +99,7 @@ class AbstractEventLoop(metaclass=ABCMeta): # Tasks methods if sys.version_info >= (3, 8): @abstractmethod - def create_task(self, coro: 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: Awaitable[_T] | Generator[Any, None, _T]) -> Task[_T]: ... @@ -120,7 +120,7 @@ class AbstractEventLoop(metaclass=ABCMeta): @abstractmethod async def getaddrinfo( self, - host: Optional[str], + host: str | None, port: str | int | None, *, family: int = ..., @@ -147,10 +147,10 @@ class AbstractEventLoop(metaclass=ABCMeta): 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] = ..., + server_hostname: str | None = ..., + ssl_handshake_timeout: float | None = ..., + happy_eyeballs_delay: float | None = ..., + interleave: int | None = ..., ) -> _TransProtPair: ... @overload @abstractmethod @@ -166,10 +166,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 @@ -186,8 +186,8 @@ class AbstractEventLoop(metaclass=ABCMeta): flags: int = ..., sock: None = ..., local_addr: Optional[Tuple[str, int]] = ..., - server_hostname: Optional[str] = ..., - ssl_handshake_timeout: Optional[float] = ..., + server_hostname: str | None = ..., + ssl_handshake_timeout: float | None = ..., ) -> _TransProtPair: ... @overload @abstractmethod @@ -203,8 +203,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 @@ -221,7 +221,7 @@ class AbstractEventLoop(metaclass=ABCMeta): flags: int = ..., sock: None = ..., local_addr: Optional[Tuple[str, int]] = ..., - server_hostname: Optional[str] = ..., + server_hostname: str | None = ..., ) -> _TransProtPair: ... @overload @abstractmethod @@ -237,12 +237,12 @@ 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 @@ -257,9 +257,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 = ..., ) -> AbstractServer: ... @overload @@ -275,30 +275,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 = ..., ) -> AbstractServer: ... 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 = ..., ) -> AbstractServer: ... @abstractmethod @@ -307,7 +307,7 @@ class AbstractEventLoop(metaclass=ABCMeta): transport: BaseTransport, file: IO[bytes], offset: int = ..., - count: Optional[int] = ..., + count: int | None = ..., *, fallback: bool = ..., ) -> int: ... @@ -319,8 +319,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 @@ -336,8 +336,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 = ..., ) -> AbstractServer: ... @overload @abstractmethod @@ -352,8 +352,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 = ..., ) -> AbstractServer: ... async def create_unix_connection( self, @@ -361,15 +361,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 = ..., ) -> AbstractServer: ... @@ -383,10 +383,10 @@ class AbstractEventLoop(metaclass=ABCMeta): 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 @@ -462,9 +462,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 @@ -482,7 +482,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). @@ -494,17 +494,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 2afbe5593e7b..7c5114b24806 100644 --- a/stdlib/asyncio/format_helpers.pyi +++ b/stdlib/asyncio/format_helpers.pyi @@ -17,4 +17,4 @@ if sys.version_info >= (3, 7): 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 ed9e273bb58c..a5b19cacccd9 100644 --- a/stdlib/asyncio/futures.pyi +++ b/stdlib/asyncio/futures.pyi @@ -33,25 +33,25 @@ 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: type | BaseException) -> None: ... @@ -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: _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 bfe5d75cff94..766c6fed2236 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -12,7 +12,7 @@ if sys.version_info >= (3, 9): 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: Optional[Type[BaseException]], exc: BaseException | None, tb: TracebackType | None ) -> Awaitable[None]: ... else: @@ -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: Optional[Type[BaseException]], 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..09024d8b3d61 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: Optional[Type[Warning]] = ..., stacklevel: int = ..., source: Any | None = ... ) -> None: ... class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport): @@ -19,7 +19,7 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTr protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., - server: Optional[events.AbstractServer] = ..., + server: events.AbstractServer | None = ..., ) -> None: ... def __repr__(self) -> str: ... if sys.version_info >= (3, 8): @@ -36,7 +36,7 @@ class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTran protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., - server: Optional[events.AbstractServer] = ..., + server: events.AbstractServer | None = ..., ) -> None: ... class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport): @@ -47,7 +47,7 @@ class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.Wri protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., - server: Optional[events.AbstractServer] = ..., + server: events.AbstractServer | None = ..., ) -> None: ... class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): @@ -58,7 +58,7 @@ class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., - server: Optional[events.AbstractServer] = ..., + server: events.AbstractServer | None = ..., ) -> None: ... class _ProactorDuplexPipeTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): ... @@ -73,7 +73,7 @@ class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePip protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., - server: Optional[events.AbstractServer] = ..., + 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..34b9aa343451 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,24 +18,24 @@ 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]] + _handshake_cb: Optional[Callable[[BaseException | None], None]] _shutdown_cb: Optional[Callable[[], None]] - def __init__(self, context: ssl.SSLContext, server_side: bool, server_hostname: Optional[str] = ...) -> 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 do_handshake(self, callback: Optional[Callable[[BaseException | None], None]] = ...) -> List[bytes]: ... def shutdown(self, callback: Optional[Callable[[], None]] = ...) -> List[bytes]: ... def feed_eof(self) -> None: ... def feed_ssldata(self, data: bytes, only_handshake: bool = ...) -> Tuple[List[bytes], List[bytes]]: ... @@ -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 fd47e8ac00ee..bea2fe79aff3 100644 --- a/stdlib/asyncio/streams.pyi +++ b/stdlib/asyncio/streams.pyi @@ -8,30 +8,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[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[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, ) -> events.AbstractServer: ... @@ -41,29 +41,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, ) -> events.AbstractServer: ... 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: ... @@ -72,7 +72,7 @@ class StreamWriter: self, transport: transports.BaseTransport, protocol: protocols.BaseProtocol, - reader: Optional[StreamReader], + reader: StreamReader | None, loop: events.AbstractEventLoop, ) -> None: ... @property @@ -89,7 +89,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 09b297ab1be2..24364025f612 100644 --- a/stdlib/asyncio/subprocess.pyi +++ b/stdlib/asyncio/subprocess.pyi @@ -15,30 +15,30 @@ 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: bytes | str) -> 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: ... 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( @@ -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] = ..., + executable: StrOrBytesPath | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., 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 = ..., @@ -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] = ..., + text: bool | None = ..., + executable: StrOrBytesPath | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., 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 = ..., @@ -100,7 +100,7 @@ else: stdin: int | IO[Any] | None = ..., stdout: int | IO[Any] | None = ..., stderr: int | IO[Any] | None = ..., - loop: Optional[events.AbstractEventLoop] = ..., + 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] = ..., + executable: StrOrBytesPath | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., 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 = ..., @@ -128,7 +128,7 @@ else: stdin: int | IO[Any] | None = ..., stdout: int | IO[Any] | None = ..., stderr: int | IO[Any] | None = ..., - loop: Optional[events.AbstractEventLoop] = ..., + 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] = ..., + text: bool | None = ..., + executable: StrOrBytesPath | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., 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 466ea0a67561..d5adafcfb117 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. @@ -137,14 +137,14 @@ if sys.version_info >= (3, 10): 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,19 +186,19 @@ 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 = ... + 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[_T1 | BaseException, _T2 | BaseException]]: ... @overload @@ -207,7 +207,7 @@ else: coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3], *, - loop: Optional[AbstractEventLoop] = ..., + loop: AbstractEventLoop | None = ..., return_exceptions: bool = ..., ) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... @overload @@ -217,7 +217,7 @@ else: coro_or_future3: _FutureT[_T3], coro_or_future4: _FutureT[_T4], *, - loop: Optional[AbstractEventLoop] = ..., + loop: AbstractEventLoop | None = ..., return_exceptions: bool = ..., ) -> Future[ Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException] @@ -230,7 +230,7 @@ else: coro_or_future4: _FutureT[_T4], coro_or_future5: _FutureT[_T5], *, - loop: Optional[AbstractEventLoop] = ..., + loop: AbstractEventLoop | None = ..., return_exceptions: bool = ..., ) -> Future[ Tuple[ @@ -248,27 +248,27 @@ 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): @@ -277,7 +277,7 @@ class Task(Future[_T], Generic[_T]): coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T], *, loop: AbstractEventLoop = ..., - name: Optional[str] = ..., + name: str | None = ..., ) -> None: ... else: def __init__( @@ -288,28 +288,28 @@ class Task(Future[_T], Generic[_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 = ...) -> Optional[Task[Any]]: ... @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: 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: Generator[_TaskYieldType, None, _T] | Awaitable[_T]) -> Task[_T]: ... - def current_task(loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ... + def current_task(loop: AbstractEventLoop | None = ...) -> Optional[Task[Any]]: ... diff --git a/stdlib/asyncio/transports.pyi b/stdlib/asyncio/transports.pyi index 636ac36301c1..4959046667df 100644 --- a/stdlib/asyncio/transports.pyi +++ b/stdlib/asyncio/transports.pyi @@ -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: Optional[Mapping[Any, Any]] = ..., 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 3ebf1c8fc2b5..5ed3039fb84f 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -44,7 +44,7 @@ if sys.version_info >= (3, 8): 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: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... diff --git a/stdlib/asyncio/unix_events.pyi b/stdlib/asyncio/unix_events.pyi index 855fca43469b..c0b4f23bde09 100644 --- a/stdlib/asyncio/unix_events.pyi +++ b/stdlib/asyncio/unix_events.pyi @@ -13,11 +13,11 @@ _T3 = TypeVar("_T3", bound=FastChildWatcher) 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: _T1) -> _T1: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] + self, typ: Optional[Type[BaseException]], exc: BaseException | None, tb: types.TracebackType | None ) -> None: ... if sys.version_info >= (3, 8): def is_active(self) -> bool: ... @@ -36,16 +36,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 = ..., ) -> AbstractServer: ... 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 @@ -59,7 +59,7 @@ if sys.version_info >= (3, 8): _T5 = TypeVar("_T5", bound=ThreadedChildWatcher) class _Warn(Protocol): def __call__( - self, message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ..., source: Optional[Any] = ... + self, message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ..., source: Any | None = ... ) -> None: ... class MultiLoopChildWatcher(AbstractChildWatcher): def __enter__(self: _T4) -> _T4: ... 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 e6009d58ebc7..044b3ab2e57d 100644 --- a/stdlib/asyncio/windows_utils.pyi +++ b/stdlib/asyncio/windows_utils.pyi @@ -19,7 +19,7 @@ class PipeHandle: else: def __del__(self) -> None: ... def __enter__(self) -> PipeHandle: ... - 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 fccf03c7f78a..55fbe7c6734b 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,12 +31,12 @@ 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: ... @@ -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 f01846e5db2b..0e2dda19756e 100644 --- a/stdlib/base64.pyi +++ b/stdlib/base64.pyi @@ -1,14 +1,14 @@ import sys from typing import IO, Optional, Union -def b64encode(s: bytes, altchars: Optional[bytes] = ...) -> bytes: ... -def b64decode(s: 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: str | bytes) -> bytes: ... def urlsafe_b64encode(s: bytes) -> bytes: ... def urlsafe_b64decode(s: str | bytes) -> bytes: ... def b32encode(s: bytes) -> bytes: ... -def b32decode(s: 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: str | bytes, casefold: bool = ...) -> bytes: ... diff --git a/stdlib/bdb.pyi b/stdlib/bdb.pyi index 32452fc224e6..cba5a6750ec3 100644 --- a/stdlib/bdb.pyi +++ b/stdlib/bdb.pyi @@ -14,11 +14,11 @@ class Bdb: skip: Optional[Set[str]] 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 canonic(self, filename: str) -> str: ... @@ -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,7 +56,7 @@ class Bdb: def get_breaks(self, filename: str, lineno: int) -> List[Breakpoint]: ... def get_file_breaks(self, filename: str) -> List[Breakpoint]: ... def get_all_breaks(self) -> List[Breakpoint]: ... - def get_stack(self, f: 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: str | CodeType, globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ... @@ -65,26 +65,26 @@ class Bdb: def runctx( self, cmd: str | CodeType, globals: Optional[Dict[str, Any]], locals: Optional[Mapping[str, Any]] ) -> 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: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index a2202796eb1e..88365dfec740 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -82,7 +82,7 @@ _TT = TypeVar("_TT", bound="type") _TBE = TypeVar("_TBE", bound="BaseException") class object: - __doc__: Optional[str] + __doc__: str | None __dict__: Dict[str, Any] __slots__: str | Iterable[str] __module__: str @@ -135,7 +135,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: ... @@ -205,10 +205,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: ... @@ -225,7 +225,7 @@ class int: def __trunc__(self) -> int: ... def __ceil__(self) -> int: ... def __floor__(self) -> int: ... - def __round__(self, ndigits: Optional[int] = ...) -> int: ... + def __round__(self, ndigits: int | None = ...) -> int: ... def __getnewargs__(self) -> Tuple[int]: ... def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... @@ -335,16 +335,16 @@ class str(Sequence[str]): def capitalize(self) -> str: ... def casefold(self) -> str: ... def center(self, __width: int, __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: str | Tuple[str, ...], __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __suffix: str | Tuple[str, ...], __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> bool: ... 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): @@ -361,24 +361,24 @@ class str(Sequence[str]): def join(self, __iterable: Iterable[str]) -> str: ... def ljust(self, __width: int, __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: int = ...) -> 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: int, __fillchar: str = ...) -> str: ... def rpartition(self, __sep: str) -> Tuple[str, str, str]: ... - def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... - def rstrip(self, __chars: Optional[str] = ...) -> str: ... - def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ... + def rsplit(self, sep: str | None = ..., maxsplit: int = ...) -> List[str]: ... + def rstrip(self, __chars: str | None = ...) -> str: ... + def split(self, sep: str | None = ..., maxsplit: int = ...) -> List[str]: ... def splitlines(self, keepends: bool = ...) -> List[str]: ... def startswith( - self, __prefix: 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: Mapping[int, int | str | None] | Sequence[int | str | None]) -> str: ... @@ -389,7 +389,7 @@ class str(Sequence[str]): 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, 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 @@ -424,25 +424,25 @@ class bytes(ByteString): def capitalize(self) -> bytes: ... def center(self, __width: int, __fillchar: bytes = ...) -> bytes: ... def count( - self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... def decode(self, encoding: str = ..., errors: str = ...) -> str: ... def endswith( self, __suffix: bytes | Tuple[bytes, ...], - __start: Optional[SupportsIndex] = ..., - __end: Optional[SupportsIndex] = ..., + __start: SupportsIndex | None = ..., + __end: SupportsIndex | None = ..., ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> bytes: ... def find( - self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... if sys.version_info >= (3, 8): def hex(self, sep: str | bytes = ..., bytes_per_sep: int = ...) -> str: ... else: def hex(self) -> str: ... def index( - self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... @@ -456,34 +456,34 @@ class bytes(ByteString): def join(self, __iterable_of_bytes: Iterable[ByteString | memoryview]) -> bytes: ... def ljust(self, __width: int, __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: int = ...) -> bytes: ... if sys.version_info >= (3, 9): def removeprefix(self, __prefix: bytes) -> bytes: ... def removesuffix(self, __suffix: bytes) -> bytes: ... def rfind( - self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... def rindex( - self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... def rjust(self, __width: int, __fillchar: bytes = ...) -> bytes: ... def rpartition(self, __sep: bytes) -> Tuple[bytes, bytes, bytes]: ... - def rsplit(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytes]: ... - def rstrip(self, __bytes: Optional[bytes] = ...) -> bytes: ... - def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytes]: ... + def rsplit(self, sep: bytes | None = ..., maxsplit: int = ...) -> List[bytes]: ... + def rstrip(self, __bytes: bytes | None = ...) -> bytes: ... + def split(self, sep: bytes | None = ..., maxsplit: int = ...) -> List[bytes]: ... def splitlines(self, keepends: bool = ...) -> List[bytes]: ... def startswith( self, __prefix: bytes | Tuple[bytes, ...], - __start: Optional[SupportsIndex] = ..., - __end: Optional[SupportsIndex] = ..., + __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: int) -> bytes: ... @classmethod @@ -526,27 +526,27 @@ class bytearray(MutableSequence[int], ByteString): def capitalize(self) -> bytearray: ... def center(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... def count( - self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... def copy(self) -> bytearray: ... def decode(self, encoding: str = ..., errors: str = ...) -> str: ... def endswith( self, __suffix: bytes | Tuple[bytes, ...], - __start: Optional[SupportsIndex] = ..., - __end: Optional[SupportsIndex] = ..., + __start: SupportsIndex | None = ..., + __end: SupportsIndex | None = ..., ) -> bool: ... def expandtabs(self, tabsize: int = ...) -> bytearray: ... def extend(self, __iterable_of_ints: Iterable[int]) -> None: ... def find( - self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... if sys.version_info >= (3, 8): def hex(self, sep: str | bytes = ..., bytes_per_sep: int = ...) -> str: ... else: def hex(self) -> str: ... def index( - self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... def insert(self, __index: int, __item: int) -> None: ... def isalnum(self) -> bool: ... @@ -561,34 +561,34 @@ class bytearray(MutableSequence[int], ByteString): def join(self, __iterable_of_bytes: Iterable[ByteString | memoryview]) -> bytearray: ... def ljust(self, __width: int, __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: ... def removesuffix(self, __suffix: bytes) -> bytearray: ... def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytearray: ... def rfind( - self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... def rindex( - self, __sub: bytes | int, __start: Optional[SupportsIndex] = ..., __end: Optional[SupportsIndex] = ... + self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... ) -> int: ... def rjust(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... def rpartition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... - def rsplit(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... - def rstrip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... - def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... + def rsplit(self, sep: bytes | None = ..., maxsplit: int = ...) -> List[bytearray]: ... + def rstrip(self, __bytes: bytes | None = ...) -> bytearray: ... + def split(self, sep: bytes | None = ..., maxsplit: int = ...) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... def startswith( self, __prefix: bytes | Tuple[bytes, ...], - __start: Optional[SupportsIndex] = ..., - __end: Optional[SupportsIndex] = ..., + __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: int) -> bytearray: ... @classmethod @@ -641,7 +641,7 @@ class memoryview(Sized, Sequence[int]): def __init__(self, obj: ReadableBuffer) -> None: ... def __enter__(self) -> memoryview: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def cast(self, format: str, shape: List[int] | Tuple[int] = ...) -> memoryview: ... @overload @@ -811,7 +811,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]: ... @@ -857,8 +857,8 @@ class set(MutableSet[_T], Generic[_T]): def __iand__(self, s: AbstractSet[object]) -> Set[_T]: ... def __or__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... def __ior__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... - def __sub__(self, s: AbstractSet[Optional[_T]]) -> Set[_T]: ... - def __isub__(self, s: AbstractSet[Optional[_T]]) -> Set[_T]: ... + 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: ... @@ -930,12 +930,12 @@ class property(object): fget: Optional[Callable[[Any], Any]] = ..., fset: Optional[Callable[[Any, Any], None]] = ..., fdel: Optional[Callable[[Any], None]] = ..., - doc: Optional[str] = ..., + 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: ... @@ -1012,7 +1012,7 @@ 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]: ... @@ -1025,7 +1025,7 @@ 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) -> Any | bool: ... @overload @@ -1040,7 +1040,7 @@ 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]: ... @@ -1146,11 +1146,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 @@ -1163,7 +1163,7 @@ def open( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> FileIO: ... # Buffering is on: return BufferedRandom, BufferedReader, or BufferedWriter @@ -1176,7 +1176,7 @@ def open( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> BufferedRandom: ... @overload def open( @@ -1187,7 +1187,7 @@ def open( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> BufferedWriter: ... @overload def open( @@ -1198,7 +1198,7 @@ def open( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> BufferedReader: ... # Buffering cannot be determined: fall back to BinaryIO @@ -1211,7 +1211,7 @@ def open( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> BinaryIO: ... # Fallback if mode is not specified @@ -1220,17 +1220,17 @@ 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: str | bytes) -> int: ... def print( *values: object, - sep: Optional[str] = ..., - end: Optional[str] = ..., + sep: str | None = ..., + end: str | None = ..., file: Optional[SupportsWrite[str]] = ..., flush: bool = ..., ) -> None: ... @@ -1357,14 +1357,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): ... @@ -1405,9 +1405,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): ... @@ -1425,13 +1425,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 1def08a50c5c..d93500f2c510 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,9 +58,9 @@ 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( @@ -76,9 +76,9 @@ def open( filename: StrOrBytesPath, 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]): @@ -95,14 +95,14 @@ class BZ2File(BaseStream, IO[bytes]): 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 @@ -110,10 +110,10 @@ class BZ2File(BaseStream, IO[bytes]): self, filename: StrOrBytesPath, mode: _ReadBinaryMode | _WriteBinaryMode = ..., - buffering: Optional[Any] = ..., + 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 a887a1016d01..45cb98eec1c1 100644 --- a/stdlib/cProfile.pyi +++ b/stdlib/cProfile.pyi @@ -3,9 +3,9 @@ from _typeshed import StrOrBytesPath from types import CodeType from typing import Any, Callable, Dict, Optional, Tuple, TypeVar, Union -def run(statement: str, filename: Optional[str] = ..., sort: 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: str | int = ... + statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: str | None = ..., sort: str | int = ... ) -> None: ... _SelfT = TypeVar("_SelfT", bound=Profile) diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index 7af052442709..adaeddd3a007 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -3,7 +3,7 @@ import sys from time import struct_time from typing import Any, Iterable, List, Optional, Sequence, Tuple, Union -_LocaleType = Tuple[Optional[str], Optional[str]] +_LocaleType = Tuple[str | None, str | None] class IllegalMonthError(ValueError): def __init__(self, month: int) -> None: ... @@ -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: ... diff --git a/stdlib/cgi.pyi b/stdlib/cgi.pyi index bc5917e272b4..037507095d75 100644 --- a/stdlib/cgi.pyi +++ b/stdlib/cgi.pyi @@ -38,7 +38,7 @@ 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 @@ -58,20 +58,20 @@ 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] + filename: str | None file: Optional[IO[bytes]] type: str type_options: dict[str, str] @@ -88,10 +88,10 @@ class FieldStorage(object): 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..a04cc9e14133 100644 --- a/stdlib/cgitb.pyi +++ b/stdlib/cgitb.pyi @@ -2,16 +2,16 @@ from _typeshed import StrOrBytesPath from types import FrameType, TracebackType from typing import IO, Any, Callable, Dict, List, Optional, Tuple, Type -_ExcInfo = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_ExcInfo = Tuple[Optional[Type[BaseException]], BaseException | None, TracebackType | None] 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]] = ..., format: str = ..., ) -> None: ... def __call__( - self, etype: Optional[Type[BaseException]], evalue: Optional[BaseException], etb: Optional[TracebackType] + self, etype: Optional[Type[BaseException]], 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..afcfd0a2a2ea 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 @@ -17,13 +17,13 @@ class Cmd: 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: ... + old_completer: Optional[Callable[[str, int], str | 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: ... @@ -34,6 +34,6 @@ class Cmd: 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 do_help(self, arg: str) -> bool | None: ... 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: ... diff --git a/stdlib/code.pyi b/stdlib/code.pyi index 5111e928efc8..69238cdd1415 100644 --- a/stdlib/code.pyi +++ b/stdlib/code.pyi @@ -5,21 +5,21 @@ class InteractiveInterpreter: def __init__(self, locals: Optional[Mapping[str, Any]] = ...) -> None: ... def runsource(self, source: str, filename: str = ..., symbol: str = ...) -> bool: ... def runcode(self, code: CodeType) -> None: ... - def showsyntaxerror(self, filename: Optional[str] = ...) -> None: ... + def showsyntaxerror(self, filename: str | None = ...) -> None: ... def showtraceback(self) -> None: ... def write(self, data: str) -> None: ... class InteractiveConsole(InteractiveInterpreter): def __init__(self, locals: Optional[Mapping[str, Any]] = ..., filename: str = ...) -> None: ... - def interact(self, banner: Optional[str] = ..., exitmsg: Optional[str] = ...) -> None: ... + def interact(self, banner: str | None = ..., exitmsg: str | None = ...) -> None: ... def push(self, line: str) -> bool: ... def resetbuffer(self) -> None: ... def raw_input(self, prompt: str = ...) -> str: ... def interact( - banner: Optional[str] = ..., + banner: str | None = ..., readfunc: Optional[Callable[[str], str]] = ..., local: Optional[Mapping[str, Any]] = ..., - exitmsg: Optional[str] = ..., + exitmsg: str | None = ..., ) -> None: ... -def compile_command(source: str, filename: str = ..., symbol: str = ...) -> Optional[CodeType]: ... +def compile_command(source: str, filename: str = ..., symbol: str = ...) -> CodeType | None: ... diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index b4327040f001..c245fc619c4e 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -79,8 +79,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 @@ -100,13 +100,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: ... @@ -115,16 +115,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 @@ -200,7 +200,7 @@ class StreamWriter(Codec): def reset(self) -> None: ... def __enter__(self: _SW) -> _SW: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] + self, typ: Optional[Type[BaseException]], exc: BaseException | None, tb: types.TracebackType | None ) -> None: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... @@ -210,12 +210,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: _SR) -> _SR: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] + self, typ: Optional[Type[BaseException]], exc: BaseException | None, tb: types.TracebackType | None ) -> None: ... def __iter__(self) -> Iterator[str]: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... @@ -227,8 +227,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 @@ -239,7 +239,7 @@ class StreamReaderWriter(TextIO): def seek(self, offset: int, whence: int = ...) -> int: ... def __enter__(self: _T) -> _T: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] + self, typ: Optional[Type[BaseException]], 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 @@ -249,7 +249,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: ... @@ -267,8 +267,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: ... @@ -277,7 +277,7 @@ class StreamRecoder(BinaryIO): def __getattr__(self, name: str) -> Any: ... def __enter__(self: _SRT) -> _SRT: ... def __exit__( - self, type: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] + self, type: Optional[Type[BaseException]], 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__. @@ -287,7 +287,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 f49d2481b6ef..4f78973e25cb 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -30,7 +30,7 @@ if sys.version_info >= (3, 7): field_names: str | Iterable[str], *, rename: bool = ..., - module: Optional[str] = ..., + module: str | None = ..., defaults: Optional[Iterable[Any]] = ..., ) -> Type[Tuple[Any, ...]]: ... @@ -41,7 +41,7 @@ else: *, verbose: bool = ..., rename: bool = ..., - module: Optional[str] = ..., + module: str | None = ..., ) -> Type[Tuple[Any, ...]]: ... class UserDict(MutableMapping[_KT, _VT]): @@ -55,7 +55,7 @@ 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] @@ -116,10 +116,10 @@ class UserString(Sequence[str]): def center(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ... 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: 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: str | UserString, start: int = ..., end: int = ...) -> int: ... def format(self, *args: Any, **kwds: Any) -> str: ... @@ -139,7 +139,7 @@ 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: Dict[int, _T] | Dict[str, _T] | Dict[str | int, _T]) -> Dict[int, _T]: ... @@ -157,12 +157,12 @@ class UserString(Sequence[str]): 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: 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: ... @@ -171,8 +171,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: ... @@ -220,9 +220,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 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 ca4087948c3e..2c1dc0dc7e74 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -59,11 +59,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: ... @@ -73,16 +73,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: _T) -> _T: ... - 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]]]): @@ -95,7 +95,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..c5404d573d1f 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] = ..., + max_workers: int | None = ..., + mp_context: BaseContext | None = ..., initializer: Optional[Callable[..., 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..a1b530893566 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]] = ..., 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 8bc5bbb775d7..8ae9d7d4366d 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -64,7 +64,7 @@ class RawConfigParser(_parser): @overload def __init__( self, - defaults: Optional[Mapping[str, Optional[str]]] = ..., + defaults: Optional[Mapping[str, str | None]] = ..., dict_type: Type[Mapping[str, str]] = ..., allow_no_value: Literal[True] = ..., *, @@ -74,13 +74,13 @@ class RawConfigParser(_parser): 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 = ..., *, @@ -90,7 +90,7 @@ class RawConfigParser(_parser): strict: bool = ..., empty_lines_in_values: bool = ..., default_section: str = ..., - interpolation: Optional[Interpolation] = ..., + interpolation: Interpolation | None = ..., converters: _converters = ..., ) -> None: ... def __len__(self) -> int: ... @@ -104,30 +104,30 @@ 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: 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 = ... + 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 = ... + 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 = ... + self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T = ... ) -> bool | _T: ... def _get_conv( self, @@ -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 + 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] = ...) -> 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] = ... + 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] = ... + 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 45fd7022cdb1..b783699c22a2 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -25,7 +25,7 @@ _T_co = TypeVar("_T_co", covariant=True) _T_io = TypeVar("_T_io", bound=Optional[IO[str]]) _F = TypeVar("_F", bound=Callable[..., Any]) -_ExitFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], bool] +_ExitFunc = Callable[[Optional[Type[BaseException]], BaseException | None, TracebackType | None], bool] _CM_EF = TypeVar("_CM_EF", ContextManager[Any], _ExitFunc) class _GeneratorContextManager(ContextManager[_T_co]): @@ -57,7 +57,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: Optional[Type[BaseException]], excinst: BaseException | None, exctb: TracebackType | None ) -> bool: ... class redirect_stdout(ContextManager[_T_io]): @@ -82,14 +82,14 @@ class ExitStack(ContextManager[ExitStack]): def __exit__( self, __exc_type: Optional[Type[BaseException]], - __exc_value: Optional[BaseException], - __traceback: Optional[TracebackType], + __exc_value: BaseException | None, + __traceback: TracebackType | None, ) -> bool: ... if sys.version_info >= (3, 7): _S = TypeVar("_S", bound=AsyncExitStack) - _ExitCoroFunc = Callable[[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]], Awaitable[bool]] + _ExitCoroFunc = Callable[[Optional[Type[BaseException]], BaseException | None, TracebackType | None], Awaitable[bool]] _CallbackCoroFunc = Callable[..., Awaitable[Any]] _ACM_EF = TypeVar("_ACM_EF", AsyncContextManager[Any], _ExitCoroFunc) class AsyncExitStack(AsyncContextManager[AsyncExitStack]): @@ -106,8 +106,8 @@ if sys.version_info >= (3, 7): def __aexit__( self, __exc_type: Optional[Type[BaseException]], - __exc_value: Optional[BaseException], - __traceback: Optional[TracebackType], + __exc_value: BaseException | None, + __traceback: TracebackType | None, ) -> Awaitable[bool]: ... if sys.version_info >= (3, 7): diff --git a/stdlib/contextvars.pyi b/stdlib/contextvars.pyi index b29decbef2b8..41c8bdbbe82c 100644 --- a/stdlib/contextvars.pyi +++ b/stdlib/contextvars.pyi @@ -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/copyreg.pyi b/stdlib/copyreg.pyi index aa9fed854693..bbde98047df1 100644 --- a/stdlib/copyreg.pyi +++ b/stdlib/copyreg.pyi @@ -1,7 +1,7 @@ from typing import Any, Callable, Hashable, List, Optional, SupportsInt, Tuple, TypeVar, Union _TypeT = TypeVar("_TypeT", bound=type) -_Reduce = Union[Tuple[Callable[..., _TypeT], Tuple[Any, ...]], Tuple[Callable[..., _TypeT], Tuple[Any, ...], Optional[Any]]] +_Reduce = Union[Tuple[Callable[..., _TypeT], Tuple[Any, ...]], Tuple[Callable[..., _TypeT], Tuple[Any, ...], Any | None]] __all__: List[str] diff --git a/stdlib/crypt.pyi b/stdlib/crypt.pyi index 155666ab1555..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[str | _Method] = ...) -> str: ... +def crypt(word: str, salt: str | _Method | None = ...) -> str: ... diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index 25a9e4aeb6c0..5681fa109200 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -47,8 +47,8 @@ class unix_dialect(Dialect): class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): fieldnames: Optional[Sequence[_T]] - restkey: Optional[str] - restval: Optional[str] + 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, @@ -68,8 +68,8 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): self: DictReader[str], f: Iterable[str], fieldnames: Optional[Sequence[str]] = ..., - restkey: Optional[str] = ..., - restval: Optional[str] = ..., + 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..0fd835fc44ab 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: ... @@ -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,7 +221,7 @@ 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]]): +class c_char_p(_PointerLike, _SimpleCData[bytes | None]): def __init__(self, value: Optional[_UnionT[int, bytes]] = ...) -> None: ... class c_double(_SimpleCData[float]): ... @@ -246,10 +246,10 @@ 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]]): +class c_wchar_p(_PointerLike, _SimpleCData[str | None]): def __init__(self, value: Optional[_UnionT[int, str]] = ...) -> None: ... class c_bool(_SimpleCData[bool]): 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/dataclasses.pyi b/stdlib/dataclasses.pyi index 8d4ab1b1efba..76fe33e1db69 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -69,7 +69,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] @@ -81,7 +81,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, @@ -93,7 +93,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: ... @@ -109,7 +109,7 @@ 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]] = ..., kw_only: bool = ..., @@ -120,7 +120,7 @@ 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]] = ..., kw_only: bool = ..., @@ -130,7 +130,7 @@ if sys.version_info >= (3, 10): *, init: bool = ..., repr: bool = ..., - hash: Optional[bool] = ..., + hash: bool | None = ..., compare: bool = ..., metadata: Optional[Mapping[str, Any]] = ..., kw_only: bool = ..., @@ -143,7 +143,7 @@ else: default: _T, init: bool = ..., repr: bool = ..., - hash: Optional[bool] = ..., + hash: bool | None = ..., compare: bool = ..., metadata: Optional[Mapping[str, Any]] = ..., ) -> _T: ... @@ -153,7 +153,7 @@ else: default_factory: Callable[[], _T], init: bool = ..., repr: bool = ..., - hash: Optional[bool] = ..., + hash: bool | None = ..., compare: bool = ..., metadata: Optional[Mapping[str, Any]] = ..., ) -> _T: ... @@ -162,7 +162,7 @@ else: *, init: bool = ..., repr: bool = ..., - hash: Optional[bool] = ..., + hash: bool | None = ..., compare: bool = ..., metadata: Optional[Mapping[str, Any]] = ..., ) -> Any: ... 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 c48dbf977d64..26c129f02d48 100644 --- a/stdlib/dbm/__init__.pyi +++ b/stdlib/dbm/__init__.pyi @@ -81,7 +81,7 @@ class _Database(MutableMapping[_KeyType, bytes]): def __del__(self) -> None: ... def __enter__(self) -> _Database: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], 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 fe0ff19ec35b..eb1d5dca807e 100644 --- a/stdlib/dbm/dumb.pyi +++ b/stdlib/dbm/dumb.pyi @@ -19,7 +19,7 @@ class _Database(MutableMapping[_KeyType, bytes]): def __del__(self) -> None: ... def __enter__(self) -> _Database: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], 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 985d238c426a..835e0d53e6dd 100644 --- a/stdlib/dbm/gnu.pyi +++ b/stdlib/dbm/gnu.pyi @@ -9,8 +9,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: ... @@ -21,10 +21,10 @@ class _gdbm: def __len__(self) -> int: ... def __enter__(self) -> _gdbm: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], 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: bytes | _T) -> bytes | _T: ... def keys(self) -> List[bytes]: ... diff --git a/stdlib/dbm/ndbm.pyi b/stdlib/dbm/ndbm.pyi index 3fce371b74f4..54ae1da86699 100644 --- a/stdlib/dbm/ndbm.pyi +++ b/stdlib/dbm/ndbm.pyi @@ -19,10 +19,10 @@ class _dbm: def __del__(self) -> None: ... def __enter__(self) -> _dbm: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], 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: bytes | _T) -> bytes | _T: ... def keys(self) -> List[bytes]: ... diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 7c2914bdbdb2..f1ab4948867c 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: Optional[Type[BaseException]], v: BaseException | None, tb: TracebackType | None) -> None: ... _TrapType = Type[DecimalException] @@ -168,12 +168,12 @@ 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] = ..., + 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: Optional[List[_TrapType]] = ..., @@ -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..5d65d1514cec 100644 --- a/stdlib/difflib.pyi +++ b/stdlib/difflib.pyi @@ -36,7 +36,7 @@ class SequenceMatcher(Generic[_T]): 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 a236082ebde6..e9b1ad10b632 100644 --- a/stdlib/dis.pyi +++ b/stdlib/dis.pyi @@ -26,18 +26,18 @@ _have_code_or_string = _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: Optional[IO[str]] = ..., 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: Optional[IO[str]] = ...) -> None: ... -def distb(tb: Optional[types.TracebackType] = ..., *, file: Optional[IO[str]] = ...) -> None: ... +def distb(tb: types.TracebackType | None = ..., *, 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 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 0e4adb4f27a9..1721f948797b 100644 --- a/stdlib/distutils/ccompiler.pyi +++ b/stdlib/distutils/ccompiler.pyi @@ -1,14 +1,14 @@ from typing import Any, Callable, List, Optional, Tuple, Union -_Macro = Union[Tuple[str], Tuple[str, Optional[str]]] +_Macro = Union[Tuple[str], Tuple[str, str | None]] 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,12 +32,12 @@ 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: 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, @@ -53,8 +53,8 @@ class CCompiler: def compile( self, sources: List[str], - output_dir: Optional[str] = ..., - macros: Optional[_Macro] = ..., + output_dir: str | None = ..., + macros: _Macro | None = ..., include_dirs: Optional[List[str]] = ..., debug: bool = ..., extra_preargs: Optional[List[str]] = ..., @@ -65,16 +65,16 @@ class CCompiler: 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] = ..., + output_dir: str | None = ..., libraries: Optional[List[str]] = ..., library_dirs: Optional[List[str]] = ..., runtime_library_dirs: Optional[List[str]] = ..., @@ -82,27 +82,27 @@ class CCompiler: debug: bool = ..., extra_preargs: Optional[List[str]] = ..., extra_postargs: Optional[List[str]] = ..., - build_temp: Optional[str] = ..., - target_lang: Optional[str] = ..., + build_temp: str | None = ..., + target_lang: str | None = ..., ) -> None: ... def link_executable( self, objects: List[str], output_progname: str, - output_dir: Optional[str] = ..., + output_dir: str | None = ..., libraries: Optional[List[str]] = ..., library_dirs: Optional[List[str]] = ..., runtime_library_dirs: Optional[List[str]] = ..., debug: bool = ..., extra_preargs: Optional[List[str]] = ..., extra_postargs: Optional[List[str]] = ..., - target_lang: Optional[str] = ..., + target_lang: str | None = ..., ) -> None: ... def link_shared_lib( self, objects: List[str], output_libname: str, - output_dir: Optional[str] = ..., + output_dir: str | None = ..., libraries: Optional[List[str]] = ..., library_dirs: Optional[List[str]] = ..., runtime_library_dirs: Optional[List[str]] = ..., @@ -110,14 +110,14 @@ class CCompiler: debug: bool = ..., extra_preargs: Optional[List[str]] = ..., extra_postargs: Optional[List[str]] = ..., - build_temp: Optional[str] = ..., - target_lang: Optional[str] = ..., + build_temp: str | None = ..., + target_lang: str | None = ..., ) -> None: ... def link_shared_object( self, objects: List[str], output_filename: str, - output_dir: Optional[str] = ..., + output_dir: str | None = ..., libraries: Optional[List[str]] = ..., library_dirs: Optional[List[str]] = ..., runtime_library_dirs: Optional[List[str]] = ..., @@ -125,13 +125,13 @@ class CCompiler: debug: bool = ..., extra_preargs: Optional[List[str]] = ..., extra_postargs: Optional[List[str]] = ..., - build_temp: Optional[str] = ..., - target_lang: Optional[str] = ..., + build_temp: str | None = ..., + target_lang: str | None = ..., ) -> None: ... def preprocess( self, source: str, - output_file: Optional[str] = ..., + output_file: str | None = ..., macros: Optional[List[_Macro]] = ..., include_dirs: Optional[List[str]] = ..., extra_preargs: Optional[List[str]] = ..., @@ -141,7 +141,7 @@ class CCompiler: def library_filename(self, libname: str, lib_type: str = ..., strip_dir: int = ..., output_dir: str = ...) -> str: ... def object_filenames(self, source_filenames: List[str], strip_dir: int = ..., output_dir: str = ...) -> List[str]: ... def shared_object_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ... - def execute(self, func: Callable[..., None], args: Tuple[Any, ...], msg: 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 2808a490a59e..309a66f1ac59 100644 --- a/stdlib/distutils/cmd.pyi +++ b/stdlib/distutils/cmd.pyi @@ -13,7 +13,7 @@ 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(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: ... @@ -24,7 +24,7 @@ class 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,10 +50,10 @@ 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, @@ -61,7 +61,7 @@ class Command: 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/command/config.pyi b/stdlib/distutils/command/config.pyi index fc7a7b2f8f23..7c96cd9425d3 100644 --- a/stdlib/distutils/command/config.pyi +++ b/stdlib/distutils/command/config.pyi @@ -10,9 +10,9 @@ LANG_EXT: Dict[str, str] class config(Command): description: str = ... # Tuple is full name, short name, description - user_options: Sequence[Tuple[str, Optional[str], str]] = ... - compiler: Optional[str | CCompiler] = ... - cc: Optional[str] = ... + user_options: Sequence[Tuple[str, str | None, str]] = ... + compiler: str | CCompiler | None = ... + cc: str | None = ... include_dirs: Optional[Sequence[str]] = ... libraries: Optional[Sequence[str]] = ... library_dirs: Optional[Sequence[str]] = ... @@ -24,7 +24,7 @@ class config(Command): def run(self) -> None: ... def try_cpp( self, - body: Optional[str] = ..., + body: str | None = ..., headers: Optional[Sequence[str]] = ..., include_dirs: Optional[Sequence[str]] = ..., lang: str = ..., @@ -32,7 +32,7 @@ class config(Command): def search_cpp( self, pattern: Pattern[str] | str, - body: Optional[str] = ..., + body: str | None = ..., headers: Optional[Sequence[str]] = ..., include_dirs: Optional[Sequence[str]] = ..., lang: str = ..., @@ -84,4 +84,4 @@ class config(Command): lang: str = ..., ) -> bool: ... -def dump_file(filename: str, head: Optional[str] = ...) -> None: ... +def dump_file(filename: str, head: str | None = ...) -> None: ... diff --git a/stdlib/distutils/command/install.pyi b/stdlib/distutils/command/install.pyi index 12e83d976a2d..d2715abeeedb 100644 --- a/stdlib/distutils/command/install.pyi +++ b/stdlib/distutils/command/install.pyi @@ -5,10 +5,10 @@ SCHEME_KEYS: Tuple[str, ...] class install(Command): user: bool - prefix: Optional[str] - home: Optional[str] - root: Optional[str] - install_lib: Optional[str] + prefix: str | None + home: str | None + root: str | None + install_lib: str | None def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... def run(self) -> None: ... diff --git a/stdlib/distutils/command/install_egg_info.pyi b/stdlib/distutils/command/install_egg_info.pyi index 80ffb19bda74..40ce626e09a3 100644 --- a/stdlib/distutils/command/install_egg_info.pyi +++ b/stdlib/distutils/command/install_egg_info.pyi @@ -3,7 +3,7 @@ from typing import ClassVar, List, Optional, Tuple class install_egg_info(Command): description: ClassVar[str] - user_options: ClassVar[List[Tuple[str, Optional[str], str]]] + user_options: ClassVar[List[Tuple[str, str | None, str]]] def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... def run(self) -> None: ... diff --git a/stdlib/distutils/config.pyi b/stdlib/distutils/config.pyi index e60507e0b65a..29524d497acb 100644 --- a/stdlib/distutils/config.pyi +++ b/stdlib/distutils/config.pyi @@ -9,7 +9,7 @@ class PyPIRCCommand(Command): DEFAULT_REALM: ClassVar[str] repository: None realm: None - user_options: ClassVar[List[Tuple[str, Optional[str], str]]] + user_options: ClassVar[List[Tuple[str, str | None, str]]] boolean_options: ClassVar[List[str]] def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... 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 8bf3be806427..8d7712df812d 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -3,21 +3,21 @@ 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[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] + 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: Optional[str | List[str]] platforms: Optional[str | List[str]] classifiers: Optional[str | List[str]] - download_url: Optional[str] + download_url: str | None provides: Optional[List[str]] requires: Optional[List[str]] obsoletes: Optional[List[str]] @@ -55,4 +55,4 @@ class Distribution: def __init__(self, attrs: Optional[Mapping[str, Any]] = ...) -> 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 get_command_obj(self, command: str, create: bool = ...) -> Command | None: ... diff --git a/stdlib/distutils/extension.pyi b/stdlib/distutils/extension.pyi index 47aa8ad4f040..52d531142f43 100644 --- a/stdlib/distutils/extension.pyi +++ b/stdlib/distutils/extension.pyi @@ -6,7 +6,7 @@ class Extension: name: str, sources: List[str], include_dirs: Optional[List[str]] = ..., - define_macros: Optional[List[Tuple[str, Optional[str]]]] = ..., + define_macros: Optional[List[Tuple[str, str | None]]] = ..., undef_macros: Optional[List[str]] = ..., library_dirs: Optional[List[str]] = ..., libraries: Optional[List[str]] = ..., @@ -15,8 +15,8 @@ class Extension: extra_compile_args: Optional[List[str]] = ..., extra_link_args: Optional[List[str]] = ..., export_symbols: Optional[List[str]] = ..., - swig_opts: Optional[str] = ..., # undocumented + swig_opts: str | None = ..., # undocumented depends: Optional[List[str]] = ..., - language: Optional[str] = ..., - optional: Optional[bool] = ..., + language: str | None = ..., + optional: bool | None = ..., ) -> None: ... diff --git a/stdlib/distutils/fancy_getopt.pyi b/stdlib/distutils/fancy_getopt.pyi index 9e2003454cd2..786adcb41e81 100644 --- a/stdlib/distutils/fancy_getopt.pyi +++ b/stdlib/distutils/fancy_getopt.pyi @@ -1,6 +1,6 @@ from typing import Any, Iterable, List, Mapping, Optional, Tuple, Union, overload -_Option = Tuple[str, Optional[str], str] +_Option = Tuple[str, str | None, str] _GR = Tuple[List[str], OptionDummy] def fancy_getopt( @@ -16,7 +16,7 @@ class FancyGetopt: @overload def getopt(self, args: Optional[List[str]], 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 ff4962441446..54a2d2c24f64 100644 --- a/stdlib/distutils/filelist.pyi +++ b/stdlib/distutils/filelist.pyi @@ -16,7 +16,7 @@ class FileList: def process_template_line(self, line: str) -> None: ... @overload def include_pattern( - self, pattern: str, anchor: 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: str | Pattern[str], *, is_regex: Literal[True, 1] = ...) -> bool: ... @@ -25,12 +25,12 @@ class FileList: self, pattern: str | Pattern[str], anchor: int | bool = ..., - prefix: Optional[str] = ..., + prefix: str | None = ..., is_regex: int | bool = ..., ) -> bool: ... @overload def exclude_pattern( - self, pattern: str, anchor: 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: str | Pattern[str], *, is_regex: Literal[True, 1] = ...) -> bool: ... @@ -39,7 +39,7 @@ class FileList: self, pattern: str | Pattern[str], anchor: int | bool = ..., - prefix: Optional[str] = ..., + prefix: str | None = ..., is_regex: int | bool = ..., ) -> bool: ... @@ -47,7 +47,7 @@ def findall(dir: str = ...) -> List[str]: ... def glob_to_re(pattern: str) -> str: ... @overload def translate_pattern( - pattern: str, anchor: 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: str | Pattern[str], *, is_regex: Literal[True, 1] = ...) -> Pattern[str]: ... @@ -55,6 +55,6 @@ def translate_pattern(pattern: str | Pattern[str], *, is_regex: Literal[True, 1] def translate_pattern( pattern: str | Pattern[str], anchor: int | bool = ..., - prefix: Optional[str] = ..., + 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 c9827f347eb0..a5617cd76424 100644 --- a/stdlib/distutils/sysconfig.pyi +++ b/stdlib/distutils/sysconfig.pyi @@ -8,6 +8,6 @@ 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 587d77c9ffad..7dbd809315ab 100644 --- a/stdlib/distutils/text_file.pyi +++ b/stdlib/distutils/text_file.pyi @@ -3,7 +3,7 @@ from typing import IO, List, Optional, Tuple, Union class TextFile: def __init__( self, - filename: Optional[str] = ..., + filename: str | None = ..., file: Optional[IO[str]] = ..., *, strip_comments: bool = ..., @@ -16,6 +16,6 @@ class TextFile: def open(self, filename: str) -> None: ... def close(self) -> None: ... def warn(self, msg: str, line: Optional[List[int] | Tuple[int, int] | int] = ...) -> None: ... - def readline(self) -> Optional[str]: ... + def readline(self) -> str | None: ... def readlines(self) -> List[str]: ... def unreadline(self, line: str) -> str: ... diff --git a/stdlib/distutils/util.pyi b/stdlib/distutils/util.pyi index 0086d726af65..ddf06c033fbb 100644 --- a/stdlib/distutils/util.pyi +++ b/stdlib/distutils/util.pyi @@ -7,17 +7,17 @@ def check_environ() -> None: ... def subst_vars(s: str, local_vars: Mapping[str, str]) -> None: ... def split_quoted(s: str) -> List[str]: ... def execute( - func: Callable[..., None], args: Tuple[Any, ...], msg: Optional[str] = ..., verbose: bool = ..., dry_run: bool = ... + func: Callable[..., None], args: Tuple[Any, ...], msg: str | None = ..., verbose: bool = ..., dry_run: bool = ... ) -> None: ... def strtobool(val: str) -> bool: ... def byte_compile( py_files: List[str], optimize: int = ..., force: bool = ..., - prefix: Optional[str] = ..., - base_dir: Optional[str] = ..., + prefix: str | None = ..., + base_dir: str | None = ..., verbose: bool = ..., dry_run: bool = ..., - direct: Optional[bool] = ..., + direct: bool | None = ..., ) -> None: ... def rfc822_escape(header: str) -> str: ... diff --git a/stdlib/distutils/version.pyi b/stdlib/distutils/version.pyi index 6af86f2564d1..4b6ed06af619 100644 --- a/stdlib/distutils/version.pyi +++ b/stdlib/distutils/version.pyi @@ -11,7 +11,7 @@ class Version: 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 @@ -23,7 +23,7 @@ class StrictVersion(Version): version_re: Pattern[str] version: Tuple[int, int, int] prerelease: Optional[Tuple[str, int]] - def __init__(self, vstring: Optional[str] = ...) -> None: ... + def __init__(self, vstring: str | None = ...) -> None: ... def parse(self: _T, vstring: str) -> _T: ... def __str__(self) -> str: ... def _cmp(self: _T, other: _T | str) -> bool: ... @@ -32,7 +32,7 @@ class LooseVersion(Version): component_re: Pattern[str] vstring: str version: Tuple[str | int, ...] - def __init__(self, vstring: Optional[str] = ...) -> None: ... + def __init__(self, vstring: str | None = ...) -> None: ... def parse(self: _T, vstring: str) -> _T: ... def __str__(self) -> str: ... def _cmp(self: _T, other: _T | str) -> bool: ... diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index fc42f13a286c..c6f2f14944cc 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,7 +41,7 @@ class Example: self, source: str, want: str, - exc_msg: Optional[str] = ..., + exc_msg: str | None = ..., lineno: int = ..., indent: int = ..., options: Optional[Dict[int, bool]] = ..., @@ -52,17 +52,17 @@ 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: ... @@ -70,7 +70,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: 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,7 +81,7 @@ class DocTestFinder: def find( self, obj: object, - name: Optional[str] = ..., + name: str | None = ..., module: None | bool | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., extraglobs: Optional[Dict[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,13 +126,13 @@ class UnexpectedException(Exception): class DebugRunner(DocTestRunner): ... -master: Optional[DocTestRunner] +master: DocTestRunner | None def testmod( - m: Optional[types.ModuleType] = ..., - name: Optional[str] = ..., + m: types.ModuleType | None = ..., + name: str | None = ..., globs: Optional[Dict[str, Any]] = ..., - verbose: Optional[bool] = ..., + verbose: bool | None = ..., report: bool = ..., optionflags: int = ..., extraglobs: Optional[Dict[str, Any]] = ..., @@ -142,23 +142,23 @@ def testmod( def testfile( filename: str, module_relative: bool = ..., - name: Optional[str] = ..., + name: str | None = ..., package: None | str | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., - verbose: Optional[bool] = ..., + verbose: bool | None = ..., report: bool = ..., optionflags: int = ..., extraglobs: Optional[Dict[str, Any]] = ..., 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: ... @@ -170,7 +170,7 @@ class DocTestCase(unittest.TestCase): optionflags: int = ..., setUp: Optional[Callable[[DocTest], Any]] = ..., tearDown: Optional[Callable[[DocTest], Any]] = ..., - checker: Optional[OutputChecker] = ..., + checker: OutputChecker | None = ..., ) -> None: ... def setUp(self) -> None: ... def tearDown(self) -> None: ... @@ -193,7 +193,7 @@ def DocTestSuite( module: None | str | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., extraglobs: Optional[Dict[str, Any]] = ..., - test_finder: Optional[DocTestFinder] = ..., + test_finder: DocTestFinder | None = ..., **options: Any, ) -> _DocTestSuite: ... @@ -207,7 +207,7 @@ def DocFileTest( package: None | str | types.ModuleType = ..., globs: Optional[Dict[str, Any]] = ..., parser: DocTestParser = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., **options: Any, ) -> DocFileCase: ... def DocFileSuite(*paths: str, **kw: Any) -> _DocTestSuite: ... diff --git a/stdlib/email/_header_value_parser.pyi b/stdlib/email/_header_value_parser.pyi index eba7278b2b84..10b0361df254 100644 --- a/stdlib/email/_header_value_parser.pyi +++ b/stdlib/email/_header_value_parser.pyi @@ -24,7 +24,7 @@ if sys.version_info >= (3, 7): rfc2047_matcher: Pattern[str] class TokenList(List[TokenList | Terminal]): - token_type: Optional[str] = ... + 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 = ... @@ -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 962086bcf4f3..5591b370894e 100644 --- a/stdlib/email/header.pyi +++ b/stdlib/email/header.pyi @@ -6,21 +6,21 @@ class Header: self, s: bytes | str | None = ..., charset: Charset | str | None = ..., - maxlinelen: Optional[int] = ..., - header_name: Optional[str] = ..., + maxlinelen: int | None = ..., + header_name: str | None = ..., continuation_ws: str = ..., errors: str = ..., ) -> None: ... def append(self, s: bytes | str, charset: Charset | str | None = ..., errors: str = ...) -> None: ... - def encode(self, splitchars: str = ..., maxlinelen: Optional[int] = ..., linesep: str = ...) -> str: ... + 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: 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 7b8ae7fac6af..729f7168aab6 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: ... @@ -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: Optional[Iterable[Address]] = ...) -> 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 4ca7f85cf2cc..d58c25a5c387 100644 --- a/stdlib/email/message.pyi +++ b/stdlib/email/message.pyi @@ -8,21 +8,21 @@ _T = TypeVar("_T") _PayloadType = List[Message] | str | bytes _CharsetType = Charset | str | None -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] -_ParamType = Union[str, Tuple[Optional[str], Optional[str], str]] +_ParamsType = Union[str, None, Tuple[str, str | None, str]] +_ParamType = Union[str, Tuple[str | None, str | None, str]] _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: ... @@ -53,9 +53,9 @@ class Message: 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 5acee4b3cf25..6cb08fa18c95 100644 --- a/stdlib/email/mime/application.pyi +++ b/stdlib/email/mime/application.pyi @@ -2,7 +2,7 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy from typing import Callable, Optional, Tuple, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, Tuple[str, str | None, str]] class MIMEApplication(MIMENonMultipart): def __init__( @@ -11,6 +11,6 @@ class MIMEApplication(MIMENonMultipart): _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 261992e9caf4..a8a5c3a04388 100644 --- a/stdlib/email/mime/audio.pyi +++ b/stdlib/email/mime/audio.pyi @@ -2,15 +2,15 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy from typing import Callable, Optional, Tuple, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, Tuple[str, str | None, str]] class MIMEAudio(MIMENonMultipart): def __init__( self, _audiodata: str | bytes, - _subtype: Optional[str] = ..., + _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..3a323ee79a7e 100644 --- a/stdlib/email/mime/base.pyi +++ b/stdlib/email/mime/base.pyi @@ -2,7 +2,7 @@ import email.message from email.policy import Policy from typing import Optional, Tuple, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, Tuple[str, str | None, 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 b0044aa627c1..4e3595ed9fbe 100644 --- a/stdlib/email/mime/image.pyi +++ b/stdlib/email/mime/image.pyi @@ -2,15 +2,15 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy from typing import Callable, Optional, Tuple, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, Tuple[str, str | None, str]] class MIMEImage(MIMENonMultipart): def __init__( self, _imagedata: str | bytes, - _subtype: Optional[str] = ..., + _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..31fa6b39abb4 100644 --- a/stdlib/email/mime/multipart.pyi +++ b/stdlib/email/mime/multipart.pyi @@ -3,15 +3,15 @@ from email.mime.base import MIMEBase from email.policy import Policy from typing import Optional, Sequence, Tuple, Union -_ParamsType = Union[str, None, Tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, Tuple[str, str | None, str]] class MIMEMultipart(MIMEBase): def __init__( self, _subtype: str = ..., - boundary: Optional[str] = ..., + boundary: str | None = ..., _subparts: Optional[Sequence[Message]] = ..., *, - 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/policy.pyi b/stdlib/email/policy.pyi index 0095395b1080..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 diff --git a/stdlib/email/utils.pyi b/stdlib/email/utils.pyi index a2829d776704..693d28951635 100644 --- a/stdlib/email/utils.pyi +++ b/stdlib/email/utils.pyi @@ -3,13 +3,13 @@ import sys from email.charset import Charset from typing import List, Optional, Tuple, Union, overload -_ParamType = Union[str, Tuple[Optional[str], Optional[str], str]] -_PDTZ = Tuple[int, int, int, int, int, int, int, int, int, Optional[int]] +_ParamType = Union[str, Tuple[str | None, str | None, str]] +_PDTZ = Tuple[int, int, int, int, int, int, int, int, int, int | None] 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: 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: ... @@ -18,7 +18,7 @@ def parsedate(data: str) -> Optional[Tuple[int, int, int, int, int, int, int, in @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 1f85fc0ef4b6..dd3cf28e2772 100644 --- a/stdlib/encodings/__init__.pyi +++ b/stdlib/encodings/__init__.pyi @@ -4,7 +4,7 @@ from typing import Any, Optional, Union class CodecRegistryError(LookupError, SystemError): ... def normalize_encoding(encoding: str | bytes) -> str: ... -def search_function(encoding: str) -> Optional[CodecInfo]: ... +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/formatter.pyi b/stdlib/formatter.pyi index 31c45592a215..28a4ca807cd1 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: ... @@ -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 9218126bf319..cdb323f980e8 100644 --- a/stdlib/fractions.pyi +++ b/stdlib/fractions.pyi @@ -22,7 +22,7 @@ class Fraction(Rational): def __new__( cls: Type[_T], numerator: int | Rational = ..., - denominator: Optional[int | Rational] = ..., + denominator: int | Rational | None = ..., *, _normalize: bool = ..., ) -> _T: ... diff --git a/stdlib/ftplib.pyi b/stdlib/ftplib.pyi index 59520e5b9b2f..ab532b00990b 100644 --- a/stdlib/ftplib.pyi +++ b/stdlib/ftplib.pyi @@ -26,17 +26,17 @@ 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: _T) -> _T: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... source_address: Optional[Tuple[str, int]] def __init__( @@ -71,10 +71,10 @@ 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[int | str] = ...) -> Tuple[socket, int]: ... - def transfercmd(self, cmd: str, rest: Optional[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[int | str] = ... + self, cmd: str, callback: Callable[[bytes], Any], blocksize: int = ..., rest: int | str | None = ... ) -> str: ... def storbinary( self, @@ -82,7 +82,7 @@ class FTP: fp: SupportsRead[bytes], blocksize: int = ..., callback: Optional[Callable[[bytes], Any]] = ..., - rest: Optional[int | str] = ..., + 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: ... @@ -94,7 +94,7 @@ class FTP: 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: ... @@ -108,15 +108,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]] = ..., ) -> 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: ... @@ -124,7 +124,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 6595bef43c12..16423143f365 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] @@ -121,7 +121,7 @@ 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]: ... 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/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..a3feb12cc996 100644 --- a/stdlib/gettext.pyi +++ b/stdlib/gettext.pyi @@ -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: Optional[Iterable[str]] = ..., all: bool = ...) -> Any: ... _T = TypeVar("_T") @overload def translation( domain: str, - localedir: Optional[StrPath] = ..., + localedir: StrPath | None = ..., languages: Optional[Iterable[str]] = ..., class_: None = ..., fallback: bool = ..., - codeset: Optional[str] = ..., + codeset: str | None = ..., ) -> NullTranslations: ... @overload def translation( domain: str, - localedir: Optional[StrPath] = ..., + localedir: StrPath | None = ..., languages: Optional[Iterable[str]] = ..., class_: Type[_T] = ..., fallback: Literal[False] = ..., - codeset: Optional[str] = ..., + codeset: str | None = ..., ) -> _T: ... @overload def translation( domain: str, - localedir: Optional[StrPath] = ..., + localedir: StrPath | None = ..., languages: Optional[Iterable[str]] = ..., 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: Optional[Container[str]] = ... ) -> 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 616362bdbb60..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: 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 09b4cc03e362..3b21448c23f5 100644 --- a/stdlib/gzip.pyi +++ b/stdlib/gzip.pyi @@ -52,18 +52,18 @@ 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: StrOrBytesPath | _ReadableFileobj | _WritableFileobj, mode: str, compresslevel: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ..., - newline: Optional[str] = ..., + encoding: str | None = ..., + errors: str | None = ..., + newline: str | None = ..., ) -> GzipFile | TextIO: ... class _PaddedFile: @@ -78,7 +78,7 @@ 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 @@ -86,11 +86,11 @@ class GzipFile(_compression.BaseStream): @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: _ReadableFileobj | _WritableFileobj | None = ..., - mtime: Optional[float] = ..., + 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/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 569c30ff8f51..c918f82d8b81 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -102,13 +102,13 @@ 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 read(self, amt: Optional[int] = ...) -> bytes: ... + def __init__(self, sock: socket, debuglevel: int = ..., method: str | None = ..., url: str | None = ...) -> None: ... + 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) -> str | _T: ... def getheaders(self) -> List[Tuple[str, str]]: ... @@ -117,8 +117,8 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO): def __iter__(self) -> Iterator[bytes]: ... def __enter__(self) -> HTTPResponse: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[types.TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Optional[Type[BaseException]], 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: ... @@ -131,18 +131,18 @@ class _HTTPConnectionProtocol(Protocol): def __call__( self, host: str, - port: Optional[int] = ..., + port: int | None = ..., timeout: float = ..., source_address: Optional[Tuple[str, int]] = ..., 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: Optional[Tuple[str, int]] = ... ) -> HTTPConnection: ... class HTTPConnection: - timeout: Optional[float] + timeout: float | None host: str port: int sock: Any @@ -150,8 +150,8 @@ class HTTPConnection: def __init__( self, host: str, - port: Optional[int] = ..., - timeout: Optional[float] = ..., + port: int | None = ..., + timeout: float | None = ..., source_address: Optional[Tuple[str, int]] = ..., blocksize: int = ..., ) -> None: ... @@ -159,27 +159,27 @@ class HTTPConnection: def __init__( self, host: str, - port: Optional[int] = ..., - timeout: Optional[float] = ..., + port: int | None = ..., + timeout: float | None = ..., source_address: Optional[Tuple[str, int]] = ..., ) -> 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: Optional[Mapping[str, str]] = ...) -> 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): @@ -187,28 +187,28 @@ class HTTPSConnection(HTTPConnection): def __init__( self, host: str, - port: Optional[int] = ..., - key_file: Optional[str] = ..., - cert_file: Optional[str] = ..., - timeout: Optional[float] = ..., + port: int | None = ..., + key_file: str | None = ..., + cert_file: str | None = ..., + timeout: float | None = ..., source_address: Optional[Tuple[str, int]] = ..., *, - 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] = ..., + port: int | None = ..., + key_file: str | None = ..., + cert_file: str | None = ..., + timeout: float | None = ..., source_address: Optional[Tuple[str, int]] = ..., *, - context: Optional[ssl.SSLContext] = ..., - check_hostname: Optional[bool] = ..., + context: ssl.SSLContext | None = ..., + check_hostname: bool | None = ..., ) -> None: ... class HTTPException(Exception): ... @@ -225,7 +225,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 6bbbffd09822..222bcd100fba 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -9,14 +9,14 @@ _T = TypeVar("_T") class LoadError(OSError): ... class CookieJar(Iterable[Cookie]): - 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 __iter__(self) -> Iterator[Cookie]: ... def __len__(self) -> int: ... @@ -26,15 +26,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): ... @@ -70,7 +70,7 @@ class DefaultCookiePolicy(CookiePolicy): allowed_domains: Optional[Sequence[str]] = ..., netscape: bool = ..., rfc2965: bool = ..., - rfc2109_as_netscape: Optional[bool] = ..., + rfc2109_as_netscape: bool | None = ..., hide_cookie2: bool = ..., strict_domain: bool = ..., strict_rfc2965_unverifiable: bool = ..., @@ -87,7 +87,7 @@ class DefaultCookiePolicy(CookiePolicy): allowed_domains: Optional[Sequence[str]] = ..., netscape: bool = ..., rfc2965: bool = ..., - rfc2109_as_netscape: Optional[bool] = ..., + rfc2109_as_netscape: bool | None = ..., hide_cookie2: bool = ..., strict_domain: bool = ..., strict_rfc2965_unverifiable: bool = ..., @@ -104,17 +104,17 @@ class DefaultCookiePolicy(CookiePolicy): def is_not_allowed(self, domain: str) -> bool: ... 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 @@ -122,10 +122,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, @@ -133,17 +133,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) -> 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 750147083d85..42208d69dc3e 100644 --- a/stdlib/http/cookies.pyi +++ b/stdlib/http/cookies.pyi @@ -24,7 +24,7 @@ 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: ... @@ -36,7 +36,7 @@ class Morsel(Dict[str, Any], Generic[_T]): def OutputString(self, attrs: Optional[List[str]] = ...) -> str: ... 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: ... diff --git a/stdlib/http/server.pyi b/stdlib/http/server.pyi index a39d9d2e300f..82be655eaa3e 100644 --- a/stdlib/http/server.pyi +++ b/stdlib/http/server.pyi @@ -29,22 +29,22 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler): MessageClass: type responses: Mapping[int, Tuple[str, str]] 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: 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 @@ -57,7 +57,7 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): request: bytes, client_address: Tuple[str, int], server: socketserver.BaseServer, - directory: Optional[StrPath] = ..., + directory: StrPath | None = ..., ) -> None: ... else: def __init__(self, request: bytes, client_address: Tuple[str, int], server: socketserver.BaseServer) -> None: ... diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index c458c6f4ccb4..2c2293ed9f93 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -20,7 +20,7 @@ class IMAP4: mustquote: Pattern[str] = ... debug: int = ... state: str = ... - literal: Optional[str] = ... + literal: str | None = ... tagged_commands: Dict[bytes, Optional[List[bytes]]] untagged_responses: Dict[str, List[bytes | Tuple[bytes, bytes]]] continuation_response: str = ... @@ -32,8 +32,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: ... @@ -50,7 +50,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: ... @@ -60,7 +60,7 @@ class IMAP4: def deleteacl(self, mailbox: str, who: str) -> _CommandResults: ... def enable(self, capability: str) -> _CommandResults: ... def __enter__(self) -> IMAP4: ... - def __exit__(self, t: Optional[Type[BaseException]], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ... + def __exit__(self, t: Optional[Type[BaseException]], 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: ... @@ -78,13 +78,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: ... @@ -104,19 +104,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 = ... @@ -124,9 +124,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: ... @@ -145,9 +145,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: ... diff --git a/stdlib/imghdr.pyi b/stdlib/imghdr.pyi index cabcd9031f63..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: 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 9fbce4c7a26f..232502d00abd 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]]: ... @@ -50,15 +50,15 @@ class _FileLike(Protocol): 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]] = ... ) -> 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..e7830bb950a0 100644 --- a/stdlib/importlib/__init__.pyi +++ b/stdlib/importlib/__init__.pyi @@ -9,7 +9,7 @@ def __import__( 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 69a3b2a57ff1..660b5f56056f 100644 --- a/stdlib/importlib/abc.pyi +++ b/stdlib/importlib/abc.pyi @@ -16,10 +16,10 @@ 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: bytes | str, path: str = ...) -> types.CodeType: ... @@ -27,34 +27,34 @@ class InspectLoader(Loader): 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: Optional[Sequence[_Path]]) -> 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: Optional[Sequence[_Path]], 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 5a9a639bf724..821482d79607 100644 --- a/stdlib/importlib/machinery.pyi +++ b/stdlib/importlib/machinery.pyi @@ -7,19 +7,19 @@ 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] + loader: importlib.abc._LoaderProtocol | None + origin: str | None submodule_search_locations: Optional[List[str]] 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): @@ -27,11 +27,11 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader) @classmethod def find_module( cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ... - ) -> Optional[importlib.abc.Loader]: ... + ) -> 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: Optional[Sequence[importlib.abc._Path]] = ..., 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: ... @@ -54,11 +54,11 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): @classmethod def find_module( cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ... - ) -> Optional[importlib.abc.Loader]: ... + ) -> 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: Optional[Sequence[importlib.abc._Path]] = ..., target: types.ModuleType | None = ... + ) -> ModuleSpec | None: ... # InspectLoader @classmethod def is_package(cls, fullname: str) -> bool: ... @@ -72,7 +72,7 @@ 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: ... @@ -80,21 +80,21 @@ class WindowsRegistryFinder(importlib.abc.MetaPathFinder): @classmethod def find_module( cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ... - ) -> Optional[importlib.abc.Loader]: ... + ) -> 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: Optional[Sequence[importlib.abc._Path]] = ..., target: types.ModuleType | None = ... + ) -> ModuleSpec | None: ... class PathFinder: @classmethod def invalidate_caches(cls) -> None: ... @classmethod def find_spec( - cls, fullname: str, path: Optional[Sequence[bytes | str]] = ..., target: Optional[types.ModuleType] = ... - ) -> Optional[ModuleSpec]: ... + cls, fullname: str, path: Optional[Sequence[bytes | str]] = ..., target: types.ModuleType | None = ... + ) -> ModuleSpec | None: ... @classmethod - def find_module(cls, fullname: str, path: Optional[Sequence[bytes | str]] = ...) -> Optional[importlib.abc.Loader]: ... + def find_module(cls, fullname: str, path: Optional[Sequence[bytes | str]] = ...) -> 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 47c2825b70bf..6a54134e80b1 100644 --- a/stdlib/importlib/metadata.pyi +++ b/stdlib/importlib/metadata.pyi @@ -23,8 +23,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 @@ -32,7 +32,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 @@ -43,7 +43,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: ... @@ -59,8 +59,8 @@ if sys.version_info >= (3, 8): def requires(self) -> Optional[List[str]]: ... 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 @@ -77,7 +77,7 @@ 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: ... diff --git a/stdlib/importlib/util.pyi b/stdlib/importlib/util.pyi index 7dea5a718179..bc16d93a88cb 100644 --- a/stdlib/importlib/util.pyi +++ b/stdlib/importlib/util.pyi @@ -11,25 +11,25 @@ def resolve_name(name: str, package: str) -> 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] = ..., + loader: importlib.abc.Loader | None = ..., submodule_search_locations: Optional[List[str]] = ..., -) -> Optional[importlib.machinery.ModuleSpec]: ... +) -> 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 f3ed35f5bb3f..51e7ec0755f8 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -45,7 +45,7 @@ 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 getmodulename(path: str) -> str | None: ... def ismodule(object: object) -> TypeGuard[ModuleType]: ... # TODO: use TypeGuard[Type[Any]] after python/mypy#10486 is resolved @@ -89,13 +89,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: ... @@ -178,7 +178,7 @@ class Parameter: KEYWORD_ONLY: ClassVar[Literal[_ParameterKind.KEYWORD_ONLY]] VAR_KEYWORD: ClassVar[Literal[_ParameterKind.VAR_KEYWORD]] def replace( - self, *, name: Optional[str] = ..., kind: Optional[_ParameterKind] = ..., default: Any = ..., annotation: Any = ... + self, *, name: str | None = ..., kind: _ParameterKind | None = ..., default: Any = ..., annotation: Any = ... ) -> Parameter: ... class BoundArguments: @@ -201,22 +201,22 @@ def walktree(classes: list[type], children: dict[Type[Any], list[type]], parent: 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] + varargs: str | None + varkw: str | None defaults: Optional[Tuple[Any, ...]] kwonlyargs: list[str] kwonlydefaults: Optional[dict[str, Any]] @@ -226,17 +226,17 @@ 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] = ..., + varargs: str | None = ..., + varkw: str | None = ..., defaults: Optional[Tuple[Any, ...]] = ..., kwonlyargs: Optional[Sequence[str]] = ..., kwonlydefaults: Optional[dict[str, Any]] = ..., @@ -250,8 +250,8 @@ def formatargspec( ) -> str: ... def formatargvalues( args: list[str], - varargs: Optional[str], - varkw: Optional[str], + varargs: str | None, + varkw: str | None, locals: Optional[dict[str, Any]], formatarg: Optional[Callable[[str], str]] = ..., formatvarargs: Optional[Callable[[str], str]] = ..., @@ -279,7 +279,7 @@ class Traceback(NamedTuple): lineno: int function: str code_context: Optional[list[str]] - index: Optional[int] # type: ignore + index: int | None # type: ignore class FrameInfo(NamedTuple): frame: FrameType @@ -287,13 +287,13 @@ class FrameInfo(NamedTuple): lineno: int function: str code_context: Optional[list[str]] - index: Optional[int] # type: ignore + index: int | None # type: ignore 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]: ... @@ -301,7 +301,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 261c178c7f80..a31772e7602d 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -27,8 +27,8 @@ class IOBase: def __next__(self) -> bytes: ... def __enter__(self: _T) -> _T: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def close(self) -> None: ... def fileno(self) -> int: ... def flush(self) -> None: ... @@ -39,21 +39,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. @@ -61,7 +61,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): @@ -91,9 +91,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: _T) -> _T: ... @@ -124,7 +124,7 @@ class BufferedRWPair(BufferedIOBase): class TextIOBase(IOBase): encoding: str - errors: Optional[str] + errors: str | None newlines: str | Tuple[str, ...] | None def __iter__(self) -> Iterator[str]: ... # type: ignore def __next__(self) -> str: ... # type: ignore @@ -133,16 +133,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: ... @@ -158,11 +158,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: _T) -> _T: ... @@ -174,7 +174,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[]. @@ -182,7 +182,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 __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[str | Tuple[str, ...]]: ... diff --git a/stdlib/ipaddress.pyi b/stdlib/ipaddress.pyi index 7d0e1e6249c8..2982f8e55705 100644 --- a/stdlib/ipaddress.pyi +++ b/stdlib/ipaddress.pyi @@ -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,11 +120,11 @@ 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]]: ... diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index 7fe08ca80531..3fea627d46f3 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -53,9 +53,9 @@ 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 __iter__(self) -> Iterator[_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/encoder.pyi b/stdlib/json/encoder.pyi index 7d520149ba4a..1dfcae103036 100644 --- a/stdlib/json/encoder.pyi +++ b/stdlib/json/encoder.pyi @@ -18,7 +18,7 @@ class JSONEncoder: check_circular: bool = ..., allow_nan: bool = ..., sort_keys: bool = ..., - indent: Optional[int] = ..., + indent: int | None = ..., separators: Optional[Tuple[str, str]] = ..., default: Optional[Callable[..., Any]] = ..., ) -> None: ... 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/grammar.pyi b/stdlib/lib2to3/pgen2/grammar.pyi index fe250cfe7717..bc96a8565aec 100644 --- a/stdlib/lib2to3/pgen2/grammar.pyi +++ b/stdlib/lib2to3/pgen2/grammar.pyi @@ -2,7 +2,7 @@ from _typeshed import StrPath from typing import Dict, List, Optional, Tuple, TypeVar _P = TypeVar("_P") -_Label = Tuple[int, Optional[str]] +_Label = Tuple[int, str | None] _DFA = List[List[Tuple[int, int]]] _DFAS = Tuple[_DFA, Dict[int, int]] 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..c94441637c34 100644 --- a/stdlib/lib2to3/pgen2/pgen.pyi +++ b/stdlib/lib2to3/pgen2/pgen.pyi @@ -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 d6091898808a..9b483c095c40 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 @@ -27,11 +27,11 @@ class Base: 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,8 +42,8 @@ class Node(Base): self, type: int, children: List[_NL], - context: Optional[Any] = ..., - prefix: Optional[str] = ..., + context: Any | None = ..., + prefix: str | None = ..., fixers_applied: Optional[List[Any]] = ..., ) -> None: ... def set_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/linecache.pyi b/stdlib/linecache.pyi index 73c77387615c..67cf17f73c65 100644 --- a/stdlib/linecache.pyi +++ b/stdlib/linecache.pyi @@ -2,9 +2,9 @@ from typing import Any, Dict, List, Optional _ModuleGlobals = Dict[str, Any] -def getline(filename: str, lineno: int, module_globals: Optional[_ModuleGlobals] = ...) -> str: ... +def getline(filename: str, lineno: int, module_globals: _ModuleGlobals | None = ...) -> str: ... def clearcache() -> None: ... -def getlines(filename: str, module_globals: Optional[_ModuleGlobals] = ...) -> List[str]: ... -def checkcache(filename: Optional[str] = ...) -> None: ... -def updatecache(filename: str, module_globals: Optional[_ModuleGlobals] = ...) -> List[str]: ... +def getlines(filename: str, module_globals: _ModuleGlobals | None = ...) -> List[str]: ... +def checkcache(filename: str | None = ...) -> None: ... +def updatecache(filename: str, module_globals: _ModuleGlobals | None = ...) -> List[str]: ... def lazycache(filename: str, module_globals: _ModuleGlobals) -> bool: ... diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index b56523a082ac..b21ccf17c9c6 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -80,7 +80,7 @@ class Error(Exception): ... def setlocale(category: int, locale: _str | Iterable[_str] | None = ...) -> _str: ... def localeconv() -> Mapping[_str, int | _str | List[int]]: ... def nl_langinfo(__key: int) -> _str: ... -def getdefaultlocale(envvars: Tuple[_str, ...] = ...) -> Tuple[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: ... diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index aba9bb2e217a..2350426d3d09 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -7,7 +7,7 @@ from time import struct_time from types import FrameType, TracebackType from typing import IO, Any, ClassVar, Optional, Pattern, Tuple, Type, Union -_SysExcInfoType = Union[Tuple[Type[BaseException], BaseException, Optional[TracebackType]], Tuple[None, None, None]] +_SysExcInfoType = Union[Tuple[Type[BaseException], BaseException, TracebackType | None], Tuple[None, None, None]] _ExcInfoType = None | bool | _SysExcInfoType | BaseException _ArgsType = Tuple[Any, ...] | Mapping[str, Any] _FilterType = Union[Filter, Callable[[LogRecord], int]] @@ -17,7 +17,7 @@ raiseExceptions: bool logThreads: bool logMultiprocessing: bool logProcesses: bool -_srcfile: Optional[str] +_srcfile: str | None def currentframe() -> FrameType: ... @@ -46,7 +46,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 @@ -144,7 +144,7 @@ class Logger(Filterer): level: int, msg: Any, args: _ArgsType, - exc_info: Optional[_ExcInfoType] = ..., + exc_info: _ExcInfoType | None = ..., extra: Optional[dict[str, Any]] = ..., stack_info: bool = ..., stacklevel: int = ..., @@ -228,7 +228,7 @@ class Logger(Filterer): level: int, msg: Any, args: _ArgsType, - exc_info: Optional[_ExcInfoType] = ..., + exc_info: _ExcInfoType | None = ..., extra: Optional[dict[str, Any]] = ..., stack_info: bool = ..., ) -> None: ... # undocumented @@ -237,9 +237,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, @@ -249,10 +249,10 @@ class Logger(Filterer): lno: int, msg: Any, args: _ArgsType, - exc_info: Optional[_SysExcInfoType], - func: Optional[str] = ..., + exc_info: _SysExcInfoType | None, + func: str | None = ..., extra: Optional[Mapping[str, Any]] = ..., - sinfo: Optional[str] = ..., + sinfo: str | None = ..., ) -> LogRecord: ... def hasHandlers(self) -> bool: ... def callHandlers(self, record: LogRecord) -> None: ... # undocumented @@ -268,9 +268,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 @@ -278,7 +278,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: ... @@ -288,24 +288,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: str = ..., validate: bool = ... + self, fmt: str | None = ..., datefmt: str | None = ..., style: str = ..., validate: bool = ... ) -> None: ... else: - def __init__(self, fmt: Optional[str] = ..., datefmt: Optional[str] = ..., style: str = ...) -> None: ... + def __init__(self, fmt: str | None = ..., datefmt: str | None = ..., style: str = ...) -> 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: ... @@ -313,7 +313,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: ... @@ -328,8 +328,8 @@ class LogRecord: args: _ArgsType 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 @@ -341,12 +341,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, @@ -355,9 +355,9 @@ class LogRecord: lineno: int, msg: Any, args: _ArgsType, - 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: ... @@ -536,14 +536,14 @@ class LoggerAdapter: level: int, msg: Any, args: _ArgsType, - exc_info: Optional[_ExcInfoType] = ..., + exc_info: _ExcInfoType | None = ..., extra: Optional[dict[str, Any]] = ..., 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]: ... @@ -704,12 +704,12 @@ def makeLogRecord(dict: Mapping[str, Any]) -> LogRecord: ... if sys.version_info >= (3, 8): def basicConfig( *, - filename: Optional[StrPath] = ..., + filename: StrPath | None = ..., filemode: str = ..., format: str = ..., - datefmt: Optional[str] = ..., + datefmt: str | None = ..., style: str = ..., - level: Optional[_Level] = ..., + level: _Level | None = ..., stream: Optional[SupportsWrite[str]] = ..., handlers: Optional[Iterable[Handler]] = ..., force: bool = ..., @@ -718,12 +718,12 @@ if sys.version_info >= (3, 8): else: def basicConfig( *, - filename: Optional[StrPath] = ..., + filename: StrPath | None = ..., filemode: str = ..., format: str = ..., - datefmt: Optional[str] = ..., + datefmt: str | None = ..., style: str = ..., - level: Optional[_Level] = ..., + level: _Level | None = ..., stream: Optional[SupportsWrite[str]] = ..., handlers: Optional[Iterable[Handler]] = ..., ) -> None: ... @@ -733,7 +733,7 @@ def setLoggerClass(klass: Type[Logger]) -> None: ... def captureWarnings(capture: bool) -> None: ... def setLogRecordFactory(factory: Callable[..., LogRecord]) -> None: ... -lastResort: Optional[StreamHandler] +lastResort: StreamHandler | None class StreamHandler(Handler): stream: SupportsWrite[str] # undocumented @@ -745,20 +745,20 @@ class StreamHandler(Handler): class FileHandler(StreamHandler): baseFilename: str # undocumented mode: str # undocumented - encoding: Optional[str] # undocumented + encoding: str | None # undocumented delay: bool # undocumented if sys.version_info >= (3, 9): - errors: Optional[str] # undocumented + errors: str | None # undocumented def __init__( 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 _open(self) -> IO[Any]: ... class NullHandler(Handler): ... diff --git a/stdlib/logging/config.pyi b/stdlib/logging/config.pyi index b605cec66652..4bf960471153 100644 --- a/stdlib/logging/config.pyi +++ b/stdlib/logging/config.pyi @@ -26,7 +26,7 @@ if sys.version_info >= (3, 10): fname: _Path | IO[str] | RawConfigParser, defaults: Optional[dict[str, str]] = ..., disable_existing_loggers: bool = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., ) -> None: ... else: @@ -37,5 +37,5 @@ else: ) -> 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: Optional[Callable[[bytes], bytes | None]] = ...) -> Thread: ... def stopListening() -> None: ... diff --git a/stdlib/logging/handlers.pyi b/stdlib/logging/handlers.pyi index 048cda390ef2..c55ca9bd9e28 100644 --- a/stdlib/logging/handlers.pyi +++ b/stdlib/logging/handlers.pyi @@ -28,12 +28,12 @@ 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: ... @@ -42,10 +42,10 @@ class BaseRotatingHandler(FileHandler): rotator: Optional[Callable[[str, str], 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 + port: int | None # undocumented address: tuple[str, int] | str # undocumented - sock: Optional[socket] # 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: 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: 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,8 +195,8 @@ 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 @@ -224,12 +224,12 @@ 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 @@ -237,7 +237,7 @@ class HTTPHandler(Handler): method: str # undocumented secure: bool # undocumented credentials: Optional[tuple[str, str]] # undocumented - context: Optional[ssl.SSLContext] # undocumented + context: ssl.SSLContext | None # undocumented def __init__( self, host: str, @@ -245,7 +245,7 @@ class HTTPHandler(Handler): method: str = ..., secure: bool = ..., credentials: Optional[tuple[str, str]] = ..., - context: Optional[ssl.SSLContext] = ..., + context: ssl.SSLContext | None = ..., ) -> None: ... def mapLogRecord(self, record: LogRecord) -> dict[str, Any]: ... if sys.version_info >= (3, 9): diff --git a/stdlib/lzma.pyi b/stdlib/lzma.pyi index 5916767403c2..5158f03e50c2 100644 --- a/stdlib/lzma.pyi +++ b/stdlib/lzma.pyi @@ -43,7 +43,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 @@ -58,7 +58,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: ... @@ -68,13 +68,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: _T) -> _T: ... def close(self) -> None: ... @@ -85,9 +85,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: ... @@ -97,10 +97,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 = ..., @@ -110,10 +110,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 = ..., @@ -123,42 +123,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] = ..., + 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/mailbox.pyi b/stdlib/mailbox.pyi index 6bb4cfb45171..57c35ec9768b 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -52,7 +52,7 @@ 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) -> _MessageT | _T: ... def __getitem__(self, key: str) -> _MessageT: ... @@ -72,7 +72,7 @@ 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 = ...) -> _MessageT | _T: ... def popitem(self) -> Tuple[str, _MessageT]: ... @@ -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]): ... @@ -136,7 +136,7 @@ class Babyl(_singlefileMailbox[BabylMessage]): 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: ... @@ -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) -> _ProxyFile[AnyStr]: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], 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 8a721168e06b..34a863f04477 100644 --- a/stdlib/mailcap.pyi +++ b/stdlib/mailcap.pyi @@ -4,5 +4,5 @@ _Cap = Dict[str, 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..8c14019503d9 100644 --- a/stdlib/mimetypes.pyi +++ b/stdlib/mimetypes.pyi @@ -3,13 +3,13 @@ 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 guess_extension(type: str, strict: bool = ...) -> str | None: ... def init(files: Optional[Sequence[str]] = ...) -> None: ... def read_mime_types(file: str) -> Optional[Dict[str, str]]: ... def add_type(type: str, ext: str, strict: bool = ...) -> None: ... @@ -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 78736bf3cf0f..a8d512ffc195 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -27,7 +27,7 @@ if sys.platform != "win32": class _mmap(Generic[AnyStr]): 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__( @@ -54,7 +54,7 @@ class mmap(_mmap[bytes], ContextManager[mmap], Iterable[bytes], 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: ... diff --git a/stdlib/modulefinder.pyi b/stdlib/modulefinder.pyi index 7cb715ce706c..fc018e7f1c0d 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: @@ -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: Optional[List[str]] = ..., 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[Optional[IO[Any]], 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 2d482424c55d..a8e641c1cf1a 100644 --- a/stdlib/msilib/__init__.pyi +++ b/stdlib/msilib/__init__.pyi @@ -32,7 +32,7 @@ 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: int | Type[_Unspecified] = ..., cond: str | Type[_Unspecified] = ..., @@ -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,19 +77,19 @@ 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 remove_pyc(self) -> None: ... @@ -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/sequence.pyi b/stdlib/msilib/sequence.pyi index e4f400d33233..25ec9aa71a87 100644 --- a/stdlib/msilib/sequence.pyi +++ b/stdlib/msilib/sequence.pyi @@ -3,7 +3,7 @@ from typing import List, Optional, Tuple if sys.platform == "win32": - _SequenceType = List[Tuple[str, Optional[str], int]] + _SequenceType = List[Tuple[str, str | None, int]] AdminExecuteSequence: _SequenceType AdminUISequence: _SequenceType 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 0afd4b55c78f..5744e3c70e0d 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: Optional[Callable[..., Any]] = ..., 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] = ..., + processes: int | None = ..., initializer: Optional[Callable[..., Any]] = ..., 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[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 3131a998f864..03b8f5e13f2a 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -22,15 +22,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) -> _ConnectionBase: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], exc_tb: Optional[types.TracebackType] + self, exc_type: Optional[Type[BaseException]], exc_value: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... class Connection(_ConnectionBase): ... @@ -40,23 +40,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) -> Listener: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], exc_tb: Optional[types.TracebackType] + self, exc_type: Optional[Type[BaseException]], 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[Connection | socket.socket | int], timeout: Optional[float] = ... + object_list: Iterable[Connection | socket.socket | int], timeout: float | None = ... ) -> List[Connection | socket.socket | int]: ... -def Client(address: _Address, family: Optional[str] = ..., authkey: Optional[bytes] = ...) -> Connection: ... +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 5cc6c1e9fe34..8ff88bbc68e0 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: Optional[Callable[..., Any]] = ..., 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,10 +53,10 @@ class BaseContext(object): def SimpleQueue(self) -> queues.SimpleQueue[Any]: ... def Pool( self, - processes: Optional[int] = ..., + processes: int | None = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ..., - maxtasksperchild: Optional[int] = ..., + maxtasksperchild: int | None = ..., ) -> multiprocessing.pool.Pool: ... @overload def RawValue(self, typecode_or_type: Type[_CT], *args: Any) -> _CT: ... @@ -100,7 +100,7 @@ class BaseContext(object): ) -> 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..ea0cc06d8e4b 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] = ..., + 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: Optional[Callable[..., Any]] = ..., 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 032018da7bce..0d1858b35a20 100644 --- a/stdlib/multiprocessing/dummy/connection.pyi +++ b/stdlib/multiprocessing/dummy/connection.pyi @@ -17,7 +17,7 @@ class Connection(object): send_bytes: Any def __enter__(self: _ConnectionT) -> _ConnectionT: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __init__(self, _in: Any, _out: Any) -> None: ... def close(self) -> None: ... @@ -29,9 +29,9 @@ class Listener(object): def address(self) -> Optional[Queue[Any]]: ... def __enter__(self: _ListenerT) -> _ListenerT: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], 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 3e6e4b0b6c68..dc53d10e3b14 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -44,18 +44,18 @@ class Namespace: _Namespace = Namespace class Token(object): - typeid: Optional[str | bytes] + typeid: str | bytes | None address: Tuple[str | bytes, int] - id: Optional[str | bytes | int] + id: str | bytes | int | None def __init__( - self, typeid: Optional[bytes | str], address: Tuple[str | bytes, int], id: Optional[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[str | bytes], Tuple[str | bytes, int], Optional[str | bytes | int]]: ... + ) -> Tuple[str | bytes | None, Tuple[str | bytes, int], str | bytes | int | None]: ... def __setstate__( - self, state: Tuple[Optional[str | bytes], Tuple[str | bytes, int], Optional[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,16 +95,16 @@ 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 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 diff --git a/stdlib/multiprocessing/pool.pyi b/stdlib/multiprocessing/pool.pyi index d8004655cacf..afcca36ef20b 100644 --- a/stdlib/multiprocessing/pool.pyi +++ b/stdlib/multiprocessing/pool.pyi @@ -15,8 +15,8 @@ class ApplyResult(Generic[_T]): callback: Optional[Callable[[_T], None]] = ..., error_callback: Optional[Callable[[BaseException], 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): @@ -29,19 +29,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] = ..., + processes: int | None = ..., initializer: Optional[Callable[..., 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( @@ -52,25 +52,25 @@ class Pool(ContextManager[Pool]): callback: Optional[Callable[[_T], None]] = ..., error_callback: Optional[Callable[[BaseException], 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] = ..., + chunksize: int | None = ..., callback: Optional[Callable[[_T], None]] = ..., error_callback: Optional[Callable[[BaseException], 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] = ..., + chunksize: int | None = ..., callback: Optional[Callable[[_T], None]] = ..., error_callback: Optional[Callable[[BaseException], None]] = ..., ) -> AsyncResult[List[_T]]: ... @@ -81,7 +81,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: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ... ) -> None: ... # undocumented diff --git a/stdlib/multiprocessing/process.pyi b/stdlib/multiprocessing/process.pyi index f2d0b5740baf..bd441c2316f5 100644 --- a/stdlib/multiprocessing/process.pyi +++ b/stdlib/multiprocessing/process.pyi @@ -9,11 +9,11 @@ class BaseProcess: self, group: None = ..., target: Optional[Callable[..., Any]] = ..., - name: Optional[str] = ..., + 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 3d61e44e67c5..ecc52c42a8d1 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..33bc53a3eb33 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: Optional[Iterable[_SLT]] = ..., *, 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 5684253407c5..4b02927be3f7 100644 --- a/stdlib/multiprocessing/sharedctypes.pyi +++ b/stdlib/multiprocessing/sharedctypes.pyi @@ -18,18 +18,18 @@ def RawArray(typecode_or_type: Type[_CT], size_or_initializer: int | Sequence[An @overload def RawArray(typecode_or_type: str, size_or_initializer: int | Sequence[Any]) -> Any: ... @overload -def Value(typecode_or_type: Type[_CT], *args: Any, lock: Literal[False], ctx: 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: 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: 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: str | Type[_CData], *args: Any, lock: bool | _LockLike = ..., ctx: Optional[BaseContext] = ... + typecode_or_type: str | Type[_CData], *args: Any, lock: bool | _LockLike = ..., ctx: BaseContext | None = ... ) -> Any: ... @overload def Array( @@ -37,7 +37,7 @@ def Array( size_or_initializer: int | Sequence[Any], *, lock: Literal[False], - ctx: Optional[BaseContext] = ..., + ctx: BaseContext | None = ..., ) -> _CT: ... @overload def Array( @@ -45,7 +45,7 @@ def Array( size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike, - ctx: Optional[BaseContext] = ..., + ctx: BaseContext | None = ..., ) -> SynchronizedArray[_CT]: ... @overload def Array( @@ -53,7 +53,7 @@ def Array( size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike, - ctx: Optional[BaseContext] = ..., + ctx: BaseContext | None = ..., ) -> SynchronizedArray[Any]: ... @overload def Array( @@ -61,25 +61,25 @@ def Array( size_or_initializer: int | Sequence[Any], *, lock: bool | _LockLike = ..., - ctx: Optional[BaseContext] = ..., + 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 70bd6ccb0cb4..3dbd675479ef 100644 --- a/stdlib/multiprocessing/synchronize.pyi +++ b/stdlib/multiprocessing/synchronize.pyi @@ -7,30 +7,30 @@ _LockLike = Lock | RLock class Barrier(threading.Barrier): def __init__( - self, parties: int, action: Optional[Callable[..., Any]] = ..., timeout: Optional[float] = ..., *ctx: BaseContext + self, parties: int, action: Optional[Callable[..., Any]] = ..., 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..b0f26e69e8c3 100644 --- a/stdlib/netrc.pyi +++ b/stdlib/netrc.pyi @@ -2,16 +2,16 @@ 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]] +_NetrcTuple = Tuple[str, str | None, str | None] 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 009077d09d6c..ba13cba1294b 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: _SelfT) -> _SelfT: ... def __exit__(self, *args: Any) -> None: ... def getwelcome(self) -> str: ... @@ -57,7 +57,7 @@ class _NNTPBase: def newnews( 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]: ... @@ -81,8 +81,8 @@ class _NNTPBase: 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..16926d08bc1b 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: ... @@ -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: ... + 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,7 +144,7 @@ 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: ... @@ -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]] option_groups: List[OptionGroup] option_list: List[Option] process_default_values: Any - prog: Optional[str] + prog: str | None rargs: Optional[List[Any]] 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] = ..., + usage: str | None = ..., option_list: Optional[Iterable[Option]] = ..., 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,18 +205,18 @@ 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: Optional[Sequence[AnyStr]] = ..., 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: ... diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 8733c0044cac..f8b28985bd59 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -170,7 +170,7 @@ sep: str if sys.platform == "win32": altsep: str else: - altsep: Optional[str] + altsep: str | None extsep: str pathsep: str defpath: str @@ -420,13 +420,13 @@ 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) -> 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) -> bytes | _T: ... @@ -442,11 +442,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( @@ -457,7 +457,7 @@ def fdopen( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> FileIO: ... @overload def fdopen( @@ -468,7 +468,7 @@ def fdopen( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> BufferedRandom: ... @overload def fdopen( @@ -479,7 +479,7 @@ def fdopen( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> BufferedWriter: ... @overload def fdopen( @@ -490,7 +490,7 @@ def fdopen( errors: None = ..., newline: None = ..., closefd: bool = ..., - opener: Optional[_Opener] = ..., + opener: _Opener | None = ..., ) -> BufferedReader: ... @overload def fdopen( @@ -501,22 +501,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): @@ -528,7 +528,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: ... @@ -553,7 +553,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, @@ -583,7 +583,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: ... @@ -592,12 +592,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": @@ -611,36 +611,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: str | int) -> int: ... # Unix only -def readlink(path: 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]: ... @@ -660,7 +660,7 @@ else: @overload 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 @@ -672,27 +672,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[Tuple[int, int] | Tuple[float, float]] = ..., *, ns: Tuple[int, int] = ..., - dir_fd: Optional[int] = ..., + dir_fd: int | None = ..., follow_symlinks: bool = ..., ) -> None: ... _OnError = Callable[[OSError], Any] def walk( - top: 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": @@ -701,32 +701,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 = ... @@ -777,7 +777,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: ... @@ -796,7 +796,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 @@ -833,11 +833,11 @@ 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: str | int) -> Optional[str]: ... + def confstr(__name: str | int) -> str | None: ... def getloadavg() -> Tuple[float, float, float]: ... def sysconf(__name: str | int) -> int: ... @@ -857,8 +857,8 @@ if sys.version_info >= (3, 7) and sys.platform != "win32": 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: _T) -> _T: ... def __exit__(self, *args: Any) -> None: ... diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index 160ac89242d0..9567618a7869 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -56,8 +56,8 @@ class Path(PurePath): def __new__(cls: Type[_P], *args: StrPath, **kwargs: Any) -> _P: ... def __enter__(self: _P) -> _P: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], traceback: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Optional[Type[BaseException]], exc_value: BaseException | None, traceback: TracebackType | None + ) -> bool | None: ... @classmethod def cwd(cls: Type[_P]) -> _P: ... def stat(self) -> stat_result: ... @@ -85,9 +85,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 @@ -133,9 +133,9 @@ 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): @@ -160,10 +160,10 @@ 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 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: StrPath | bytes) -> None: ... diff --git a/stdlib/pdb.pyi b/stdlib/pdb.pyi index b42fa0cc5410..a43b56fc737a 100644 --- a/stdlib/pdb.pyi +++ b/stdlib/pdb.pyi @@ -15,15 +15,15 @@ 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 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,11 +39,11 @@ 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, @@ -55,10 +55,10 @@ class Pdb(Bdb, Cmd): 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: ... @@ -67,38 +67,38 @@ class Pdb(Bdb, Cmd): 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]: ... diff --git a/stdlib/pickle.pyi b/stdlib/pickle.pyi index e9dc2c68979f..4505e0586e8e 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], @@ -38,8 +38,8 @@ if sys.version_info >= (3, 8): ) -> 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: ... @@ -64,14 +64,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: ... diff --git a/stdlib/pickletools.pyi b/stdlib/pickletools.pyi index 7f75336ebd3e..8b1b7bcabe15 100644 --- a/stdlib/pickletools.pyi +++ b/stdlib/pickletools.pyi @@ -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,7 +152,7 @@ class OpcodeInfo(object): opcodes: List[OpcodeInfo] -def genops(pickle: bytes | IO[bytes]) -> Iterator[Tuple[OpcodeInfo, Optional[Any], Optional[int]]]: ... +def genops(pickle: bytes | IO[bytes]) -> Iterator[Tuple[OpcodeInfo, Any | None, int | None]]: ... def optimize(p: bytes | IO[bytes]) -> bytes: ... def dis( pickle: bytes | IO[bytes], diff --git a/stdlib/pkgutil.pyi b/stdlib/pkgutil.pyi index 02d723574ac5..173f48e01689 100644 --- a/stdlib/pkgutil.pyi +++ b/stdlib/pkgutil.pyi @@ -11,13 +11,13 @@ class ModuleInfo(NamedTuple): 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[MetaPathFinder | PathEntryFinder]: ... def iter_modules(path: Optional[Iterable[str]] = ..., prefix: str = ...) -> Iterator[ModuleInfo]: ... @@ -25,7 +25,7 @@ def read_code(stream: SupportsRead[bytes]) -> Any: ... # undocumented def walk_packages( path: Optional[Iterable[str]] = ..., prefix: str = ..., onerror: Optional[Callable[[str], 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 e42c2aebf74c..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: ... 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 2499463647cd..bb6ddbb2fb45 100644 --- a/stdlib/posix.pyi +++ b/stdlib/posix.pyi @@ -158,7 +158,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 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..b40d793f6bc0 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,7 +26,7 @@ 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): @@ -35,7 +35,7 @@ if sys.version_info >= (3, 10): stream: Optional[IO[str]] = ..., indent: int = ..., width: int = ..., - depth: Optional[int] = ..., + depth: int | None = ..., *, compact: bool = ..., sort_dicts: bool = ..., @@ -48,7 +48,7 @@ elif sys.version_info >= (3, 8): stream: Optional[IO[str]] = ..., indent: int = ..., width: int = ..., - depth: Optional[int] = ..., + depth: int | None = ..., *, compact: bool = ..., sort_dicts: bool = ..., @@ -60,7 +60,7 @@ if sys.version_info >= (3, 10): stream: Optional[IO[str]] = ..., indent: int = ..., width: int = ..., - depth: Optional[int] = ..., + depth: int | None = ..., *, compact: bool = ..., sort_dicts: bool = ..., @@ -73,7 +73,7 @@ elif sys.version_info >= (3, 8): stream: Optional[IO[str]] = ..., indent: int = ..., width: int = ..., - depth: Optional[int] = ..., + depth: int | None = ..., *, compact: bool = ..., sort_dicts: bool = ..., @@ -85,7 +85,7 @@ else: stream: Optional[IO[str]] = ..., indent: int = ..., width: int = ..., - depth: Optional[int] = ..., + depth: int | None = ..., *, compact: bool = ..., ) -> None: ... @@ -100,7 +100,7 @@ class PrettyPrinter: self, indent: int = ..., width: int = ..., - depth: Optional[int] = ..., + depth: int | None = ..., stream: Optional[IO[str]] = ..., *, compact: bool = ..., @@ -112,7 +112,7 @@ class PrettyPrinter: self, indent: int = ..., width: int = ..., - depth: Optional[int] = ..., + depth: int | None = ..., stream: Optional[IO[str]] = ..., *, compact: bool = ..., @@ -123,7 +123,7 @@ class PrettyPrinter: self, indent: int = ..., width: int = ..., - depth: Optional[int] = ..., + depth: int | None = ..., stream: Optional[IO[str]] = ..., *, compact: bool = ..., diff --git a/stdlib/profile.pyi b/stdlib/profile.pyi index 3f8fa0151d75..bf3ea56164d5 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: 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: 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,7 +13,7 @@ _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: Optional[Callable[[], float]] = ..., bias: int | None = ...) -> None: ... def set_cmd(self, cmd: str) -> None: ... def simulate_call(self, name: str) -> None: ... def simulate_cmd_complete(self) -> None: ... diff --git a/stdlib/py_compile.pyi b/stdlib/py_compile.pyi index 6a563a858282..169a09a63ee8 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: ... diff --git a/stdlib/pyclbr.pyi b/stdlib/pyclbr.pyi index 92b62aa88c75..d8f70f9c3521 100644 --- a/stdlib/pyclbr.pyi +++ b/stdlib/pyclbr.pyi @@ -17,7 +17,7 @@ class Class: super: Optional[List[Class | str]], file: str, lineno: int, - parent: Optional[Class] = ..., + parent: Class | None = ..., ) -> None: ... else: def __init__(self, module: str, name: str, super: Optional[List[Class | str]], file: str, lineno: int) -> None: ... @@ -29,7 +29,7 @@ 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: ... diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index 1abfb8b51b50..540feb10f20c 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -19,7 +19,7 @@ from typing import ( ) # the return type of sys.exc_info(), used by ErrorDuringImport.__init__ -_Exc_Info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_Exc_Info = Tuple[Optional[Type[BaseException]], BaseException | None, TracebackType | None] __author__: str __date__: str @@ -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: Optional[Container[str]] = ..., 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] + 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: ... @@ -111,14 +111,14 @@ class HTMLDoc(Doc): 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[Union[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,20 +127,20 @@ 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 filelink(self, url: str, path: str) -> str: ... @@ -166,29 +166,29 @@ class TextDoc(Doc): self, tree: List[Union[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: ... @@ -208,12 +208,12 @@ html: HTMLDoc class _OldStyleClass: ... def resolve(thing: str | object, forceload: bool = ...) -> Optional[Tuple[object, str]]: ... -def render_doc(thing: str | object, title: str = ..., forceload: bool = ..., renderer: Optional[Doc] = ...) -> str: ... +def render_doc(thing: str | object, title: str = ..., forceload: bool = ..., renderer: Doc | None = ...) -> str: ... def doc( thing: str | object, title: str = ..., forceload: bool = ..., output: Optional[SupportsWrite[str]] = ... ) -> None: ... def writedoc(thing: str | object, forceload: bool = ...) -> None: ... -def writedocs(dir: str, pkgpath: str = ..., done: Optional[Any] = ...) -> None: ... +def writedocs(dir: str, pkgpath: str = ..., done: Any | None = ...) -> None: ... class Helper: keywords: Dict[str, str | Tuple[str, str]] @@ -250,8 +250,8 @@ class ModuleScanner: quit: bool def run( self, - callback: Callable[[Optional[str], str, str], None], - key: Optional[Any] = ..., + callback: Callable[[str | None, str, str], None], + key: Any | None = ..., completer: Optional[Callable[[], None]] = ..., onerror: Optional[Callable[[str], None]] = ..., ) -> None: ... diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index 3d852212e877..7327c8aa00b8 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -19,15 +19,15 @@ XML_PARAM_ENTITY_PARSING_NEVER: int XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE: int XML_PARAM_ENTITY_PARSING_ALWAYS: int -_Model = Tuple[int, int, Optional[str], Tuple[Any, ...]] +_Model = Tuple[int, int, str | None, Tuple[Any, ...]] class XMLParserType(object): 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,11 +43,11 @@ 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]] + XmlDeclHandler: Optional[Callable[[str, str | None, int], Any]] + StartDoctypeDeclHandler: Optional[Callable[[str, str | None, str | None, bool], Any]] EndDoctypeDeclHandler: Optional[Callable[[], Any]] ElementDeclHandler: Optional[Callable[[str, _Model], Any]] - AttlistDeclHandler: Optional[Callable[[str, str, str, Optional[str], bool], Any]] + AttlistDeclHandler: Optional[Callable[[str, str, str, str | None, bool], Any]] StartElementHandler: Optional[ Union[ Callable[[str, Dict[str, str]], Any], @@ -58,9 +58,9 @@ class XMLParserType(object): 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]] + UnparsedEntityDeclHandler: Optional[Callable[[str, str | None, str, str | None, str], Any]] + EntityDeclHandler: Optional[Callable[[str, bool, str | None, str | None, str, str | None, str | None], Any]] + NotationDeclHandler: Optional[Callable[[str, str | None, str, str | None], Any]] StartNamespaceDeclHandler: Optional[Callable[[str, str], Any]] EndNamespaceDeclHandler: Optional[Callable[[str], Any]] CommentHandler: Optional[Callable[[str], Any]] @@ -69,11 +69,11 @@ class XMLParserType(object): 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]] + ExternalEntityRefHandler: Optional[Callable[[str, str | None, str | None, str | None], int]] 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: Optional[Dict[str, Any]] = ... ) -> 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 62463ca47570..2201f32f0e9f 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -11,7 +11,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: ... @@ -33,7 +33,7 @@ class Random(_random.Random): 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: ... @@ -78,7 +78,7 @@ else: 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/readline.pyi b/stdlib/readline.pyi index 39f0001d048b..2ed41e7925d7 100644 --- a/stdlib/readline.pyi +++ b/stdlib/readline.pyi @@ -1,17 +1,17 @@ from _typeshed import StrOrBytesPath from typing import Callable, Optional, Sequence -_CompleterT = Optional[Callable[[str, int], Optional[str]]] +_CompleterT = Optional[Callable[[str, int], str | None]] _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: ... diff --git a/stdlib/rlcompleter.pyi b/stdlib/rlcompleter.pyi index 8afb5b1ef628..ae2f0f734091 100644 --- a/stdlib/rlcompleter.pyi +++ b/stdlib/rlcompleter.pyi @@ -2,4 +2,4 @@ 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 complete(self, text: str, state: int) -> str | None: ... diff --git a/stdlib/runpy.pyi b/stdlib/runpy.pyi index d40c3668ad2f..9b502e945402 100644 --- a/stdlib/runpy.pyi +++ b/stdlib/runpy.pyi @@ -17,6 +17,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: Optional[Dict[str, Any]] = ..., 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: Optional[Dict[str, Any]] = ..., 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 1a046c7b9bc3..57d981b02bc5 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: Optional[Iterable[kevent]], __maxevents: int, __timeout: float | None = ... ) -> List[kevent]: ... def fileno(self) -> int: ... @classmethod @@ -105,8 +105,8 @@ if sys.platform == "linux": def __exit__( self, exc_type: Optional[Type[BaseException]] = ..., - exc_val: Optional[BaseException] = ..., - exc_tb: Optional[TracebackType] = ..., + 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 94690efadbf8..68601669aae7 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 ed062f62b49b..2ff4ae62d6ef 100644 --- a/stdlib/shelve.pyi +++ b/stdlib/shelve.pyi @@ -3,7 +3,7 @@ from typing import Any, Dict, Iterator, Optional, Tuple class Shelf(collections.abc.MutableMapping[Any, Any]): def __init__( - self, dict: Dict[bytes, Any], protocol: Optional[int] = ..., writeback: bool = ..., keyencoding: str = ... + self, dict: Dict[bytes, Any], protocol: int | None = ..., writeback: bool = ..., keyencoding: str = ... ) -> None: ... def __iter__(self) -> Iterator[str]: ... def __len__(self) -> int: ... @@ -20,7 +20,7 @@ class Shelf(collections.abc.MutableMapping[Any, Any]): class BsdDbShelf(Shelf): def __init__( - self, dict: Dict[bytes, Any], protocol: Optional[int] = ..., writeback: bool = ..., keyencoding: str = ... + self, dict: Dict[bytes, Any], protocol: int | None = ..., writeback: bool = ..., keyencoding: str = ... ) -> None: ... def set_location(self, key: Any) -> Tuple[str, Any]: ... def next(self) -> Tuple[str, Any]: ... @@ -29,6 +29,6 @@ class BsdDbShelf(Shelf): def last(self) -> Tuple[str, Any]: ... class DbfilenameShelf(Shelf): - 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 = ...) -> DbfilenameShelf: ... +def open(filename: str, flag: str = ..., protocol: int | None = ..., writeback: bool = ...) -> DbfilenameShelf: ... diff --git a/stdlib/shlex.pyi b/stdlib/shlex.pyi index 3373cb3ca6aa..f74e8de78276 100644 --- a/stdlib/shlex.pyi +++ b/stdlib/shlex.pyi @@ -28,8 +28,8 @@ class shlex(Iterable[str]): punctuation_chars: str def __init__( self, - instream: Optional[str | TextIO] = ..., - infile: Optional[str] = ..., + instream: str | TextIO | None = ..., + infile: str | None = ..., posix: bool = ..., punctuation_chars: bool | 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 6d701d9bd248..7767c9494a8b 100644 --- a/stdlib/shutil.pyi +++ b/stdlib/shutil.pyi @@ -63,27 +63,27 @@ class _ntuple_diskusage(NamedTuple): free: int def disk_usage(path: StrPath) -> _ntuple_diskusage: ... -def chown(path: StrPath, user: Optional[str | int] = ..., group: Optional[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( @@ -95,11 +95,11 @@ def register_archive_format( 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 = ... diff --git a/stdlib/signal.pyi b/stdlib/signal.pyi index 2ac96a539b37..fb1bafa93d64 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..9c8c3e363770 100644 --- a/stdlib/site.pyi +++ b/stdlib/site.pyi @@ -1,9 +1,9 @@ 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: ... diff --git a/stdlib/smtpd.pyi b/stdlib/smtpd.pyi index 822994f9f55f..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: bytes | str, **kwargs: Any - ) -> Optional[str]: ... + ) -> str | None: ... class DebuggingServer(SMTPServer): ... class PureProxy(SMTPServer): def process_message( # type: ignore self, peer: _Address, mailfrom: str, rcpttos: List[str], data: bytes | str - ) -> Optional[str]: ... + ) -> str | None: ... class MailmanProxy(PureProxy): def process_message( # type: ignore self, peer: _Address, mailfrom: str, rcpttos: List[str], data: bytes | str - ) -> Optional[str]: ... + ) -> str | None: ... diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index ffade0b70051..afa316e58f1f 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -48,39 +48,39 @@ 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) -> SMTP: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], 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 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: ... @@ -105,11 +105,11 @@ 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, @@ -122,7 +122,7 @@ class SMTP: def send_message( self, msg: _Message, - from_addr: Optional[str] = ..., + from_addr: str | None = ..., to_addrs: Optional[str | Sequence[str]] = ..., mail_options: Sequence[str] = ..., rcpt_options: Sequence[str] = ..., @@ -132,19 +132,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 @@ -154,6 +154,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 b4f23b05ba0b..adeb283ffc95 100644 --- a/stdlib/sndhdr.pyi +++ b/stdlib/sndhdr.pyi @@ -8,5 +8,5 @@ class SndHeaders(NamedTuple): nframes: int 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 06adfc85d171..5926439a7cd4 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -543,7 +543,7 @@ class socket(_socket.socket): family: AddressFamily | int = ..., type: SocketKind | int = ..., proto: int = ..., - fileno: Optional[int] = ..., + fileno: int | None = ..., ) -> None: ... def __enter__(self: _T) -> _T: ... 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 @@ -602,8 +602,8 @@ else: 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,20 +611,20 @@ class SocketIO(RawIOBase): def getfqdn(name: str = ...) -> str: ... def create_connection( - address: tuple[Optional[str], int], - timeout: Optional[float] = ..., # noqa: F811 + address: tuple[str | None, int], + timeout: float | None = ..., # noqa: F811 source_address: Optional[tuple[bytearray | bytes | str, int]] = ..., ) -> 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[bytearray | bytes | str], + host: bytearray | bytes | str | None, port: str | int | None, family: int = ..., type: int = ..., diff --git a/stdlib/socketserver.pyi b/stdlib/socketserver.pyi index cb0c45db281f..d24329c755f8 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -15,7 +15,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: ... @@ -32,7 +32,7 @@ class BaseServer: def verify_request(self, request: _RequestType, client_address: _AddressType) -> bool: ... def __enter__(self: _T) -> _T: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[types.TracebackType] + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... def service_actions(self) -> None: ... def shutdown_request(self, request: _RequestType) -> None: ... # undocumented @@ -86,7 +86,7 @@ if sys.platform != "win32": if sys.platform != "win32": class ForkingMixIn: - timeout: Optional[float] # undocumented + timeout: float | None # undocumented active_children: Optional[Set[int]] # undocumented max_children: int # undocumented if sys.version_info >= (3, 7): @@ -134,7 +134,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 4687497d11a9..ad725c537021 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -69,7 +69,7 @@ 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]] = ..., cached_statements: int = ..., @@ -81,7 +81,7 @@ else: database: bytes | str, timeout: float = ..., detect_types: int = ..., - isolation_level: Optional[str] = ..., + isolation_level: str | None = ..., check_same_thread: bool = ..., factory: Optional[Type[Connection]] = ..., cached_statements: int = ..., @@ -128,7 +128,7 @@ 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: ... @@ -159,7 +159,7 @@ class Connection(object): ) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... def __enter__(self) -> Connection: ... - 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 @@ -177,7 +177,7 @@ class Cursor(Iterator[Any]): def executemany(self, __sql: str, __seq_of_parameters: Iterable[Iterable[Any]]) -> 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_constants.pyi b/stdlib/sre_constants.pyi index bd7bf6033239..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[str | bytes] - pos: Optional[int] + pattern: str | bytes | None + pos: int | None lineno: int colno: int - def __init__(self, msg: str, pattern: Optional[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 06af6201c47e..e482af1db162 100644 --- a/stdlib/sre_parse.pyi +++ b/stdlib/sre_parse.pyi @@ -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: ... @@ -34,7 +34,7 @@ if sys.version_info >= (3, 8): else: Pattern = _State -_OpSubpatternType = Tuple[Optional[int], int, int, SubPattern] +_OpSubpatternType = Tuple[int | None, int, int, SubPattern] _OpGroupRefExistsType = Tuple[int, SubPattern, SubPattern] _OpInType = List[Tuple[_NIC, int]] _OpBranchType = Tuple[None, List[SubPattern]] @@ -43,7 +43,7 @@ _CodeType = Tuple[_NIC, _AvType] class SubPattern: data: List[_CodeType] - width: Optional[int] + width: int | None if sys.version_info >= (3, 8): state: State @@ -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: ... @@ -82,17 +82,17 @@ class Tokenizer: def fix_flags(src: str | bytes, flags: int) -> int: ... -_TemplateType = Tuple[List[Tuple[int, int]], List[Optional[str]]] -_TemplateByteType = Tuple[List[Tuple[int, int]], List[Optional[bytes]]] +_TemplateType = Tuple[List[Tuple[int, int]], List[str | None]] +_TemplateByteType = Tuple[List[Tuple[int, int]], List[bytes | None]] 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 d0e0dff855fb..19ff972129ff 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -12,7 +12,7 @@ _PeerCertRetType = _PeerCertRetDictType | bytes | None _EnumRetType = List[Tuple[bytes, str, Set[str] | bool]] _PasswordType = Union[Callable[[], str | bytes], str, bytes] -_SrvnmeCbType = Callable[[SSLSocket | SSLObject, Optional[str], SSLSocket], Optional[int]] +_SrvnmeCbType = Callable[[SSLSocket | SSLObject, str | None, SSLSocket], int | None] class SSLError(OSError): library: str @@ -34,18 +34,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: str | bytes | None = ... + purpose: Any = ..., *, cafile: str | None = ..., capath: str | None = ..., cadata: str | bytes | None = ... ) -> SSLContext: ... if sys.version_info >= (3, 7): @@ -55,10 +55,10 @@ 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] = ..., + certfile: str | None = ..., + keyfile: str | None = ..., + cafile: str | None = ..., + capath: str | None = ..., cadata: str | bytes | None = ..., ) -> SSLContext: ... @@ -66,13 +66,13 @@ 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] = ..., + certfile: str | None = ..., + keyfile: str | None = ..., + cafile: str | None = ..., + capath: str | None = ..., cadata: str | bytes | None = ..., ) -> SSLContext: ... @@ -85,7 +85,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: ... @@ -217,66 +217,66 @@ 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] = ..., + 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: 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: bytes, flags: int = ...) -> int: ... def sendall(self, data: bytes, flags: int = ...) -> None: ... @overload def sendto(self, data: bytes, flags_or_addr: socket._Address) -> int: ... @overload - def sendto(self, data: bytes, flags_or_addr: int | socket._Address, addr: Optional[socket._Address] = ...) -> int: ... + def sendto(self, data: bytes, 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 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: ... @@ -304,11 +304,11 @@ 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: str | bytes | None = ... + self, cafile: StrPath | None = ..., capath: StrPath | None = ..., cadata: str | bytes | None = ... ) -> None: ... def get_ca_certs(self, binary_form: bool = ...) -> List[_PeerCertRetDictType] | List[bytes]: ... def set_default_verify_paths(self) -> None: ... @@ -319,9 +319,9 @@ class SSLContext: sslobject_class: Type[SSLObject] 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( @@ -330,16 +330,16 @@ 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]: ... if sys.version_info >= (3, 7): @@ -350,33 +350,33 @@ class SSLContext: 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[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 selected_alpn_protocol(self) -> str | None: ... + def selected_npn_protocol(self) -> str | None: ... def cipher(self) -> Optional[Tuple[str, str, int]]: ... def shared_ciphers(self) -> Optional[List[Tuple[str, str, int]]]: ... - def compression(self) -> Optional[str]: ... + 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 89eee73fc572..1a5d4716d4f0 100644 --- a/stdlib/statistics.pyi +++ b/stdlib/statistics.pyi @@ -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: ... diff --git a/stdlib/string.pyi b/stdlib/string.pyi index 9d4157e86a94..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,7 +22,7 @@ class Template: class Formatter: def format(self, __format_string: str, *args: Any, **kwargs: Any) -> str: ... def vformat(self, format_string: str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> str: ... - def parse(self, format_string: str) -> Iterable[Tuple[str, 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: int | str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ... def check_unused_args(self, used_args: Sequence[int | str], args: Sequence[Any], kwargs: Mapping[str, Any]) -> None: ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 7c70c1023335..ec5aa6b0bf72 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -45,7 +45,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: ... @@ -56,15 +56,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -74,25 +74,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -103,24 +103,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -130,25 +130,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., *, universal_newlines: Literal[True], startupinfo: Any = ..., @@ -159,25 +159,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]] = ..., 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 = ..., @@ -189,23 +189,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -215,11 +215,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: @@ -228,15 +228,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -246,23 +246,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -271,24 +271,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., *, universal_newlines: Literal[True], startupinfo: Any = ..., @@ -298,24 +298,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]] = ..., 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 = ..., @@ -326,22 +326,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -350,25 +350,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -376,7 +376,7 @@ def call( start_new_session: bool = ..., pass_fds: Any = ..., *, - timeout: Optional[float] = ..., + timeout: float | None = ..., ) -> int: ... # Same args as Popen.__init__ @@ -390,15 +390,15 @@ def check_call( preexec_fn: Optional[Callable[[], Any]] = ..., 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): @@ -407,14 +407,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -422,24 +422,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -447,24 +447,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -472,24 +472,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., *, universal_newlines: Literal[True], startupinfo: Any = ..., @@ -498,24 +498,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]] = ..., 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 = ..., @@ -523,8 +523,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] = ..., @@ -533,14 +533,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -548,11 +548,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: @@ -560,14 +560,14 @@ else: def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -575,23 +575,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -599,23 +599,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]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., startupinfo: Any = ..., creationflags: int = ..., restore_signals: bool = ..., @@ -623,23 +623,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]] = ..., 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 = ..., @@ -647,8 +647,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: ... @@ -656,14 +656,14 @@ else: def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., + executable: StrOrBytesPath | None = ..., stdin: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[StrOrBytesPath] = ..., - env: Optional[_ENV] = ..., + cwd: StrOrBytesPath | None = ..., + env: _ENV | None = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -671,10 +671,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 @@ -684,11 +684,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 @@ -697,13 +697,13 @@ 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 @@ -724,49 +724,49 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., 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] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., 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 @@ -774,68 +774,68 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., 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] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., 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] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., 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 = ..., @@ -850,25 +850,25 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., 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 @@ -876,47 +876,47 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., 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] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., 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 @@ -924,42 +924,42 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., 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] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., 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 = ..., @@ -973,35 +973,35 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[StrOrBytesPath] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., + executable: StrOrBytesPath | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., preexec_fn: Optional[Callable[[], Any]] = ..., 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: ... @@ -1009,7 +1009,7 @@ class Popen(Generic[AnyStr]): def kill(self) -> None: ... def __enter__(self: _S) -> _S: ... def __exit__( - self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType] + self, type: Optional[Type[BaseException]], value: BaseException | None, traceback: TracebackType | None ) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -1026,16 +1026,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]] = ..., ) -> 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 bbd487edab88..614da563abca 100644 --- a/stdlib/sunau.pyi +++ b/stdlib/sunau.pyi @@ -46,7 +46,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: ... @@ -72,7 +72,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/sys.pyi b/stdlib/sys.pyi index 5e48ad91b01c..280dcb92652d 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -31,10 +31,10 @@ _PathSequence = Sequence[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": @@ -55,8 +55,8 @@ executable: str float_repr_style: str hexversion: int last_type: Optional[Type[BaseException]] -last_value: Optional[BaseException] -last_traceback: Optional[TracebackType] +last_value: BaseException | None +last_traceback: TracebackType | None maxsize: int maxunicode: int meta_path: List[_MetaPathFinder] @@ -65,13 +65,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 @@ -187,13 +187,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 @@ -232,10 +232,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 b8044bcaa615..bd923405e4e0 100644 --- a/stdlib/sysconfig.pyi +++ b/stdlib/sysconfig.pyi @@ -1,13 +1,13 @@ 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 = ...) -> Optional[str]: ... +def get_path(name: str, scheme: str = ..., vars: Optional[Dict[str, Any]] = ..., expand: bool = ...) -> str | None: ... def get_paths(scheme: str = ..., vars: Optional[Dict[str, Any]] = ..., expand: bool = ...) -> Dict[str, str]: ... def get_python_version() -> str: ... def get_platform() -> str: ... diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index ede3ead5d8a2..cbce391796e1 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -70,21 +70,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 bufsize: int = ..., *, - format: Optional[int] = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + 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] = ..., + debug: int | None = ..., + errorlevel: int | None = ..., + compresslevel: int | None = ..., ) -> TarFile: ... class ExFileObject(io.BufferedReader): @@ -92,170 +92,170 @@ 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] + 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] = ..., + fileobj: _Fileobj | None = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + 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 + debug: int | None = ..., + errorlevel: int | None = ..., + copybufsize: int | None = ..., # undocumented ) -> None: ... def __enter__(self) -> TarFile: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __iter__(self) -> Iterator[TarInfo]: ... @classmethod def open( cls, - name: Optional[StrOrBytesPath] = ..., + name: StrOrBytesPath | None = ..., mode: str = ..., fileobj: Optional[IO[bytes]] = ..., # depends on mode bufsize: int = ..., *, - format: Optional[int] = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., errors: str = ..., pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... @classmethod def taropen( cls, - name: Optional[StrOrBytesPath], + name: StrOrBytesPath | None, mode: Literal["r", "a", "w", "x"] = ..., - fileobj: Optional[_Fileobj] = ..., + fileobj: _Fileobj | None = ..., *, compresslevel: int = ..., - format: Optional[int] = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... @overload @classmethod def gzopen( cls, - name: Optional[StrOrBytesPath], + name: StrOrBytesPath | None, mode: Literal["r"] = ..., - fileobj: Optional[_GzipReadableFileobj] = ..., + fileobj: _GzipReadableFileobj | None = ..., compresslevel: int = ..., *, - format: Optional[int] = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... @overload @classmethod def gzopen( cls, - name: Optional[StrOrBytesPath], + name: StrOrBytesPath | None, mode: Literal["w", "x"], - fileobj: Optional[_GzipWritableFileobj] = ..., + fileobj: _GzipWritableFileobj | None = ..., compresslevel: int = ..., *, - format: Optional[int] = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... @overload @classmethod def bz2open( cls, - name: Optional[StrOrBytesPath], + name: StrOrBytesPath | None, mode: Literal["w", "x"], - fileobj: Optional[_Bz2WritableFileobj] = ..., + fileobj: _Bz2WritableFileobj | None = ..., compresslevel: int = ..., *, - format: Optional[int] = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... @overload @classmethod def bz2open( cls, - name: Optional[StrOrBytesPath], + name: StrOrBytesPath | None, mode: Literal["r"] = ..., - fileobj: Optional[_Bz2ReadableFileobj] = ..., + fileobj: _Bz2ReadableFileobj | None = ..., compresslevel: int = ..., *, - format: Optional[int] = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... @classmethod def xzopen( cls, - name: Optional[StrOrBytesPath], + name: StrOrBytesPath | None, mode: Literal["r", "w", "x"] = ..., fileobj: Optional[IO[bytes]] = ..., - preset: Optional[int] = ..., + preset: int | None = ..., *, - format: Optional[int] = ..., + format: int | None = ..., tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... 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 next(self) -> TarInfo | None: ... def extractall( self, path: StrOrBytesPath = ..., members: Optional[Iterable[TarInfo]] = ..., *, numeric_owner: bool = ... ) -> None: ... @@ -276,24 +276,24 @@ class TarFile: def add( self, name: StrPath, - arcname: Optional[StrPath] = ..., + arcname: StrPath | None = ..., recursive: bool = ..., *, - filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ..., + filter: Optional[Callable[[TarInfo], TarInfo | None]] = ..., ) -> None: ... else: def add( self, name: StrPath, - arcname: Optional[StrPath] = ..., + arcname: StrPath | None = ..., recursive: bool = ..., exclude: Optional[Callable[[str], bool]] = ..., *, - filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ..., + filter: Optional[Callable[[TarInfo], TarInfo | None]] = ..., ) -> None: ... def addfile(self, tarinfo: TarInfo, fileobj: Optional[IO[bytes]] = ...) -> None: ... def gettarinfo( - self, name: Optional[str] = ..., arcname: Optional[str] = ..., fileobj: Optional[IO[bytes]] = ... + self, name: str | None = ..., arcname: str | None = ..., fileobj: Optional[IO[bytes]] = ... ) -> TarInfo: ... def close(self) -> None: ... @@ -323,8 +323,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 @@ -343,7 +343,7 @@ class TarInfo: @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 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 ) -> bytes: ... diff --git a/stdlib/telnetlib.pyi b/stdlib/telnetlib.pyi index 0a0343caae98..86d20e60243f 100644 --- a/stdlib/telnetlib.pyi +++ b/stdlib/telnetlib.pyi @@ -81,8 +81,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: ... @@ -90,7 +90,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: ... @@ -107,7 +107,7 @@ class Telnet: def mt_interact(self) -> None: ... def listener(self) -> None: ... def expect( - self, list: Sequence[Pattern[bytes] | bytes], timeout: Optional[float] = ... + self, list: Sequence[Pattern[bytes] | bytes], timeout: float | None = ... ) -> Tuple[int, Optional[Match[bytes]], bytes]: ... def __enter__(self) -> Telnet: ... def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index 44850b2f5911..aa78713d0033 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -9,7 +9,7 @@ if sys.version_info >= (3, 9): # global variables TMP_MAX: int -tempdir: Optional[str] +tempdir: str | None template: str _S = TypeVar("_S") @@ -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] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., dir: Optional[_DirT[AnyStr]] = ..., 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] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., dir: Optional[_DirT[AnyStr]] = ..., 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] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., dir: Optional[_DirT[AnyStr]] = ..., delete: bool = ..., *, - errors: Optional[str] = ..., + errors: str | None = ..., ) -> _TemporaryFileWrapper[Any]: ... else: @@ -61,10 +61,10 @@ 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] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., dir: Optional[_DirT[AnyStr]] = ..., delete: bool = ..., ) -> _TemporaryFileWrapper[str]: ... @@ -72,10 +72,10 @@ else: 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] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., dir: Optional[_DirT[AnyStr]] = ..., delete: bool = ..., ) -> _TemporaryFileWrapper[bytes]: ... @@ -83,10 +83,10 @@ else: def NamedTemporaryFile( mode: str = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., dir: Optional[_DirT[AnyStr]] = ..., delete: bool = ..., ) -> _TemporaryFileWrapper[Any]: ... @@ -99,67 +99,67 @@ 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] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., dir: Optional[_DirT[AnyStr]] = ..., *, - 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] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., dir: Optional[_DirT[AnyStr]] = ..., *, - 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] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., dir: Optional[_DirT[AnyStr]] = ..., *, - 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] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., dir: Optional[_DirT[AnyStr]] = ..., ) -> 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] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., dir: Optional[_DirT[AnyStr]] = ..., ) -> IO[bytes]: ... @overload def TemporaryFile( mode: str = ..., buffering: int = ..., - encoding: Optional[str] = ..., - newline: Optional[str] = ..., - suffix: Optional[AnyStr] = ..., - prefix: Optional[AnyStr] = ..., + encoding: str | None = ..., + newline: str | None = ..., + suffix: AnyStr | None = ..., + prefix: AnyStr | None = ..., dir: Optional[_DirT[AnyStr]] = ..., ) -> IO[Any]: ... @@ -170,8 +170,8 @@ class _TemporaryFileWrapper(Generic[AnyStr], IO[AnyStr]): def __init__(self, file: IO[AnyStr], name: str, delete: bool = ...) -> None: ... def __enter__(self) -> _TemporaryFileWrapper[AnyStr]: ... def __exit__( - self, exc: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc: Optional[Type[BaseException]], 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: ... @@ -213,13 +213,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__( @@ -227,13 +227,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__( @@ -241,16 +241,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__( @@ -258,11 +258,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__( @@ -270,11 +270,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__( @@ -282,17 +282,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: _S) -> _S: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Optional[Type[BaseException]], 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. @@ -305,7 +305,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]: ... @@ -321,12 +321,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: Optional[_DirT[AnyStr]] = ... ) -> 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: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -335,16 +335,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: Optional[_DirT[AnyStr]] = ..., 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: Optional[_DirT[AnyStr]] = ...) -> 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: Optional[_DirT[AnyStr]] = ...) -> AnyStr: ... def gettempdirb() -> bytes: ... def gettempprefixb() -> bytes: ... def gettempdir() -> str: ... diff --git a/stdlib/textwrap.pyi b/stdlib/textwrap.pyi index 0fd80bcb6cff..4a524c3d285a 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. diff --git a/stdlib/threading.pyi b/stdlib/threading.pyi index 5d59eecc64e0..f5770df80dde 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] = ..., + name: str | None = ..., args: Iterable[Any] = ..., kwargs: Optional[Mapping[str, Any]] = ..., *, - 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: Optional[Type[BaseException]], 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,8 +77,8 @@ 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: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... @@ -88,12 +88,12 @@ class Condition: 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: Optional[Type[BaseException]], 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: Optional[Type[BaseException]], 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 @@ -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: Optional[Callable[[], 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 1701e27ebe49..cd07196e137e 100644 --- a/stdlib/time.pyi +++ b/stdlib/time.pyi @@ -77,9 +77,9 @@ 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 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: _TimeTuple | struct_time = ...) -> str: ... diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index a826f539f6f4..5bf47cd6b678 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -123,7 +123,7 @@ _Padding = Union[ _Relief = Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] # manual page: Tk_GetRelief _ScreenUnits = str | float # manual page: Tk_GetPixels _XYScrollCommand = Union[str, Callable[[float, float], Any]] # -xscrollcommand and -yscrollcommand in 'options' manual page -_TakeFocusValue = Union[int, Literal[""], Callable[[str], Optional[bool]]] # -takefocus in manual page named 'options' +_TakeFocusValue = Union[int, Literal[""], Callable[[str], bool | None]] # -takefocus in manual page named 'options' class EventType(str, Enum): Activate: str = ... @@ -193,7 +193,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: ... @@ -206,25 +206,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: ... @@ -237,18 +237,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: 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): ... @@ -257,12 +257,12 @@ 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 @@ -279,18 +279,18 @@ 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: Literal[0] | Misc | None = ...): ... def winfo_atomname(self, id: int, displayof: Literal[0] | Misc | None = ...): ... @@ -298,7 +298,7 @@ class Misc: 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: 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: ... @@ -343,40 +343,40 @@ 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: Optional[Callable[[Event[Misc]], Any]] = ..., 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: Optional[Callable[[Event[Misc]], Any]] = ..., 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] = ..., + sequence: str | None = ..., func: Optional[Callable[[Event[Misc]], Any]] = ..., - add: Optional[bool] = ..., + 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: ... @@ -387,11 +387,11 @@ class Misc: ) -> 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( @@ -415,7 +415,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: ... @@ -452,7 +452,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 @@ -494,7 +494,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]: ... @@ -503,12 +503,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 @@ -521,27 +521,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 @@ -556,11 +556,11 @@ 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: ... @@ -574,7 +574,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: ... @@ -601,12 +601,12 @@ 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( @@ -671,7 +671,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) @@ -834,12 +834,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: Optional[Callable[[Event[_W]], Any]] = ..., 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 @@ -847,7 +847,7 @@ class Toplevel(BaseWidget, Wm): # copy/pasted here instead of aliasing as 'config = Tk.config'. def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, background: _Color = ..., @@ -903,7 +903,7 @@ class Toplevel(BaseWidget, Wm): class Button(Widget): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, activebackground: _Color = ..., @@ -1000,7 +1000,7 @@ class Button(Widget): class Canvas(Widget, XView, YView): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, background: _Color = ..., @@ -1083,7 +1083,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,17 +1092,17 @@ class Canvas(Widget, XView, YView): def tag_bind( self, tagOrId: str | int, - sequence: Optional[str] = ..., + sequence: str | None = ..., func: Optional[Callable[[Event[Canvas]], Any]] = ..., - add: Optional[bool] = ..., + add: bool | None = ..., ) -> str: ... @overload - def tag_bind(self, tagOrId: 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: str | int, *, func: str, add: Optional[bool] = ...) -> None: ... - def tag_unbind(self, tagOrId: 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 = ...): ... def coords(self, *args): ... def create_arc(self, *args, **kw) -> _CanvasItemId: ... def create_bitmap(self, *args, **kw) -> _CanvasItemId: ... @@ -1272,7 +1272,7 @@ class Canvas(Widget, XView, YView): def find_above(self, tagOrId: str | _CanvasItemId): ... def find_all(self): ... def find_below(self, tagOrId: str | _CanvasItemId): ... - def find_closest(self, x, y, halo: Optional[Any] = ..., start: Optional[Any] = ...): ... + 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: str | _CanvasItemId): ... @@ -1282,7 +1282,7 @@ class Canvas(Widget, XView, YView): def index(self, *args): ... def insert(self, *args): ... def itemcget(self, tagOrId, option): ... - def itemconfigure(self, tagOrId, cnf: Optional[Any] = ..., **kw): ... + def itemconfigure(self, tagOrId, cnf: Any | None = ..., **kw): ... itemconfig: Any def tag_lower(self, *args): ... lower: Any @@ -1307,7 +1307,7 @@ class Canvas(Widget, XView, YView): class Checkbutton(Widget): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, activebackground: _Color = ..., @@ -1424,7 +1424,7 @@ class Checkbutton(Widget): class Entry(Widget, XView): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, background: _Color = ..., @@ -1512,7 +1512,7 @@ class Entry(Widget, XView): @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure - def delete(self, first, last: Optional[Any] = ...): ... + def delete(self, first, last: Any | None = ...): ... def get(self): ... def icursor(self, index): ... def index(self, index): ... @@ -1535,7 +1535,7 @@ class Entry(Widget, XView): class Frame(Widget): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, background: _Color = ..., @@ -1587,7 +1587,7 @@ class Frame(Widget): class Label(Widget): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, activebackground: _Color = ..., @@ -1667,7 +1667,7 @@ class Label(Widget): class Listbox(Widget, XView, YView): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, activestyle: Literal["dotbox", "none", "underline"] = ..., @@ -1756,8 +1756,8 @@ class Listbox(Widget, XView, YView): 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): ... @@ -1766,15 +1766,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 = str | int @@ -1782,7 +1782,7 @@ _MenuIndex = str | int class Menu(Widget): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, activebackground: _Color = ..., @@ -2035,9 +2035,9 @@ class Menu(Widget): variable: Variable = ..., ) -> None: ... def insert_separator(self, index: _MenuIndex, cnf: Optional[Dict[str, Any]] = ..., *, background: _Color = ...) -> None: ... - def delete(self, index1, index2: Optional[Any] = ...): ... + def delete(self, index1, index2: Any | None = ...): ... def entrycget(self, index, option): ... - def entryconfigure(self, index, cnf: Optional[Any] = ..., **kw): ... + def entryconfigure(self, index, cnf: Any | None = ..., **kw): ... entryconfig: Any def index(self, index): ... def invoke(self, index): ... @@ -2050,7 +2050,7 @@ class Menu(Widget): class Menubutton(Widget): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, activebackground: _Color = ..., @@ -2136,7 +2136,7 @@ class Menubutton(Widget): class Message(Widget): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, anchor: _Anchor = ..., @@ -2199,7 +2199,7 @@ class Message(Widget): class Radiobutton(Widget): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, activebackground: _Color = ..., @@ -2303,7 +2303,7 @@ class Radiobutton(Widget): class Scale(Widget): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, activebackground: _Color = ..., @@ -2388,13 +2388,13 @@ class Scale(Widget): 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] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, activebackground: _Color = ..., @@ -2454,7 +2454,7 @@ class Scrollbar(Widget): @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): ... @@ -2466,7 +2466,7 @@ _TextIndex = _tkinter.Tcl_Obj | str | float | Misc class Text(Widget, XView, YView): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, autoseparators: bool = ..., @@ -2581,13 +2581,13 @@ class Text(Widget, XView, YView): def debug(self, boolean: None = ...) -> bool: ... @overload def debug(self, boolean: bool) -> None: ... - def delete(self, index1: _TextIndex, index2: Optional[_TextIndex] = ...) -> None: ... + def delete(self, index1: _TextIndex, index2: _TextIndex | None = ...) -> None: ... def dlineinfo(self, index: _TextIndex) -> Optional[Tuple[int, int, int, int, int]]: ... @overload def dump( self, index1: _TextIndex, - index2: Optional[_TextIndex] = ..., + index2: _TextIndex | None = ..., command: None = ..., *, all: bool = ..., @@ -2601,7 +2601,7 @@ class Text(Widget, XView, YView): def dump( self, index1: _TextIndex, - index2: Optional[_TextIndex], + index2: _TextIndex | None, command: Union[Callable[[str, str, str], Any], str], *, all: bool = ..., @@ -2615,7 +2615,7 @@ class Text(Widget, XView, YView): def dump( self, index1: _TextIndex, - index2: Optional[_TextIndex] = ..., + index2: _TextIndex | None = ..., *, command: Union[Callable[[str, str, str], Any], str], all: bool = ..., @@ -2634,10 +2634,10 @@ 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: ... @@ -2649,8 +2649,8 @@ 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: str | Text, cnf: Dict[str, Any] = ..., **kw: Any) -> None: ... def peer_names(self) -> Tuple[_tkinter.Tcl_Obj, ...]: ... @@ -2661,25 +2661,25 @@ class Text(Widget, XView, YView): 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: Optional[Callable[[Event[Text]], Any]], 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 @@ -2721,28 +2721,28 @@ class Text(Widget, XView, YView): 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] = ... + self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ... ) -> Tuple[str, str] | Tuple[()]: ... def tag_prevrange( - self, tagName: str, index1: _TextIndex, index2: Optional[_TextIndex] = ... + self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ... ) -> Tuple[str, str] | Tuple[()]: ... - def tag_raise(self, tagName: str, aboveThis: Optional[str] = ...) -> None: ... + 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 @@ -2752,7 +2752,7 @@ class OptionMenu(Menubutton): def __init__( # differs from other widgets self, - master: Optional[Misc], + master: Misc | None, variable: StringVar, value: str, *values: str, @@ -2771,7 +2771,7 @@ class Image: name: Any tk: _tkinter.TkappType def __init__( - self, imgtype, name: Optional[Any] = ..., cnf=..., master: Optional[Misc | _tkinter.TkappType] = ..., **kw + self, imgtype, name: Any | None = ..., cnf=..., master: Misc | _tkinter.TkappType | None = ..., **kw ): ... def __del__(self): ... def __setitem__(self, key, value): ... @@ -2785,9 +2785,9 @@ class Image: class PhotoImage(Image): def __init__( self, - name: Optional[str] = ..., + name: str | None = ..., cnf: Dict[str, Any] = ..., - master: Optional[Misc | _tkinter.TkappType] = ..., + master: Misc | _tkinter.TkappType | None = ..., *, data: str | bytes = ..., # not same as data argument of put() format: str = ..., @@ -2820,7 +2820,7 @@ class PhotoImage(Image): self, data: str | _TkinterSequence[str] | _TkinterSequence2D[_Color], to: Optional[Tuple[int, int]] = ... ) -> None: ... def write( - self, filename: StrOrBytesPath, format: Optional[str] = ..., from_coords: Optional[Tuple[int, int]] = ... + self, filename: StrOrBytesPath, format: str | None = ..., from_coords: Optional[Tuple[int, int]] = ... ) -> None: ... if sys.version_info >= (3, 8): def transparency_get(self, x: int, y: int) -> bool: ... @@ -2829,9 +2829,9 @@ class PhotoImage(Image): class BitmapImage(Image): def __init__( self, - name: Optional[Any] = ..., + name: Any | None = ..., cnf: Dict[str, Any] = ..., - master: Optional[Misc | _tkinter.TkappType] = ..., + master: Misc | _tkinter.TkappType | None = ..., *, background: _Color = ..., data: str | bytes = ..., @@ -2847,7 +2847,7 @@ def image_types() -> Tuple[str, ...]: ... class Spinbox(Widget, XView): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, activebackground: _Color = ..., @@ -2963,7 +2963,7 @@ class Spinbox(Widget, XView): 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): ... @@ -2976,7 +2976,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: ... @@ -2986,7 +2986,7 @@ class Spinbox(Widget, XView): class LabelFrame(Widget): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, background: _Color = ..., @@ -3051,7 +3051,7 @@ class LabelFrame(Widget): class PanedWindow(Widget): def __init__( self, - master: Optional[Misc] = ..., + master: Misc | None = ..., cnf: Optional[Dict[str, Any]] = ..., *, background: _Color = ..., @@ -3120,6 +3120,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 d5adf27f294f..e8050170b96d 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[str | bytes] = ..., **options: Any + color: str | bytes | None = ..., **options: Any ) -> Union[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 7371f91b524e..488fefb6274e 100644 --- a/stdlib/tkinter/dnd.pyi +++ b/stdlib/tkinter/dnd.pyi @@ -3,11 +3,11 @@ from tkinter import Event, Misc, Tk from typing import ClassVar, Optional 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 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 86238f0be798..e84cc88f679b 100644 --- a/stdlib/tkinter/filedialog.pyi +++ b/stdlib/tkinter/filedialog.pyi @@ -6,7 +6,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 = ... @@ -20,21 +20,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 20a734221e22..de84eca54e3b 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 12c614072ba2..87aa82eff0b2 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..2e54954efa51 100644 --- a/stdlib/tkinter/tix.pyi +++ b/stdlib/tkinter/tix.pyi @@ -38,20 +38,20 @@ 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_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] = ..., + master: tkinter.Misc | None = ..., + widgetName: str | None = ..., static_options: Optional[List[str]] = ..., cnf: Dict[str, Any] = ..., kw: Dict[str, Any] = ..., @@ -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: ... @@ -301,5 +301,5 @@ class Form: 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 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 167641661754..552225049efe 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -6,7 +6,7 @@ from typing import Any, Callable, Dict, List, Optional, Tuple, Union, overload from typing_extensions import Literal 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 = ..., @@ -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 = ..., @@ -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 = ..., @@ -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 = ..., @@ -290,13 +290,13 @@ class Combobox(Entry): ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @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 = ..., @@ -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 = ..., @@ -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 @@ -436,7 +436,7 @@ LabelFrame = Labelframe class Menubutton(Widget): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, class_: str = ..., compound: _TtkCompound = ..., @@ -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 = ..., @@ -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 = ..., @@ -561,15 +561,15 @@ class Panedwindow(Widget, tkinter.PanedWindow): 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 = ..., @@ -603,14 +603,14 @@ class Progressbar(Widget): @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 = ..., @@ -657,7 +657,7 @@ 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]] = ..., @@ -712,12 +712,12 @@ class Scale(Widget, tkinter.Scale): ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @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] = ..., @@ -758,7 +758,7 @@ class Scrollbar(Widget, tkinter.Scrollbar): class Separator(Widget): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, class_: str = ..., cursor: tkinter._Cursor = ..., @@ -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 = ..., @@ -809,7 +809,7 @@ 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 = ..., @@ -874,7 +874,7 @@ if sys.version_info >= (3, 7): class Treeview(Widget, tkinter.XView, tkinter.YView): def __init__( self, - master: Optional[tkinter.Misc] = ..., + master: tkinter.Misc | None = ..., *, class_: str = ..., columns: str | tkinter._TkinterSequence[str] = ..., @@ -914,23 +914,23 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure - def bbox(self, item, column: Optional[Any] = ...): ... # type: ignore - def get_children(self, item: Optional[Any] = ...): ... + def bbox(self, item, column: Any | None = ...): ... # type: ignore + def get_children(self, item: Any | None = ...): ... def set_children(self, item, *newchildren): ... - def column(self, column, option: Optional[Any] = ..., **kw): ... + def column(self, column, option: Any | None = ..., **kw): ... def delete(self, *items): ... def detach(self, *items): ... def exists(self, item): ... - def focus(self, item: Optional[Any] = ...): ... - def heading(self, column, option: Optional[Any] = ..., **kw): ... + def focus(self, item: Any | None = ...): ... + def heading(self, column, option: Any | None = ..., **kw): ... def identify(self, component, x, y): ... def identify_row(self, y): ... def identify_column(self, x): ... def identify_region(self, x, y): ... def identify_element(self, x, y): ... def index(self, item): ... - def insert(self, parent, index, iid: Optional[Any] = ..., **kw): ... - def item(self, item, option: Optional[Any] = ..., **kw): ... + def insert(self, parent, index, iid: Any | None = ..., **kw): ... + def item(self, item, option: Any | None = ..., **kw): ... def move(self, item, parent, index): ... reattach: Any def next(self, item): ... @@ -940,24 +940,24 @@ 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): ... def selection_add(self, items): ... def selection_remove(self, items): ... def selection_toggle(self, items): ... - def set(self, item, column: Optional[Any] = ..., value: Optional[Any] = ...): ... + def set(self, item, column: Any | None = ..., value: Any | None = ...): ... # There's no tag_unbind() or 'add' argument for whatever reason. # 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: Optional[Callable[[tkinter.Event[Treeview]], Any]] = ... ) -> 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: ... - def tag_configure(self, tagname, option: Optional[Any] = ..., **kw): ... - def tag_has(self, tagname, item: Optional[Any] = ...): ... + def tag_configure(self, tagname, option: Any | None = ..., **kw): ... + def tag_has(self, tagname, item: Any | None = ...): ... class LabeledScale(Frame): label: Any @@ -965,8 +965,8 @@ class LabeledScale(Frame): # TODO: don't any-type **kw. That goes to Frame.__init__. def __init__( self, - master: Optional[tkinter.Misc] = ..., - variable: Optional[tkinter.IntVar | tkinter.DoubleVar] = ..., + master: tkinter.Misc | None = ..., + variable: tkinter.IntVar | tkinter.DoubleVar | None = ..., from_: float = ..., to: float = ..., *, @@ -981,7 +981,7 @@ 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 = ..., @@ -990,4 +990,4 @@ class OptionMenu(Menubutton): ) -> 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 15e6a988cc32..ac9b4c4809c5 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -50,7 +50,7 @@ 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: ... diff --git a/stdlib/trace.pyi b/stdlib/trace.pyi index 1e60b392e565..7e42db7afa8f 100644 --- a/stdlib/trace.pyi +++ b/stdlib/trace.pyi @@ -4,21 +4,21 @@ from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple, Type _T = TypeVar("_T") _localtrace = Callable[[types.FrameType, str, Any], Callable[..., Any]] -_fileModuleFunction = Tuple[str, Optional[str], str] +_fileModuleFunction = Tuple[str, str | None, str] class CoverageResults: def __init__( self, counts: Optional[Dict[Tuple[str, int], int]] = ..., calledfuncs: Optional[Dict[_fileModuleFunction, int]] = ..., - infile: Optional[StrPath] = ..., + infile: StrPath | None = ..., callers: Optional[Dict[Tuple[_fileModuleFunction, _fileModuleFunction], int]] = ..., - outfile: Optional[StrPath] = ..., + 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]: ... class Trace: @@ -30,8 +30,8 @@ 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: str | types.CodeType) -> None: ... diff --git a/stdlib/traceback.pyi b/stdlib/traceback.pyi index dca5f480c3ba..9c52f2b3b897 100644 --- a/stdlib/traceback.pyi +++ b/stdlib/traceback.pyi @@ -3,16 +3,16 @@ from _typeshed import SupportsWrite from types import FrameType, TracebackType from typing import IO, Any, Dict, Generator, Iterable, Iterator, List, Mapping, Optional, Set, Tuple, Type -_PT = Tuple[str, int, str, Optional[str]] +_PT = Tuple[str, int, str, str | None] -def print_tb(tb: Optional[TracebackType], limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... +def print_tb(tb: TracebackType | None, limit: int | None = ..., file: Optional[IO[str]] = ...) -> None: ... if sys.version_info >= (3, 10): def print_exception( __exc: Optional[Type[BaseException]], - value: Optional[BaseException] = ..., - tb: Optional[TracebackType] = ..., - limit: Optional[int] = ..., + value: BaseException | None = ..., + tb: TracebackType | None = ..., + limit: int | None = ..., file: Optional[IO[str]] = ..., chain: bool = ..., ) -> None: ... @@ -20,53 +20,53 @@ if sys.version_info >= (3, 10): else: def print_exception( etype: Optional[Type[BaseException]], - value: Optional[BaseException], - tb: Optional[TracebackType], - limit: Optional[int] = ..., + value: BaseException | None, + tb: TracebackType | None, + limit: int | None = ..., file: Optional[IO[str]] = ..., 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: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... +def print_last(limit: int | None = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... +def print_stack(f: FrameType | None = ..., limit: int | None = ..., file: Optional[IO[str]] = ...) -> 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: ... if sys.version_info >= (3, 10): - def format_exception_only(__exc: Optional[Type[BaseException]], value: Optional[BaseException] = ...) -> List[str]: ... + def format_exception_only(__exc: Optional[Type[BaseException]], value: BaseException | None = ...) -> List[str]: ... else: - def format_exception_only(etype: Optional[Type[BaseException]], value: Optional[BaseException]) -> List[str]: ... + def format_exception_only(etype: Optional[Type[BaseException]], 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] = ..., + 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] = ..., + 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,7 +86,7 @@ class TracebackException: exc_value: BaseException, exc_traceback: TracebackType, *, - limit: Optional[int] = ..., + limit: int | None = ..., lookup_lines: bool = ..., capture_locals: bool = ..., compact: bool = ..., @@ -97,7 +97,7 @@ class TracebackException: 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]] = ..., ) -> 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]: ... @@ -135,7 +135,7 @@ class FrameSummary(Iterable[Any]): *, lookup_line: bool = ..., locals: Optional[Mapping[str, str]] = ..., - line: Optional[str] = ..., + 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 7ef1d4eb0500..53cb4b52984b 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: @@ -48,7 +48,7 @@ class Frame: def __init__(self, frame: _FrameTupleT) -> None: ... if sys.version_info >= (3, 9): - _TraceTupleT = Union[Tuple[int, int, Sequence[_FrameTupleT], Optional[int]], Tuple[int, int, Sequence[_FrameTupleT]]] + _TraceTupleT = Union[Tuple[int, int, Sequence[_FrameTupleT], int | None], Tuple[int, int, Sequence[_FrameTupleT]]] else: _TraceTupleT = Tuple[int, int, Sequence[_FrameTupleT]] @@ -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 diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index da4ba1ca15e3..805bb424a064 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: _PolygonCoords | PhotoImage | None = ...) -> None: ... - def addcomponent(self, poly: _PolygonCoords, fill: _Color, outline: Optional[_Color] = ...) -> 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: ... @@ -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): @@ -130,7 +130,7 @@ class TNavigator(object): 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 = ..., @@ -215,7 +215,7 @@ class RawTurtle(TPen, TNavigator): 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: ... @@ -253,21 +253,21 @@ class RawTurtle(TPen, TNavigator): # we return Any. def stamp(self) -> Any: ... def clearstamp(self, stampid: int | Tuple[int, ...]) -> None: ... - def clearstamps(self, n: Optional[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 @@ -278,8 +278,8 @@ class _Screen(TurtleScreen): self, width: int | float = ..., height: int | float = ..., - startx: Optional[int] = ..., - starty: Optional[int] = ..., + 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: @@ -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: ... @@ -404,7 +404,7 @@ def towards(x: TNavigator | Tuple[float, float], y: None = ...) -> float: ... 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: ... @@ -522,22 +522,22 @@ def tilt(angle: float) -> None: ... # we return Any. def stamp() -> Any: ... def clearstamp(stampid: int | Tuple[int, ...]) -> None: ... -def clearstamps(n: Optional[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 dec474fd3db7..9ef93dd5cfbd 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -154,10 +154,10 @@ 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: ... class GeneratorType(Generator[_T_co, _T_contra, _V_co]): gi_code: CodeType @@ -170,10 +170,10 @@ class GeneratorType(Generator[_T_co, _T_contra, _V_co]): def send(self, __arg: _T_contra) -> _T_co: ... @overload def throw( - self, __typ: Type[BaseException], __val: typing.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: ... class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]): ag_await: Optional[Awaitable[Any]] @@ -185,14 +185,14 @@ 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: 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]: ... class CoroutineType: - cr_await: Optional[Any] + cr_await: Any | None cr_code: CodeType cr_frame: FrameType cr_running: bool @@ -200,10 +200,10 @@ class CoroutineType: def send(self, __arg: Any) -> Any: ... @overload def throw( - self, __typ: Type[BaseException], __val: typing.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__. @@ -219,7 +219,7 @@ 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: ... class MethodType: __func__: _StaticFunctionType @@ -267,11 +267,11 @@ if sys.version_info >= (3, 7): 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: ... @@ -281,7 +281,7 @@ class TracebackType: def tb_lineno(self) -> int: ... class FrameType: - f_back: Optional[FrameType] + f_back: FrameType | None f_builtins: Dict[str, Any] f_code: CodeType f_globals: Dict[str, Any] diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index adb31f4a32d5..53b616a6b3d4 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -203,11 +203,11 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]): @overload @abstractmethod def throw( - self, __typ: Type[BaseException], __val: 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 @@ -228,7 +228,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 @@ -240,11 +240,11 @@ class Coroutine(Awaitable[_V_co], Generic[_T_co, _T_contra, _V_co]): @overload @abstractmethod def throw( - self, __typ: Type[BaseException], __val: 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: ... @@ -273,11 +273,11 @@ class AsyncGenerator(AsyncIterator[_T_co], Generic[_T_co, _T_contra]): @overload @abstractmethod def athrow( - self, __typ: Type[BaseException], __val: 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 @@ -423,16 +423,16 @@ class ContextManager(Protocol[_T_co]): def __exit__( self, __exc_type: Optional[Type[BaseException]], - __exc_value: Optional[BaseException], - __traceback: Optional[TracebackType], - ) -> Optional[bool]: ... + __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: Optional[Type[BaseException]], 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, @@ -441,7 +441,7 @@ 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: _VT_co | _T) -> _VT_co | _T: ... def items(self) -> AbstractSet[Tuple[_KT, _VT_co]]: ... @@ -513,7 +513,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 @@ -528,8 +528,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: Optional[Type[BaseException]], value: BaseException | None, traceback: TracebackType | None + ) -> bool | None: ... class BinaryIO(IO[bytes]): @abstractmethod @@ -542,7 +542,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 @@ -555,8 +555,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 @@ -635,7 +635,7 @@ else: ) -> 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 @@ -689,10 +689,10 @@ 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 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: Optional[Dict[str, Any]], localns: Optional[Dict[str, Any]]) -> 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 29f285132e0d..573d2706a0c7 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -81,7 +81,7 @@ def get_type_hints( 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 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 d29a1c460fbe..9dc264859ca3 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -47,7 +47,7 @@ class SkipTest(Exception): class TestCase: failureException: Type[BaseException] longMessage: bool - maxDiff: Optional[int] + maxDiff: int | None # undocumented _testMethodName: str # undocumented @@ -59,8 +59,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: ... @@ -138,35 +138,35 @@ class TestCase: msg: Any = ..., ) -> _AssertWarnsContext: ... def assertLogs( - self, logger: Optional[str | logging.Logger] = ..., level: 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: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ... def assertNotRegex(self, text: AnyStr, unexpected_regex: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ... @@ -184,7 +184,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: @@ -195,7 +195,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: ... @@ -247,7 +247,7 @@ class FunctionTestCase(TestCase): testFunc: Callable[[], None], setUp: Optional[Callable[[], None]] = ..., tearDown: Optional[Callable[[], None]] = ..., - description: Optional[str] = ..., + description: str | None = ..., ) -> None: ... def runTest(self) -> None: ... @@ -255,7 +255,7 @@ class _AssertRaisesContext(Generic[_E]): exception: _E def __enter__(self) -> _AssertRaisesContext[_E]: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -267,7 +267,7 @@ class _AssertWarnsContext: warnings: List[WarningMessage] def __enter__(self) -> _AssertWarnsContext: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... class _AssertLogsContext: @@ -277,5 +277,5 @@ class _AssertLogsContext: def __init__(self, test_case: TestCase, logger_name: str, level: int) -> None: ... def __enter__(self) -> _AssertLogsContext: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... diff --git a/stdlib/unittest/loader.pyi b/stdlib/unittest/loader.pyi index 48c9f1c5f100..ca7ba16713fa 100644 --- a/stdlib/unittest/loader.pyi +++ b/stdlib/unittest/loader.pyi @@ -19,10 +19,10 @@ class TestLoader: 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 diff --git a/stdlib/unittest/main.pyi b/stdlib/unittest/main.pyi index 59e9463ae325..519660833560 100644 --- a/stdlib/unittest/main.pyi +++ b/stdlib/unittest/main.pyi @@ -14,11 +14,11 @@ class TestProgram: result: unittest.result.TestResult 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]] @@ -31,17 +31,17 @@ class TestProgram: 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 c95886a46282..ee57f4a18a55 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 @@ -77,15 +77,15 @@ class NonCallableMock(Base, Any): # type: ignore def __init__( self, spec: Union[List[str], object, Type[object], None] = ..., - wraps: Optional[Any] = ..., - name: Optional[str] = ..., + wraps: Any | None = ..., + name: str | None = ..., spec_set: Union[List[str], object, Type[object], None] = ..., - parent: Optional[NonCallableMock] = ..., - _spec_state: Optional[Any] = ..., + 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,11 +224,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 | AsyncMock]: ... else: @@ -237,11 +237,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 @@ -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,11 +276,11 @@ 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 | AsyncMock]: ... else: @@ -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 3c8991c08786..0cf589297a35 100644 --- a/stdlib/unittest/runner.pyi +++ b/stdlib/unittest/runner.pyi @@ -21,12 +21,12 @@ 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] = ..., + resultclass: _ResultClassType | None = ..., warnings: Optional[Type[Warning]] = ..., *, tb_locals: bool = ..., diff --git a/stdlib/urllib/error.pyi b/stdlib/urllib/error.pyi index 18f4109d4fa7..65ea3812dfb5 100644 --- a/stdlib/urllib/error.pyi +++ b/stdlib/urllib/error.pyi @@ -6,7 +6,7 @@ from urllib.response import addinfourl class URLError(IOError): reason: str | BaseException - def __init__(self, reason: str | BaseException, filename: Optional[str] = ...) -> None: ... + def __init__(self, reason: str | BaseException, filename: str | None = ...) -> None: ... class HTTPError(URLError, addinfourl): code: int diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 242022e4957c..2a095ba35511 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,7 +112,7 @@ 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]]]], doseq: bool = ..., @@ -121,24 +121,24 @@ def urlencode( 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 c37480c116e1..2b8b20a100a5 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -29,13 +29,13 @@ _UrlopenRet = Any def urlopen( url: str | Request, - data: Optional[bytes] = ..., - timeout: Optional[float] = ..., + 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: ... @@ -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,7 +90,7 @@ 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) -> str | _T: ... def header_items(self) -> List[Tuple[str, str]]: ... @@ -99,7 +99,7 @@ class Request: class OpenerDirector: addheaders: List[Tuple[str, str]] def add_handler(self, handler: BaseHandler) -> None: ... - def open(self, fullurl: 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,23 +120,23 @@ class HTTPRedirectHandler(BaseHandler): inf_msg: ClassVar[str] # undocumented def redirect_request( self, req: Request, fp: IO[str], code: int, msg: str, headers: Mapping[str, str], newurl: str - ) -> Optional[Request]: ... + ) -> Request | None: ... def http_error_301( self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str] - ) -> Optional[_UrlopenRet]: ... + ) -> _UrlopenRet | None: ... def http_error_302( self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str] - ) -> Optional[_UrlopenRet]: ... + ) -> _UrlopenRet | None: ... def http_error_303( self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str] - ) -> Optional[_UrlopenRet]: ... + ) -> _UrlopenRet | None: ... def http_error_307( self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str] - ) -> Optional[_UrlopenRet]: ... + ) -> _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 @@ -144,22 +144,22 @@ class HTTPCookieProcessor(BaseHandler): 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 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: str | Sequence[str], user: str, passwd: str) -> None: ... - def find_user_password(self, realm: str, authuri: str) -> Tuple[Optional[str], Optional[str]]: ... + 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: 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: 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: str | Sequence[str], is_authenticated: bool = ...) -> None: ... def is_authenticated(self, authuri: str) -> bool: ... @@ -168,47 +168,47 @@ class AbstractBasicAuthHandler: rx: ClassVar[Pattern[str]] # undocumented passwd: HTTPPasswordMgr add_password: Callable[[str, str | Sequence[str], str, str], None] - def __init__(self, password_mgr: Optional[HTTPPasswordMgr] = ...) -> None: ... + def __init__(self, password_mgr: HTTPPasswordMgr | None = ...) -> None: ... def http_error_auth_reqed(self, authreq: str, host: str, req: Request, headers: Mapping[str, str]) -> 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[str], code: int, msg: int, headers: Mapping[str, str] - ) -> Optional[_UrlopenRet]: ... + ) -> _UrlopenRet | None: ... class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler): auth_header: ClassVar[str] def http_error_407( self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str] - ) -> Optional[_UrlopenRet]: ... + ) -> _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: Mapping[str, str]) -> 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[str], code: int, msg: int, headers: Mapping[str, str] - ) -> Optional[_UrlopenRet]: ... + ) -> _UrlopenRet | None: ... class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler): auth_header: ClassVar[str] # undocumented def http_error_407( self, req: Request, fp: IO[str], code: int, msg: int, headers: Mapping[str, str] - ) -> Optional[_UrlopenRet]: ... + ) -> _UrlopenRet | None: ... class AbstractHTTPHandler(BaseHandler): # undocumented def __init__(self, debuglevel: int = ...) -> None: ... @@ -222,7 +222,7 @@ 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 @@ -238,7 +238,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: ... @@ -271,56 +271,56 @@ class HTTPErrorProcessor(BaseHandler): def urlretrieve( url: str, - filename: Optional[StrOrBytesPath] = ..., + filename: StrOrBytesPath | None = ..., reporthook: Optional[Callable[[int, int, int], None]] = ..., - data: Optional[bytes] = ..., + 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 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] = ..., + filename: str | None = ..., reporthook: Optional[Callable[[int, int, int], None]] = ..., - data: Optional[bytes] = ..., - ) -> Tuple[str, Optional[Message]]: ... + 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: Mapping[str, str], data: Optional[bytes] = ... + self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: Mapping[str, str], data: bytes | None = ... ) -> _UrlopenRet: ... # undocumented def http_error_default( self, url: str, fp: IO[bytes], errcode: int, errmsg: str, headers: Mapping[str, str] ) -> _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[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: Optional[bytes] = ... - ) -> Optional[_UrlopenRet | addinfourl]: ... # undocumented + self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: bytes | None = ... + ) -> _UrlopenRet | addinfourl | None: ... # undocumented def http_error_302( - self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: Optional[bytes] = ... - ) -> Optional[_UrlopenRet | addinfourl]: ... # undocumented + self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: bytes | None = ... + ) -> _UrlopenRet | addinfourl | None: ... # undocumented def http_error_303( - self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: Optional[bytes] = ... - ) -> Optional[_UrlopenRet | addinfourl]: ... # undocumented + self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: bytes | None = ... + ) -> _UrlopenRet | addinfourl | None: ... # undocumented def http_error_307( - self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: Optional[bytes] = ... - ) -> Optional[_UrlopenRet | addinfourl]: ... # undocumented + self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: bytes | None = ... + ) -> _UrlopenRet | addinfourl | None: ... # undocumented def http_error_401( self, url: str, @@ -328,9 +328,9 @@ class FancyURLopener(URLopener): errcode: int, errmsg: str, headers: Mapping[str, str], - data: Optional[bytes] = ..., + data: bytes | None = ..., retry: bool = ..., - ) -> Optional[_UrlopenRet]: ... # undocumented + ) -> _UrlopenRet | None: ... # undocumented def http_error_407( self, url: str, @@ -338,24 +338,24 @@ class FancyURLopener(URLopener): errcode: int, errmsg: str, headers: Mapping[str, str], - 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: Mapping[str, str] ) -> addinfourl: ... # undocumented def redirect_internal( - self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], data: Optional[bytes] - ) -> Optional[_UrlopenRet]: ... # undocumented + self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, str], 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 c8f9d75d2f14..1f19f3eeb27f 100644 --- a/stdlib/urllib/response.pyi +++ b/stdlib/urllib/response.pyi @@ -9,7 +9,7 @@ class addbase(BinaryIO): def __init__(self, fp: IO[bytes]) -> None: ... def __enter__(self: _AIUT) -> _AIUT: ... def __exit__( - self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType] + self, type: Optional[Type[BaseException]], value: BaseException | None, traceback: TracebackType | None ) -> None: ... def __iter__(self: _AIUT) -> _AIUT: ... def __next__(self) -> bytes: ... @@ -28,7 +28,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: ... @@ -46,6 +46,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..a2f16edeb129 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]]: ... diff --git a/stdlib/uu.pyi b/stdlib/uu.pyi index 9304720ada09..58f285f3d27c 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..c1f5e285533e 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: ... diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index aaa61c5645dc..fded0f5a3c3e 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -9,11 +9,11 @@ def showwarning( category: Type[Warning], filename: str, lineno: int, - file: Optional[TextIO] = ..., - line: Optional[str] = ..., + file: TextIO | None = ..., + line: str | None = ..., ) -> None: ... def formatwarning( - message: 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 = ... @@ -28,30 +28,30 @@ class WarningMessage: 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: 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 __new__(cls, *, record: bool, module: ModuleType | None = ...) -> catch_warnings: ... def __enter__(self) -> Optional[List[WarningMessage]]: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], 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 36db3203ea88..c25d5de00718 100644 --- a/stdlib/wave.pyi +++ b/stdlib/wave.pyi @@ -19,7 +19,7 @@ class Wave_read: def __init__(self, f: _File) -> None: ... def __enter__(self) -> Wave_read: ... 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: ... @@ -62,7 +62,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..674201de85af 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -37,7 +37,7 @@ 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 __call__(self) -> types.MethodType | None: ... class WeakValueDictionary(MutableMapping[_KT, _VT]): @overload @@ -86,7 +86,7 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]): class finalize: def __init__(self, __obj: object, __func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... - def __call__(self, _: Any = ...) -> Optional[Any]: ... + def __call__(self, _: Any = ...) -> Any | None: ... def detach(self) -> Optional[Tuple[Any, Any, Tuple[Any, ...], Dict[str, Any]]]: ... def peek(self) -> Optional[Tuple[Any, Any, Tuple[Any, ...], Dict[str, Any]]]: ... alive: bool diff --git a/stdlib/webbrowser.pyi b/stdlib/webbrowser.pyi index 2131ca479646..924a8b6e7d7b 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: Optional[Callable[[], BaseBrowser]], instance: BaseBrowser | None = ..., *, preferred: bool = ... ) -> None: ... else: def register( - name: str, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., update_tryorder: int = ... + name: str, klass: Optional[Callable[[], BaseBrowser]], 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: ... diff --git a/stdlib/winreg.pyi b/stdlib/winreg.pyi index 192f55f1a2b7..05b19a8f13aa 100644 --- a/stdlib/winreg.pyi +++ b/stdlib/winreg.pyi @@ -4,9 +4,9 @@ from typing import Any, Optional, Tuple, Type, Union _KeyType = 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: ... @@ -18,12 +18,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: 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: ... @@ -92,7 +92,7 @@ class HKEYType: def __int__(self) -> int: ... def __enter__(self) -> HKEYType: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Optional[Type[BaseException]], 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 d6e72ac78d44..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[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..3c1a822092e6 100644 --- a/stdlib/wsgiref/handlers.pyi +++ b/stdlib/wsgiref/handlers.pyi @@ -6,9 +6,9 @@ from .headers import Headers from .types import ErrorStream, InputStream, StartResponse, WSGIApplication, WSGIEnvironment from .util import FileWrapper -_exc_info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_exc_info = Tuple[Optional[Type[BaseException]], BaseException | None, TracebackType | None] -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]] 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..2bd58e5e3d2a 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: Union[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 d31dc70f146f..7fa026f65535 100644 --- a/stdlib/xml/dom/minidom.pyi +++ b/stdlib/xml/dom/minidom.pyi @@ -6,25 +6,25 @@ from xml.sax.xmlreader import XMLReader _T = TypeVar("_T") -def parse(file: str | IO[Any], parser: Optional[XMLReader] = ..., bufsize: Optional[int] = ...): ... -def parseString(string: 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): ... @@ -57,14 +57,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: ... @@ -77,7 +77,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: ... @@ -108,11 +108,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): ... @@ -302,11 +302,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/etree/ElementInclude.pyi b/stdlib/xml/etree/ElementInclude.pyi index 0ff95a9aad8b..09842ba4146f 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: str | bytes | int, parse: str, encoding: Optional[str] = ...) -> 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 @@ -17,8 +17,8 @@ if sys.version_info >= (3, 9): def include( elem: Element, loader: Optional[Callable[..., str | Element]] = ..., - base_url: Optional[str] = ..., - max_depth: Optional[int] = ..., + 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 6e0674cb6e55..f73c4afb6a14 100644 --- a/stdlib/xml/etree/ElementPath.pyi +++ b/stdlib/xml/etree/ElementPath.pyi @@ -26,8 +26,8 @@ class _SelectorContext: _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 find(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) -> Element | None: ... def findall(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) -> List[Element]: ... def findtext( - elem: Element, path: str, default: Optional[_T] = ..., namespaces: Optional[Dict[str, str]] = ... + elem: Element, path: str, default: _T | None = ..., namespaces: Optional[Dict[str, str]] = ... ) -> _T | str: ... diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index 04494913a897..eb1c8edff5a0 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -35,10 +35,10 @@ def iselement(element: object) -> bool: ... if sys.version_info >= (3, 8): @overload def canonicalize( - xml_data: Optional[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 = ..., @@ -49,10 +49,10 @@ if sys.version_info >= (3, 8): ) -> str: ... @overload def canonicalize( - xml_data: Optional[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 = ..., @@ -65,25 +65,25 @@ if sys.version_info >= (3, 8): class Element(MutableSequence[Element]): tag: str attrib: Dict[str, str] - text: Optional[str] - tail: Optional[str] + 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 find(self, path: str, namespaces: Optional[Dict[str, str]] = ...) -> Element | None: ... def findall(self, path: str, namespaces: Optional[Dict[str, str]] = ...) -> 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: Optional[Dict[str, str]] = ...) -> str | None: ... @overload def findtext(self, path: str, default: _T, namespaces: Optional[Dict[str, str]] = ...) -> _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) -> 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 iter(self, tag: str | None = ...) -> Generator[Element, None, None]: ... def iterfind(self, path: str, namespaces: Optional[Dict[str, str]] = ...) -> Generator[Element, None, None]: ... def itertext(self) -> Generator[str, None, None]: ... def keys(self) -> KeysView[str]: ... @@ -102,28 +102,28 @@ 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: Optional[Dict[str, str]] = ...) -> 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: Optional[Dict[str, str]] = ...) -> str | None: ... @overload def findtext(self, path: str, default: _T, namespaces: Optional[Dict[str, str]] = ...) -> _T | str: ... def findall(self, path: str, namespaces: Optional[Dict[str, str]] = ...) -> List[Element]: ... @@ -131,10 +131,10 @@ class ElementTree: 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,85 +147,85 @@ 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: ... @@ -233,24 +233,24 @@ def dump(elem: Element) -> None: ... if sys.version_info >= (3, 9): 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: Optional[Sequence[str]] = ..., parser: XMLParser | None = ... ) -> Iterator[Tuple[str, Any]]: ... class XMLPullParser: - def __init__(self, events: Optional[Sequence[str]] = ..., *, _parser: Optional[XMLParser] = ...) -> None: ... + def __init__(self, events: Optional[Sequence[str]] = ..., *, _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: str | bytes, parser: Optional[XMLParser] = ...) -> Element: ... -def XMLID(text: 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[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,7 +264,7 @@ def fromstringlist(sequence: Sequence[str | bytes], parser: Optional[XMLParser] _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: str | bytes) -> None: ... def start(self, __tag: str | bytes, __attrs: Dict[str | bytes, str | bytes]) -> Element: ... @@ -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: str | bytes) -> None: ... diff --git a/stdlib/xml/sax/__init__.pyi b/stdlib/xml/sax/__init__.pyi index 3559b2efcb91..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: ... @@ -29,5 +29,5 @@ else: def make_parser(parser_list: List[str] = ...) -> XMLReader: ... def parse(source: str | IO[str] | IO[bytes], handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ... -def parseString(string: bytes | str, handler: ContentHandler, errorHandler: Optional[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..aae27a9688fc 100644 --- a/stdlib/xml/sax/saxutils.pyi +++ b/stdlib/xml/sax/saxutils.pyi @@ -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 0321ba56d8b1..704929ed7305 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -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: ... @@ -101,9 +101,9 @@ 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 __init__(self, encoding: str | None = ..., allow_none: bool = ...) -> None: ... def dumps(self, values: Fault | Iterable[_Marshallable]) -> str: ... def __dump(self, value: Union[_Marshallable], write: Callable[[str], Any]) -> None: ... # undocumented def dump_nil(self, value: None, 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: Fault | Tuple[_Marshallable, ...], - methodname: Optional[str] = ..., - methodresponse: Optional[bool] = ..., - encoding: Optional[str] = ..., + 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 @@ -303,7 +303,7 @@ class ServerProxy: def __call__(self, attr: str) -> Union[Callable[[], None], Transport]: ... def __enter__(self) -> ServerProxy: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], 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 abc5b491c758..b1a2e7f2b2e9 100644 --- a/stdlib/xmlrpc/server.pyi +++ b/stdlib/xmlrpc/server.pyi @@ -39,27 +39,27 @@ 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, ...]], Fault | Tuple[_Marshallable, ...]] + Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] ] = ..., - path: Optional[Any] = ..., + path: Any | None = ..., ) -> str: ... # undocumented def system_listMethods(self) -> List[str]: ... # undocumented def system_methodSignature(self, method_name: str) -> str: ... # undocumented @@ -75,7 +75,7 @@ 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: int | str = ..., size: int | str = ...) -> None: ... @@ -89,7 +89,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 +105,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: ... @@ -115,19 +115,19 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented self, data: str, dispatch_method: Optional[ - Callable[[Optional[str], Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] + Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] ] = ..., - path: Optional[Any] = ..., + 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 +151,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 40fad41dcd83..06f62f992f63 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] = ..., + target: _Path | None = ..., + interpreter: str | None = ..., + main: str | None = ..., filter: Optional[Callable[[Path], bool]] = ..., 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 14435fc7e5ff..9e1b2eafa911 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -37,7 +37,7 @@ class ZipExtFile(io.BufferedIOBase): 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__( @@ -45,7 +45,7 @@ class ZipExtFile(io.BufferedIOBase): fileobj: _ClosableZipStream, mode: str, zipinfo: ZipInfo, - pwd: Optional[bytes] = ..., + pwd: bytes | None = ..., *, close_fileobj: Literal[True], ) -> None: ... @@ -55,7 +55,7 @@ class ZipExtFile(io.BufferedIOBase): fileobj: _ZipStream, mode: str, zipinfo: ZipInfo, - pwd: Optional[bytes] = ..., + pwd: bytes | None = ..., close_fileobj: Literal[False] = ..., ) -> None: ... else: @@ -87,17 +87,17 @@ class ZipExtFile(io.BufferedIOBase): decrypter: Optional[Callable[[Sequence[int]], bytes]] = ..., 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] @@ -111,7 +111,7 @@ class ZipFile: mode: str = ..., compression: int = ..., allowZip64: bool = ..., - compresslevel: Optional[int] = ..., + compresslevel: int | None = ..., *, strict_timestamps: bool = ..., ) -> None: ... @@ -122,7 +122,7 @@ class ZipFile: mode: str = ..., compression: int = ..., allowZip64: bool = ..., - compresslevel: Optional[int] = ..., + compresslevel: int | None = ..., ) -> None: ... else: def __init__( @@ -130,44 +130,44 @@ class ZipFile: ) -> None: ... def __enter__(self) -> ZipFile: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Optional[Type[BaseException]], 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: str | ZipInfo, mode: str = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ... + self, name: str | ZipInfo, mode: str = ..., pwd: bytes | None = ..., *, force_zip64: bool = ... ) -> IO[bytes]: ... - def extract(self, member: 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: Optional[Iterable[str]] = ..., 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: 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: str | ZipInfo, data: bytes | str, - compress_type: Optional[int] = ..., - compresslevel: Optional[int] = ..., + compress_type: int | None = ..., + compresslevel: int | None = ..., ) -> None: ... else: def writestr( - self, zinfo_or_arcname: str | ZipInfo, data: bytes | str, compress_type: Optional[int] = ... + self, zinfo_or_arcname: str | ZipInfo, data: bytes | str, compress_type: int | None = ... ) -> None: ... class PyZipFile(ZipFile): @@ -194,18 +194,18 @@ class ZipInfo: CRC: int compress_size: int file_size: int - def __init__(self, filename: Optional[str] = ..., date_time: Optional[_DateTuple] = ...) -> None: ... + def __init__(self, filename: str | None = ..., date_time: _DateTuple | None = ...) -> 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: @@ -215,7 +215,7 @@ if sys.version_info >= (3, 8): def parent(self) -> Path: ... # undocumented 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: ... @@ -225,9 +225,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: ... diff --git a/stdlib/zipimport.pyi b/stdlib/zipimport.pyi index aa4c5a0b0d4e..323f23476dc1 100644 --- a/stdlib/zipimport.pyi +++ b/stdlib/zipimport.pyi @@ -13,14 +13,14 @@ class zipimporter(object): prefix: str 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 ffcfeaccac5e..57f8f06412f6 100644 --- a/stdlib/zlib.pyi +++ b/stdlib/zlib.pyi @@ -38,7 +38,7 @@ 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: array[Any] | bytes, __value: int = ...) -> int: ... def decompress(__data: bytes, wbits: int = ..., bufsize: int = ...) -> bytes: ... diff --git a/stdlib/zoneinfo/__init__.pyi b/stdlib/zoneinfo/__init__.pyi index 35bd142b8017..8b056b2c9e19 100644 --- a/stdlib/zoneinfo/__init__.pyi +++ b/stdlib/zoneinfo/__init__.pyi @@ -16,7 +16,7 @@ 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: ... From 35fc69df4a08a6839f64a609def9d045058df4bd Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:41:53 -0700 Subject: [PATCH 07/16] fastmod -d stdlib --accept-all '\bOptional\[([\w\.\| ]+)\[([^\[\]]+)\]\]' '$1[$2] | None' --- stdlib/@python2/ConfigParser.pyi | 4 +- stdlib/@python2/SimpleHTTPServer.pyi | 4 +- stdlib/@python2/SocketServer.pyi | 2 +- stdlib/@python2/__builtin__.pyi | 22 ++-- stdlib/@python2/_dummy_threading.pyi | 14 +- stdlib/@python2/_io.pyi | 4 +- stdlib/@python2/_thread.pyi | 2 +- stdlib/@python2/_warnings.pyi | 6 +- stdlib/@python2/_weakrefset.pyi | 2 +- stdlib/@python2/_winreg.pyi | 2 +- stdlib/@python2/aifc.pyi | 4 +- stdlib/@python2/argparse.pyi | 34 ++--- stdlib/@python2/asyncore.pyi | 2 +- stdlib/@python2/bdb.pyi | 12 +- stdlib/@python2/builtins.pyi | 22 ++-- stdlib/@python2/cgi.pyi | 8 +- stdlib/@python2/cgitb.pyi | 6 +- stdlib/@python2/cmd.pyi | 10 +- stdlib/@python2/code.pyi | 6 +- stdlib/@python2/codecs.pyi | 8 +- stdlib/@python2/compileall.pyi | 4 +- stdlib/@python2/contextlib.pyi | 4 +- stdlib/@python2/copy.pyi | 2 +- stdlib/@python2/csv.pyi | 4 +- stdlib/@python2/ctypes/__init__.pyi | 14 +- stdlib/@python2/dbm/__init__.pyi | 2 +- stdlib/@python2/dbm/dumb.pyi | 2 +- stdlib/@python2/dbm/gnu.pyi | 2 +- stdlib/@python2/dbm/ndbm.pyi | 2 +- stdlib/@python2/decimal.pyi | 4 +- stdlib/@python2/distutils/ccompiler.pyi | 70 +++++----- stdlib/@python2/distutils/command/config.pyi | 50 +++---- stdlib/@python2/distutils/core.pyi | 2 +- stdlib/@python2/distutils/dist.pyi | 4 +- stdlib/@python2/distutils/fancy_getopt.pyi | 8 +- stdlib/@python2/distutils/text_file.pyi | 2 +- stdlib/@python2/distutils/version.pyi | 2 +- stdlib/@python2/doctest.pyi | 24 ++-- stdlib/@python2/filecmp.pyi | 2 +- stdlib/@python2/formatter.pyi | 2 +- stdlib/@python2/ftplib.pyi | 2 +- stdlib/@python2/gettext.pyi | 8 +- stdlib/@python2/imaplib.pyi | 2 +- stdlib/@python2/inspect.pyi | 4 +- stdlib/@python2/json.pyi | 12 +- stdlib/@python2/lib2to3/pgen2/pgen.pyi | 2 +- stdlib/@python2/lib2to3/pytree.pyi | 4 +- stdlib/@python2/logging/__init__.pyi | 48 +++---- stdlib/@python2/logging/config.pyi | 2 +- stdlib/@python2/logging/handlers.pyi | 2 +- stdlib/@python2/mailbox.pyi | 4 +- stdlib/@python2/mimetypes.pyi | 4 +- stdlib/@python2/modulefinder.pyi | 6 +- stdlib/@python2/msilib/__init__.pyi | 2 +- stdlib/@python2/multiprocessing/__init__.pyi | 2 +- .../multiprocessing/dummy/connection.pyi | 2 +- stdlib/@python2/multiprocessing/pool.pyi | 8 +- stdlib/@python2/optparse.pyi | 22 ++-- stdlib/@python2/os/__init__.pyi | 2 +- stdlib/@python2/pdb.pyi | 12 +- stdlib/@python2/pickle.pyi | 4 +- stdlib/@python2/pickletools.pyi | 4 +- stdlib/@python2/pkgutil.pyi | 4 +- stdlib/@python2/posix.pyi | 2 +- stdlib/@python2/pprint.pyi | 4 +- stdlib/@python2/pstats.pyi | 2 +- stdlib/@python2/py_compile.pyi | 2 +- stdlib/@python2/pyclbr.pyi | 8 +- stdlib/@python2/pydoc.pyi | 14 +- stdlib/@python2/pyexpat/__init__.pyi | 2 +- stdlib/@python2/re.pyi | 8 +- stdlib/@python2/rlcompleter.pyi | 2 +- stdlib/@python2/select.pyi | 2 +- stdlib/@python2/sets.pyi | 4 +- stdlib/@python2/site.pyi | 4 +- stdlib/@python2/socket.pyi | 2 +- stdlib/@python2/sqlite3/dbapi2.pyi | 2 +- stdlib/@python2/ssl.pyi | 4 +- stdlib/@python2/stringold.pyi | 2 +- stdlib/@python2/subprocess.pyi | 6 +- stdlib/@python2/sunau.pyi | 2 +- stdlib/@python2/symtable.pyi | 2 +- stdlib/@python2/sysconfig.pyi | 6 +- stdlib/@python2/tarfile.pyi | 56 ++++---- stdlib/@python2/telnetlib.pyi | 2 +- stdlib/@python2/threading.pyi | 14 +- stdlib/@python2/timeit.pyi | 4 +- stdlib/@python2/trace.pyi | 6 +- stdlib/@python2/traceback.pyi | 16 +-- stdlib/@python2/types.pyi | 10 +- stdlib/@python2/typing.pyi | 14 +- stdlib/@python2/typing_extensions.pyi | 6 +- stdlib/@python2/unittest.pyi | 4 +- stdlib/@python2/urllib2.pyi | 2 +- stdlib/@python2/warnings.pyi | 4 +- stdlib/@python2/webbrowser.pyi | 2 +- stdlib/@python2/wsgiref/handlers.pyi | 4 +- stdlib/@python2/xml/etree/ElementInclude.pyi | 2 +- stdlib/@python2/xml/etree/ElementPath.pyi | 12 +- stdlib/@python2/xml/etree/ElementTree.pyi | 22 ++-- stdlib/@python2/xmlrpclib.pyi | 2 +- stdlib/@python2/zipfile.pyi | 8 +- stdlib/_dummy_threading.pyi | 18 +-- stdlib/_json.pyi | 2 +- stdlib/_thread.pyi | 2 +- stdlib/_tracemalloc.pyi | 2 +- stdlib/_typeshed/tkinter.pyi | 2 +- stdlib/_warnings.pyi | 6 +- stdlib/_weakrefset.pyi | 2 +- stdlib/aifc.pyi | 8 +- stdlib/argparse.pyi | 44 +++---- stdlib/asyncio/base_events.pyi | 16 +-- stdlib/asyncio/base_subprocess.pyi | 8 +- stdlib/asyncio/events.pyi | 14 +- stdlib/asyncio/format_helpers.pyi | 2 +- stdlib/asyncio/locks.pyi | 4 +- stdlib/asyncio/proactor_events.pyi | 22 ++-- stdlib/asyncio/streams.pyi | 2 +- stdlib/asyncio/tasks.pyi | 6 +- stdlib/asyncio/transports.pyi | 4 +- stdlib/asyncio/trsock.pyi | 2 +- stdlib/asyncio/unix_events.pyi | 4 +- stdlib/asyncore.pyi | 2 +- stdlib/bdb.pyi | 12 +- stdlib/builtins.pyi | 24 ++-- stdlib/cgi.pyi | 12 +- stdlib/cgitb.pyi | 6 +- stdlib/cmd.pyi | 10 +- stdlib/code.pyi | 6 +- stdlib/codecs.pyi | 8 +- stdlib/collections/__init__.pyi | 8 +- stdlib/concurrent/futures/process.pyi | 2 +- stdlib/concurrent/futures/thread.pyi | 2 +- stdlib/configparser.pyi | 6 +- stdlib/contextlib.pyi | 12 +- stdlib/copy.pyi | 2 +- stdlib/csv.pyi | 4 +- stdlib/ctypes/__init__.pyi | 14 +- stdlib/dataclasses.pyi | 16 +-- stdlib/dbm/__init__.pyi | 2 +- stdlib/dbm/dumb.pyi | 2 +- stdlib/dbm/gnu.pyi | 2 +- stdlib/dbm/ndbm.pyi | 2 +- stdlib/decimal.pyi | 4 +- stdlib/dis.pyi | 12 +- stdlib/distutils/ccompiler.pyi | 70 +++++----- stdlib/distutils/command/config.pyi | 50 +++---- stdlib/distutils/core.pyi | 2 +- stdlib/distutils/dist.pyi | 16 +-- stdlib/distutils/extension.pyi | 20 +-- stdlib/distutils/fancy_getopt.pyi | 8 +- stdlib/distutils/filelist.pyi | 2 +- stdlib/distutils/text_file.pyi | 2 +- stdlib/distutils/version.pyi | 2 +- stdlib/doctest.pyi | 24 ++-- stdlib/email/_header_value_parser.pyi | 4 +- stdlib/email/headerregistry.pyi | 2 +- stdlib/email/mime/multipart.pyi | 2 +- stdlib/email/utils.pyi | 2 +- stdlib/filecmp.pyi | 4 +- stdlib/formatter.pyi | 2 +- stdlib/ftplib.pyi | 10 +- stdlib/functools.pyi | 4 +- stdlib/gettext.pyi | 14 +- stdlib/http/client.pyi | 16 +-- stdlib/http/cookiejar.pyi | 12 +- stdlib/http/cookies.pyi | 10 +- stdlib/imaplib.pyi | 4 +- stdlib/importlib/__init__.pyi | 4 +- stdlib/importlib/abc.pyi | 4 +- stdlib/importlib/machinery.pyi | 18 +-- stdlib/importlib/metadata.pyi | 8 +- stdlib/importlib/util.pyi | 2 +- stdlib/inspect.pyi | 34 ++--- stdlib/io.pyi | 4 +- stdlib/ipaddress.pyi | 2 +- stdlib/itertools.pyi | 2 +- stdlib/json/__init__.pyi | 12 +- stdlib/json/encoder.pyi | 4 +- stdlib/lib2to3/pgen2/pgen.pyi | 2 +- stdlib/lib2to3/pytree.pyi | 4 +- stdlib/logging/__init__.pyi | 124 +++++++++--------- stdlib/logging/config.pyi | 4 +- stdlib/logging/handlers.pyi | 6 +- stdlib/mailbox.pyi | 4 +- stdlib/mimetypes.pyi | 4 +- stdlib/modulefinder.pyi | 10 +- stdlib/msilib/__init__.pyi | 2 +- stdlib/multiprocessing/__init__.pyi | 4 +- stdlib/multiprocessing/connection.pyi | 4 +- stdlib/multiprocessing/context.pyi | 4 +- stdlib/multiprocessing/dummy/__init__.pyi | 4 +- stdlib/multiprocessing/dummy/connection.pyi | 8 +- stdlib/multiprocessing/managers.pyi | 10 +- stdlib/multiprocessing/pool.pyi | 4 +- stdlib/multiprocessing/process.pyi | 2 +- stdlib/multiprocessing/shared_memory.pyi | 2 +- stdlib/multiprocessing/synchronize.pyi | 2 +- stdlib/optparse.pyi | 22 ++-- stdlib/os/__init__.pyi | 8 +- stdlib/pathlib.pyi | 2 +- stdlib/pdb.pyi | 12 +- stdlib/pickle.pyi | 10 +- stdlib/pickletools.pyi | 4 +- stdlib/pkgutil.pyi | 4 +- stdlib/pprint.pyi | 16 +-- stdlib/pstats.pyi | 2 +- stdlib/py_compile.pyi | 2 +- stdlib/pyclbr.pyi | 10 +- stdlib/pydoc.pyi | 14 +- stdlib/pyexpat/__init__.pyi | 2 +- stdlib/random.pyi | 12 +- stdlib/re.pyi | 12 +- stdlib/rlcompleter.pyi | 2 +- stdlib/runpy.pyi | 4 +- stdlib/select.pyi | 4 +- stdlib/site.pyi | 4 +- stdlib/smtplib.pyi | 4 +- stdlib/socket.pyi | 2 +- stdlib/socketserver.pyi | 4 +- stdlib/sqlite3/dbapi2.pyi | 4 +- stdlib/sre_parse.pyi | 4 +- stdlib/ssl.pyi | 6 +- stdlib/statistics.pyi | 2 +- stdlib/subprocess.pyi | 10 +- stdlib/sunau.pyi | 2 +- stdlib/symtable.pyi | 4 +- stdlib/sys.pyi | 2 +- stdlib/sysconfig.pyi | 6 +- stdlib/tarfile.pyi | 56 ++++---- stdlib/telnetlib.pyi | 2 +- stdlib/tempfile.pyi | 38 +++--- stdlib/threading.pyi | 18 +-- stdlib/timeit.pyi | 10 +- stdlib/tkinter/__init__.pyi | 122 ++++++++--------- stdlib/tkinter/dnd.pyi | 4 +- stdlib/tkinter/tix.pyi | 6 +- stdlib/tkinter/ttk.pyi | 52 ++++---- stdlib/trace.pyi | 6 +- stdlib/traceback.pyi | 34 ++--- stdlib/types.pyi | 10 +- stdlib/typing.pyi | 26 ++-- stdlib/typing_extensions.pyi | 6 +- stdlib/unittest/case.pyi | 6 +- stdlib/unittest/loader.pyi | 4 +- stdlib/unittest/main.pyi | 4 +- stdlib/unittest/runner.pyi | 2 +- stdlib/urllib/error.pyi | 2 +- stdlib/urllib/request.pyi | 8 +- stdlib/urllib/response.pyi | 2 +- stdlib/urllib/robotparser.pyi | 2 +- stdlib/venv/__init__.pyi | 2 +- stdlib/warnings.pyi | 4 +- stdlib/webbrowser.pyi | 2 +- stdlib/winreg.pyi | 2 +- stdlib/wsgiref/handlers.pyi | 4 +- stdlib/xml/etree/ElementInclude.pyi | 4 +- stdlib/xml/etree/ElementPath.pyi | 12 +- stdlib/xml/etree/ElementTree.pyi | 48 +++---- stdlib/xmlrpc/client.pyi | 2 +- stdlib/zipfile.pyi | 8 +- stdlib/zoneinfo/__init__.pyi | 2 +- 262 files changed, 1219 insertions(+), 1219 deletions(-) diff --git a/stdlib/@python2/ConfigParser.pyi b/stdlib/@python2/ConfigParser.pyi index 538c5408766a..2f63632c9371 100644 --- a/stdlib/@python2/ConfigParser.pyi +++ b/stdlib/@python2/ConfigParser.pyi @@ -84,8 +84,8 @@ class RawConfigParser: class ConfigParser(RawConfigParser): _KEYCRE: Any - def get(self, section: str, option: str, raw: bool = ..., vars: Optional[Dict[Any, Any]] = ...) -> Any: ... - def items(self, section: str, raw: bool = ..., vars: Optional[Dict[Any, Any]] = ...) -> List[Tuple[str, Any]]: ... + def get(self, section: str, option: str, raw: bool = ..., vars: Dict[Any, Any] | None = ...) -> Any: ... + def items(self, section: str, raw: bool = ..., vars: Dict[Any, Any] | None = ...) -> List[Tuple[str, Any]]: ... def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ... def _interpolation_replace(self, match: Any) -> str: ... diff --git a/stdlib/@python2/SimpleHTTPServer.pyi b/stdlib/@python2/SimpleHTTPServer.pyi index 198636e1fe6b..472ed8fdf4d1 100644 --- a/stdlib/@python2/SimpleHTTPServer.pyi +++ b/stdlib/@python2/SimpleHTTPServer.pyi @@ -6,8 +6,8 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): server_version: str def do_GET(self) -> None: ... def do_HEAD(self) -> None: ... - def send_head(self) -> Optional[IO[str]]: ... - def list_directory(self, path: str | unicode) -> Optional[StringIO[Any]]: ... + def send_head(self) -> IO[str] | None: ... + def list_directory(self, path: str | unicode) -> StringIO[Any] | None: ... def translate_path(self, path: AnyStr) -> AnyStr: ... def copyfile(self, source: IO[AnyStr], outputfile: IO[AnyStr]): ... def guess_type(self, path: str | unicode) -> str: ... diff --git a/stdlib/@python2/SocketServer.pyi b/stdlib/@python2/SocketServer.pyi index 44827e06e538..991efaf240b9 100644 --- a/stdlib/@python2/SocketServer.pyi +++ b/stdlib/@python2/SocketServer.pyi @@ -61,7 +61,7 @@ if sys.platform != "win32": if sys.platform != "win32": class ForkingMixIn: timeout: float | None # undocumented - active_children: Optional[List[int]] # undocumented + active_children: List[int] | None # undocumented max_children: int # undocumented def collect_children(self) -> None: ... # undocumented def handle_timeout(self) -> None: ... # undocumented diff --git a/stdlib/@python2/__builtin__.pyi b/stdlib/@python2/__builtin__.pyi index 4f7395590d52..252b0b54fea0 100644 --- a/stdlib/@python2/__builtin__.pyi +++ b/stdlib/@python2/__builtin__.pyi @@ -93,13 +93,13 @@ class staticmethod(object): # Special, only valid as a decorator. __func__: Callable[..., Any] 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] 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 @@ -548,9 +548,9 @@ class bytearray(MutableSequence[int], ByteString): class memoryview(Sized, Container[str]): 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 def __init__(self, obj: ReadableBuffer) -> None: ... @@ -829,7 +829,7 @@ NotImplemented: _NotImplementedType def abs(__x: SupportsAbs[_T]) -> _T: ... def all(__iterable: Iterable[object]) -> bool: ... def any(__iterable: Iterable[object]) -> bool: ... -def apply(__func: Callable[..., _T], __args: Optional[Sequence[Any]] = ..., __kwds: Optional[Mapping[str, Any]] = ...) -> _T: ... +def apply(__func: Callable[..., _T], __args: Sequence[Any] | None = ..., __kwds: Mapping[str, Any] | None = ...) -> _T: ... def bin(__number: int | _SupportsIndex) -> str: ... def callable(__obj: object) -> bool: ... def chr(__i: int) -> str: ... @@ -846,9 +846,9 @@ _N2 = TypeVar("_N2", int, float) def divmod(__x: _N2, __y: _N2) -> Tuple[_N2, _N2]: ... def eval( - __source: Text | bytes | CodeType, __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ... + __source: Text | bytes | CodeType, __globals: Dict[str, Any] | None = ..., __locals: Mapping[str, Any] | None = ... ) -> Any: ... -def execfile(__filename: str, __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Dict[str, Any]] = ...) -> None: ... +def execfile(__filename: str, __globals: Dict[str, Any] | None = ..., __locals: Dict[str, Any] | None = ...) -> None: ... def exit(code: object = ...) -> NoReturn: ... @overload def filter(__function: Callable[[AnyStr], Any], __iterable: AnyStr) -> AnyStr: ... # type: ignore @@ -973,7 +973,7 @@ def ord(__c: Text | bytes) -> int: ... # This is only available after from __future__ import print_function. def print( - *values: object, sep: Text | None = ..., end: Text | None = ..., file: Optional[SupportsWrite[Any]] = ... + *values: object, sep: Text | None = ..., end: Text | None = ..., file: SupportsWrite[Any] | None = ... ) -> None: ... _E = TypeVar("_E", contravariant=True) @@ -1052,8 +1052,8 @@ def zip( ) -> List[Tuple[Any, ...]]: ... def __import__( name: Text, - 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: ... diff --git a/stdlib/@python2/_dummy_threading.pyi b/stdlib/@python2/_dummy_threading.pyi index 44b81fe337bf..ab062bf200cc 100644 --- a/stdlib/@python2/_dummy_threading.pyi +++ b/stdlib/@python2/_dummy_threading.pyi @@ -2,7 +2,7 @@ from types import FrameType, TracebackType from typing import Any, Callable, Iterable, List, Mapping, Optional, Text, Type, TypeVar, Union # TODO recursive type -_TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] +_TF = Callable[[FrameType, str, Any], Callable[..., Any] | None] _PF = Callable[[FrameType, str, Any], None] _T = TypeVar("_T") @@ -32,10 +32,10 @@ class Thread: def __init__( self, group: None = ..., - target: Optional[Callable[..., Any]] = ..., + target: Callable[..., Any] | None = ..., name: Text | None = ..., args: Iterable[Any] = ..., - kwargs: Optional[Mapping[Text, Any]] = ..., + kwargs: Mapping[Text, Any] | None = ..., ) -> None: ... def start(self) -> None: ... def run(self) -> None: ... @@ -53,7 +53,7 @@ class Lock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... @@ -63,7 +63,7 @@ class _RLock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... @@ -74,7 +74,7 @@ class Condition: def __init__(self, lock: Lock | _RLock | None = ...) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... @@ -86,7 +86,7 @@ class Condition: class Semaphore: def __init__(self, value: int = ...) -> None: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def __enter__(self, blocking: bool = ...) -> bool: ... diff --git a/stdlib/@python2/_io.pyi b/stdlib/@python2/_io.pyi index 5e3ebcf0ed8b..368f3f44f725 100644 --- a/stdlib/@python2/_io.pyi +++ b/stdlib/@python2/_io.pyi @@ -32,7 +32,7 @@ class _IOBase(BinaryIO): def writable(self) -> bool: ... def __enter__(self: _T) -> _T: ... def __exit__( - self, t: Optional[Type[BaseException]], value: BaseException | None, traceback: Any | None + self, t: Type[BaseException] | None, value: BaseException | None, traceback: Any | None ) -> bool | None: ... def __iter__(self: _T) -> _T: ... # The parameter type of writelines[s]() is determined by that of write(): @@ -142,7 +142,7 @@ class _TextIOBase(TextIO): def writelines(self, lines: Iterable[unicode]) -> None: ... def __enter__(self: _T) -> _T: ... def __exit__( - self, t: Optional[Type[BaseException]], value: BaseException | None, traceback: Any | None + self, t: Type[BaseException] | None, value: BaseException | None, traceback: Any | None ) -> bool | None: ... def __iter__(self: _T) -> _T: ... diff --git a/stdlib/@python2/_thread.pyi b/stdlib/@python2/_thread.pyi index 2fd84f1c5727..b900fc7874af 100644 --- a/stdlib/@python2/_thread.pyi +++ b/stdlib/@python2/_thread.pyi @@ -13,7 +13,7 @@ class LockType: def locked(self) -> bool: ... def __enter__(self) -> bool: ... def __exit__( - self, type: Optional[Type[BaseException]], value: BaseException | None, traceback: TracebackType | None + self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: Dict[str, Any] = ...) -> int: ... diff --git a/stdlib/@python2/_warnings.pyi b/stdlib/@python2/_warnings.pyi index 03bd1e5e4991..98caae2867ec 100644 --- a/stdlib/@python2/_warnings.pyi +++ b/stdlib/@python2/_warnings.pyi @@ -6,7 +6,7 @@ once_registry: Dict[Any, Any] filters: List[Tuple[Any, ...]] @overload -def warn(message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ...) -> None: ... +def warn(message: str, category: Type[Warning] | None = ..., stacklevel: int = ...) -> None: ... @overload def warn(message: Warning, category: Any = ..., stacklevel: int = ...) -> None: ... @overload @@ -17,7 +17,7 @@ def warn_explicit( lineno: int, module: str | None = ..., registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., + module_globals: Dict[str, Any] | None = ..., ) -> None: ... @overload def warn_explicit( @@ -27,5 +27,5 @@ def warn_explicit( lineno: int, module: str | None = ..., registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., + module_globals: Dict[str, Any] | None = ..., ) -> None: ... diff --git a/stdlib/@python2/_weakrefset.pyi b/stdlib/@python2/_weakrefset.pyi index bb0a969f4471..a7ebd8e24e9d 100644 --- a/stdlib/@python2/_weakrefset.pyi +++ b/stdlib/@python2/_weakrefset.pyi @@ -5,7 +5,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: ... diff --git a/stdlib/@python2/_winreg.pyi b/stdlib/@python2/_winreg.pyi index 0cb985d32bc9..8e4cbfa0e146 100644 --- a/stdlib/@python2/_winreg.pyi +++ b/stdlib/@python2/_winreg.pyi @@ -90,7 +90,7 @@ class HKEYType: def __int__(self) -> int: ... def __enter__(self) -> HKEYType: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def Close(self) -> None: ... def Detach(self) -> int: ... diff --git a/stdlib/@python2/aifc.pyi b/stdlib/@python2/aifc.pyi index 0a3aa120d026..ec34113c2c2a 100644 --- a/stdlib/@python2/aifc.pyi +++ b/stdlib/@python2/aifc.pyi @@ -28,7 +28,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: ... @@ -54,7 +54,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: ... diff --git a/stdlib/@python2/argparse.pyi b/stdlib/@python2/argparse.pyi index 76a9da9baaf5..6b71a2e9d34b 100644 --- a/stdlib/@python2/argparse.pyi +++ b/stdlib/@python2/argparse.pyi @@ -76,7 +76,7 @@ class _ActionsContainer: choices: Iterable[_T] = ..., required: bool = ..., help: Text | None = ..., - metavar: Optional[Text | Tuple[Text, ...]] = ..., + metavar: Text | Tuple[Text, ...] | None = ..., dest: Text | None = ..., version: Text = ..., **kwargs: Any, @@ -88,7 +88,7 @@ class _ActionsContainer: def _add_container_actions(self, container: _ActionsContainer) -> None: ... def _get_positional_kwargs(self, dest: Text, **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[Text, Action]]], Any]: ... def _check_conflict(self, action: Action) -> None: ... def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[Tuple[Text, Action]]) -> NoReturn: ... @@ -126,11 +126,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[Text]] = ...) -> Namespace: ... + def parse_args(self, args: Sequence[Text] | None = ...) -> Namespace: ... @overload - def parse_args(self, args: Optional[Sequence[Text]], namespace: None) -> Namespace: ... # type: ignore + def parse_args(self, args: Sequence[Text] | None, namespace: None) -> Namespace: ... # type: ignore @overload - def parse_args(self, args: Optional[Sequence[Text]], namespace: _N) -> _N: ... + def parse_args(self, args: Sequence[Text] | None, namespace: _N) -> _N: ... @overload def parse_args(self, *, namespace: None) -> Namespace: ... # type: ignore @overload @@ -148,12 +148,12 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): help: Text | None = ..., metavar: Text | 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[Text]] = ..., namespace: Namespace | None = ... + self, args: Sequence[Text] | None = ..., namespace: Namespace | None = ... ) -> Tuple[Namespace, List[str]]: ... def convert_arg_line_to_args(self, arg_line: Text) -> List[str]: ... def exit(self, status: int = ..., message: Text | None = ...) -> NoReturn: ... @@ -165,14 +165,14 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): def _read_args_from_files(self, arg_strings: List[Text]) -> List[Text]: ... def _match_argument(self, action: Action, arg_strings_pattern: Text) -> int: ... def _match_arguments_partial(self, actions: Sequence[Action], arg_strings_pattern: Text) -> List[int]: ... - def _parse_optional(self, arg_string: Text) -> Optional[Tuple[Action | None, Text, Text | None]]: ... + def _parse_optional(self, arg_string: Text) -> Tuple[Action | None, Text, Text | None] | None: ... def _get_option_tuples(self, option_string: Text) -> List[Tuple[Action, Text, Text | None]]: ... def _get_nargs_pattern(self, action: Action) -> _Text: ... def _get_values(self, action: Action, arg_strings: List[Text]) -> Any: ... def _get_value(self, action: Action, arg_string: Text) -> 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 @@ -232,10 +232,10 @@ class Action(_AttributeHolder): const: Any default: Any type: Union[Callable[[str], Any], FileType, None] - choices: Optional[Iterable[Any]] + choices: Iterable[Any] | None required: bool help: _Text | None - metavar: Optional[_Text | Tuple[_Text, ...]] + metavar: _Text | Tuple[_Text, ...] | None def __init__( self, option_strings: Sequence[Text], @@ -244,10 +244,10 @@ class Action(_AttributeHolder): const: _T | None = ..., default: _T | str | None = ..., type: Optional[Union[Callable[[Text], _T], Callable[[str], _T], FileType]] = ..., - choices: Optional[Iterable[_T]] = ..., + choices: Iterable[_T] | None = ..., required: bool = ..., help: Text | None = ..., - metavar: Optional[Text | Tuple[Text, ...]] = ..., + metavar: Text | Tuple[Text, ...] | None = ..., ) -> None: ... def __call__( self, @@ -297,7 +297,7 @@ class _StoreConstAction(Action): default: Any = ..., required: bool = ..., help: Text | None = ..., - metavar: Optional[Text | Tuple[Text, ...]] = ..., + metavar: Text | Tuple[Text, ...] | None = ..., ) -> None: ... # undocumented @@ -325,7 +325,7 @@ class _AppendConstAction(Action): default: Any = ..., required: bool = ..., help: Text | None = ..., - metavar: Optional[Text | Tuple[Text, ...]] = ..., + metavar: Text | Tuple[Text, ...] | None = ..., ) -> None: ... # undocumented @@ -367,7 +367,7 @@ class _SubParsersAction(Action): parser_class: Type[ArgumentParser], dest: Text = ..., help: Text | None = ..., - metavar: Optional[Text | Tuple[Text, ...]] = ..., + metavar: Text | Tuple[Text, ...] | None = ..., ) -> None: ... # TODO: Type keyword args properly. def add_parser(self, name: Text, **kwargs: Any) -> ArgumentParser: ... diff --git a/stdlib/@python2/asyncore.pyi b/stdlib/@python2/asyncore.pyi index 7c8bd1b29974..7a159c5fc520 100644 --- a/stdlib/@python2/asyncore.pyi +++ b/stdlib/@python2/asyncore.pyi @@ -42,7 +42,7 @@ class dispatcher: def listen(self, num: int) -> None: ... def bind(self, addr: Tuple[Any, ...] | str) -> None: ... def connect(self, address: Tuple[Any, ...] | str) -> None: ... - def accept(self) -> Optional[Tuple[SocketType, Any]]: ... + def accept(self) -> Tuple[SocketType, Any] | None: ... def send(self, data: bytes) -> int: ... def recv(self, buffer_size: int) -> bytes: ... def close(self) -> None: ... diff --git a/stdlib/@python2/bdb.pyi b/stdlib/@python2/bdb.pyi index cba5a6750ec3..bf8f3c583260 100644 --- a/stdlib/@python2/bdb.pyi +++ b/stdlib/@python2/bdb.pyi @@ -11,7 +11,7 @@ class BdbQuit(Exception): ... class Bdb: - skip: Optional[Set[str]] + skip: Set[str] | None breaks: Dict[str, List[int]] fncache: Dict[str, str] frame_returning: FrameType | None @@ -20,7 +20,7 @@ class Bdb: 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: ... @@ -59,11 +59,11 @@ class Bdb: 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: 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: 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) -> _T | None: ... @@ -89,7 +89,7 @@ class Breakpoint: 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: ... diff --git a/stdlib/@python2/builtins.pyi b/stdlib/@python2/builtins.pyi index 4f7395590d52..252b0b54fea0 100644 --- a/stdlib/@python2/builtins.pyi +++ b/stdlib/@python2/builtins.pyi @@ -93,13 +93,13 @@ class staticmethod(object): # Special, only valid as a decorator. __func__: Callable[..., Any] 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] 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 @@ -548,9 +548,9 @@ class bytearray(MutableSequence[int], ByteString): class memoryview(Sized, Container[str]): 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 def __init__(self, obj: ReadableBuffer) -> None: ... @@ -829,7 +829,7 @@ NotImplemented: _NotImplementedType def abs(__x: SupportsAbs[_T]) -> _T: ... def all(__iterable: Iterable[object]) -> bool: ... def any(__iterable: Iterable[object]) -> bool: ... -def apply(__func: Callable[..., _T], __args: Optional[Sequence[Any]] = ..., __kwds: Optional[Mapping[str, Any]] = ...) -> _T: ... +def apply(__func: Callable[..., _T], __args: Sequence[Any] | None = ..., __kwds: Mapping[str, Any] | None = ...) -> _T: ... def bin(__number: int | _SupportsIndex) -> str: ... def callable(__obj: object) -> bool: ... def chr(__i: int) -> str: ... @@ -846,9 +846,9 @@ _N2 = TypeVar("_N2", int, float) def divmod(__x: _N2, __y: _N2) -> Tuple[_N2, _N2]: ... def eval( - __source: Text | bytes | CodeType, __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Mapping[str, Any]] = ... + __source: Text | bytes | CodeType, __globals: Dict[str, Any] | None = ..., __locals: Mapping[str, Any] | None = ... ) -> Any: ... -def execfile(__filename: str, __globals: Optional[Dict[str, Any]] = ..., __locals: Optional[Dict[str, Any]] = ...) -> None: ... +def execfile(__filename: str, __globals: Dict[str, Any] | None = ..., __locals: Dict[str, Any] | None = ...) -> None: ... def exit(code: object = ...) -> NoReturn: ... @overload def filter(__function: Callable[[AnyStr], Any], __iterable: AnyStr) -> AnyStr: ... # type: ignore @@ -973,7 +973,7 @@ def ord(__c: Text | bytes) -> int: ... # This is only available after from __future__ import print_function. def print( - *values: object, sep: Text | None = ..., end: Text | None = ..., file: Optional[SupportsWrite[Any]] = ... + *values: object, sep: Text | None = ..., end: Text | None = ..., file: SupportsWrite[Any] | None = ... ) -> None: ... _E = TypeVar("_E", contravariant=True) @@ -1052,8 +1052,8 @@ def zip( ) -> List[Tuple[Any, ...]]: ... def __import__( name: Text, - 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: ... diff --git a/stdlib/@python2/cgi.pyi b/stdlib/@python2/cgi.pyi index b8a0918dce6c..c3a5d81e852f 100644 --- a/stdlib/@python2/cgi.pyi +++ b/stdlib/@python2/cgi.pyi @@ -6,7 +6,7 @@ from UserDict import UserDict _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 = ..., @@ -32,7 +32,7 @@ class MiniFieldStorage: 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] @@ -57,13 +57,13 @@ class FieldStorage(object): disposition: str disposition_options: dict[str, str] filename: str | None - file: Optional[IO[bytes]] + file: IO[bytes] | None type: str type_options: dict[str, str] innerboundary: bytes length: int done: int - list: Optional[List[Any]] + list: List[Any] | None value: None | bytes | List[Any] def __init__( self, diff --git a/stdlib/@python2/cgitb.pyi b/stdlib/@python2/cgitb.pyi index 9a75965c3796..ed6b3c041408 100644 --- a/stdlib/@python2/cgitb.pyi +++ b/stdlib/@python2/cgitb.pyi @@ -1,7 +1,7 @@ from types import FrameType, TracebackType from typing import IO, Any, Callable, Dict, List, Optional, Text, Tuple, Type -_ExcInfo = Tuple[Optional[Type[BaseException]], BaseException | None, TracebackType | None] +_ExcInfo = Tuple[Type[BaseException] | None, BaseException | None, TracebackType | None] def reset() -> str: ... # undocumented def small(text: str) -> str: ... # undocumented @@ -20,11 +20,11 @@ class Hook: # undocumented display: int = ..., logdir: Text | None = ..., context: int = ..., - file: Optional[IO[str]] = ..., + file: IO[str] | None = ..., format: str = ..., ) -> None: ... def __call__( - self, etype: Optional[Type[BaseException]], evalue: BaseException | None, etb: TracebackType | None + self, etype: Type[BaseException] | None, evalue: BaseException | None, etb: TracebackType | None ) -> None: ... def handle(self, info: _ExcInfo | None = ...) -> None: ... diff --git a/stdlib/@python2/cmd.pyi b/stdlib/@python2/cmd.pyi index afcfd0a2a2ea..75d7fcba5949 100644 --- a/stdlib/@python2/cmd.pyi +++ b/stdlib/@python2/cmd.pyi @@ -16,7 +16,7 @@ class Cmd: stdout: IO[str] cmdqueue: List[str] completekey: str - def __init__(self, completekey: str = ..., stdin: Optional[IO[str]] = ..., stdout: Optional[IO[str]] = ...) -> None: ... + def __init__(self, completekey: str = ..., stdin: IO[str] | None = ..., stdout: IO[str] | None = ...) -> None: ... old_completer: Optional[Callable[[str, int], str | None]] def cmdloop(self, intro: Any | None = ...) -> None: ... def precmd(self, line: str) -> str: ... @@ -29,11 +29,11 @@ class Cmd: 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) -> bool | None: ... - 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 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/@python2/code.pyi b/stdlib/@python2/code.pyi index 05e85cf5581a..54552de54e38 100644 --- a/stdlib/@python2/code.pyi +++ b/stdlib/@python2/code.pyi @@ -2,7 +2,7 @@ from types import CodeType from typing import Any, Callable, Mapping, Optional class InteractiveInterpreter: - def __init__(self, locals: Optional[Mapping[str, Any]] = ...) -> None: ... + def __init__(self, locals: Mapping[str, Any] | None = ...) -> None: ... def runsource(self, source: str, filename: str = ..., symbol: str = ...) -> bool: ... def runcode(self, code: CodeType) -> None: ... def showsyntaxerror(self, filename: str | None = ...) -> None: ... @@ -10,13 +10,13 @@ class InteractiveInterpreter: def write(self, data: str) -> None: ... class InteractiveConsole(InteractiveInterpreter): - def __init__(self, locals: Optional[Mapping[str, Any]] = ..., filename: str = ...) -> None: ... + def __init__(self, locals: Mapping[str, Any] | None = ..., filename: str = ...) -> None: ... def interact(self, banner: str | None = ...) -> None: ... def push(self, line: str) -> bool: ... def resetbuffer(self) -> None: ... def raw_input(self, prompt: str = ...) -> str: ... def interact( - banner: str | None = ..., readfunc: Optional[Callable[[str], str]] = ..., local: Optional[Mapping[str, Any]] = ... + banner: str | None = ..., readfunc: Optional[Callable[[str], str]] = ..., local: Mapping[str, Any] | None = ... ) -> None: ... def compile_command(source: str, filename: str = ..., symbol: str = ...) -> CodeType | None: ... diff --git a/stdlib/@python2/codecs.pyi b/stdlib/@python2/codecs.pyi index c6494cf820db..eadb76723f4e 100644 --- a/stdlib/@python2/codecs.pyi +++ b/stdlib/@python2/codecs.pyi @@ -204,7 +204,7 @@ class StreamWriter(Codec): def reset(self) -> None: ... def __enter__(self: _SW) -> _SW: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: BaseException | None, tb: types.TracebackType | None + self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None ) -> None: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... @@ -219,7 +219,7 @@ class StreamReader(Codec): def reset(self) -> None: ... def __enter__(self: _SR) -> _SR: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: BaseException | None, tb: types.TracebackType | None + self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None ) -> None: ... def __iter__(self) -> Iterator[_Decoded]: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... @@ -243,7 +243,7 @@ class StreamReaderWriter(TextIO): def seek(self, offset: int, whence: int = ...) -> int: ... def __enter__(self: _T) -> _T: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: BaseException | None, tb: types.TracebackType | None + 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 @@ -281,7 +281,7 @@ class StreamRecoder(BinaryIO): def __getattr__(self, name: str) -> Any: ... def __enter__(self: _SRT) -> _SRT: ... def __exit__( - self, type: Optional[Type[BaseException]], value: BaseException | None, tb: types.TracebackType | None + 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__. diff --git a/stdlib/@python2/compileall.pyi b/stdlib/@python2/compileall.pyi index 1316875a6233..e9458e935e48 100644 --- a/stdlib/@python2/compileall.pyi +++ b/stdlib/@python2/compileall.pyi @@ -6,10 +6,10 @@ def compile_dir( maxlevels: int = ..., ddir: Text | None = ..., force: bool = ..., - rx: Optional[Pattern[Any]] = ..., + rx: Pattern[Any] | None = ..., quiet: int = ..., ) -> int: ... def compile_file( - fullname: Text, ddir: Text | None = ..., force: bool = ..., rx: Optional[Pattern[Any]] = ..., quiet: int = ... + fullname: Text, ddir: Text | None = ..., force: bool = ..., rx: Pattern[Any] | None = ..., quiet: int = ... ) -> int: ... def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ...) -> int: ... diff --git a/stdlib/@python2/contextlib.pyi b/stdlib/@python2/contextlib.pyi index 6bd73748d16c..3b748e6c71b4 100644 --- a/stdlib/@python2/contextlib.pyi +++ b/stdlib/@python2/contextlib.pyi @@ -4,10 +4,10 @@ from typing_extensions import Protocol _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) -_T_io = TypeVar("_T_io", bound=Optional[IO[str]]) +_T_io = TypeVar("_T_io", bound=IO[str] | None) _F = TypeVar("_F", bound=Callable[..., Any]) -_ExitFunc = Callable[[Optional[Type[BaseException]], BaseException | None, TracebackType | None], bool] +_ExitFunc = Callable[[Type[BaseException] | None, BaseException | None, TracebackType | None], bool] _CM_EF = TypeVar("_CM_EF", ContextManager[Any], _ExitFunc) class GeneratorContextManager(ContextManager[_T_co]): diff --git a/stdlib/@python2/copy.pyi b/stdlib/@python2/copy.pyi index b51c79c66c6a..180e58756ead 100644 --- a/stdlib/@python2/copy.pyi +++ b/stdlib/@python2/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/@python2/csv.pyi b/stdlib/@python2/csv.pyi index 9bb659f441fc..f21b5cfdd547 100644 --- a/stdlib/@python2/csv.pyi +++ b/stdlib/@python2/csv.pyi @@ -46,7 +46,7 @@ class excel_tab(excel): delimiter: str class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): - fieldnames: Optional[Sequence[_T]] + fieldnames: Sequence[_T] | None restkey: str | None restval: str | None reader: _reader @@ -67,7 +67,7 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): def __init__( self: DictReader[str], f: Iterable[Text], - fieldnames: Optional[Sequence[str]] = ..., + fieldnames: Sequence[str] | None = ..., restkey: str | None = ..., restval: str | None = ..., dialect: _DialectLike = ..., diff --git a/stdlib/@python2/ctypes/__init__.pyi b/stdlib/@python2/ctypes/__init__.pyi index 866c1b3ad0b6..d446f9ee481a 100644 --- a/stdlib/@python2/ctypes/__init__.pyi +++ b/stdlib/@python2/ctypes/__init__.pyi @@ -75,7 +75,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 @@ -90,7 +90,7 @@ class _CData(metaclass=_CDataMeta): class _CanCastTo(_CData): ... class _PointerLike(_CanCastTo): ... -_ECT = Callable[[Optional[Type[_CData]], _FuncPointer, Tuple[_CData, ...]], _CData] +_ECT = Callable[[Type[_CData] | None, _FuncPointer, Tuple[_CData, ...]], _CData] _PF = _UnionT[Tuple[int], Tuple[int, str], Tuple[int, str, Any]] class _FuncPointer(_PointerLike, _CData): @@ -113,15 +113,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: ... @@ -203,7 +203,7 @@ 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: Optional[_UnionT[int, bytes]] = ...) -> None: ... + def __init__(self, value: _UnionT[int, bytes] | None = ...) -> None: ... class c_double(_SimpleCData[float]): ... class c_longdouble(_SimpleCData[float]): ... @@ -231,7 +231,7 @@ class c_void_p(_PointerLike, _SimpleCData[int | None]): ... class c_wchar(_SimpleCData[Text]): ... class c_wchar_p(_PointerLike, _SimpleCData[Text | None]): - def __init__(self, value: Optional[_UnionT[int, Text]] = ...) -> None: ... + def __init__(self, value: _UnionT[int, Text] | None = ...) -> None: ... class c_bool(_SimpleCData[bool]): def __init__(self, value: bool = ...) -> None: ... diff --git a/stdlib/@python2/dbm/__init__.pyi b/stdlib/@python2/dbm/__init__.pyi index bf2a8bfc41c4..2c1a16fdb7d8 100644 --- a/stdlib/@python2/dbm/__init__.pyi +++ b/stdlib/@python2/dbm/__init__.pyi @@ -15,7 +15,7 @@ class _Database(MutableMapping[_KeyType, bytes]): def __del__(self) -> None: ... def __enter__(self) -> _Database: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... class _error(Exception): ... diff --git a/stdlib/@python2/dbm/dumb.pyi b/stdlib/@python2/dbm/dumb.pyi index eb1d5dca807e..f0bd7aa59f8a 100644 --- a/stdlib/@python2/dbm/dumb.pyi +++ b/stdlib/@python2/dbm/dumb.pyi @@ -19,7 +19,7 @@ class _Database(MutableMapping[_KeyType, bytes]): def __del__(self) -> None: ... def __enter__(self) -> _Database: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def open(file: str, flag: str = ..., mode: int = ...) -> _Database: ... diff --git a/stdlib/@python2/dbm/gnu.pyi b/stdlib/@python2/dbm/gnu.pyi index 87eb2e7a1c9a..3a0a3544dc20 100644 --- a/stdlib/@python2/dbm/gnu.pyi +++ b/stdlib/@python2/dbm/gnu.pyi @@ -20,7 +20,7 @@ class _gdbm: def __len__(self) -> int: ... def __enter__(self) -> _gdbm: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... @overload def get(self, k: _KeyType) -> bytes | None: ... diff --git a/stdlib/@python2/dbm/ndbm.pyi b/stdlib/@python2/dbm/ndbm.pyi index 54ae1da86699..94e14365081f 100644 --- a/stdlib/@python2/dbm/ndbm.pyi +++ b/stdlib/@python2/dbm/ndbm.pyi @@ -19,7 +19,7 @@ class _dbm: def __del__(self) -> None: ... def __enter__(self) -> _dbm: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... @overload def get(self, k: _KeyType) -> bytes | None: ... diff --git a/stdlib/@python2/decimal.pyi b/stdlib/@python2/decimal.pyi index c058fceff11a..63f54da62979 100644 --- a/stdlib/@python2/decimal.pyi +++ b/stdlib/@python2/decimal.pyi @@ -146,7 +146,7 @@ class _ContextManager(object): saved_context: Context def __init__(self, new_context: Context) -> None: ... def __enter__(self) -> Context: ... - def __exit__(self, t: Optional[Type[BaseException]], v: BaseException | None, tb: TracebackType | None) -> None: ... + def __exit__(self, t: Type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... _TrapType = Type[DecimalException] @@ -169,7 +169,7 @@ class Context(object): Emax: int | None = ..., capitals: int | None = ..., _clamp: int | None = ..., - _ignored_flags: Optional[List[_TrapType]] = ..., + _ignored_flags: List[_TrapType] | None = ..., ) -> None: ... def clear_flags(self) -> None: ... def copy(self) -> Context: ... diff --git a/stdlib/@python2/distutils/ccompiler.pyi b/stdlib/@python2/distutils/ccompiler.pyi index 1721f948797b..dfed71592d54 100644 --- a/stdlib/@python2/distutils/ccompiler.pyi +++ b/stdlib/@python2/distutils/ccompiler.pyi @@ -41,10 +41,10 @@ class CCompiler: 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: ... @@ -55,11 +55,11 @@ class CCompiler: sources: List[str], output_dir: str | None = ..., macros: _Macro | None = ..., - include_dirs: Optional[List[str]] = ..., + 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, @@ -75,13 +75,13 @@ class CCompiler: objects: List[str], output_filename: str, output_dir: str | None = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., - export_symbols: Optional[List[str]] = ..., + 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]] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., build_temp: str | None = ..., target_lang: str | None = ..., ) -> None: ... @@ -90,12 +90,12 @@ class CCompiler: objects: List[str], output_progname: str, output_dir: str | None = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., + 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]] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., target_lang: str | None = ..., ) -> None: ... def link_shared_lib( @@ -103,13 +103,13 @@ class CCompiler: objects: List[str], output_libname: str, output_dir: str | None = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., - export_symbols: Optional[List[str]] = ..., + 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]] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., build_temp: str | None = ..., target_lang: str | None = ..., ) -> None: ... @@ -118,13 +118,13 @@ class CCompiler: objects: List[str], output_filename: str, output_dir: str | None = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., - export_symbols: Optional[List[str]] = ..., + 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]] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., build_temp: str | None = ..., target_lang: str | None = ..., ) -> None: ... @@ -132,10 +132,10 @@ class CCompiler: self, source: str, output_file: str | None = ..., - macros: Optional[List[_Macro]] = ..., - include_dirs: Optional[List[str]] = ..., - extra_preargs: Optional[List[str]] = ..., - extra_postargs: Optional[List[str]] = ..., + 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: ... diff --git a/stdlib/@python2/distutils/command/config.pyi b/stdlib/@python2/distutils/command/config.pyi index 7c96cd9425d3..f95d8c5e41ce 100644 --- a/stdlib/@python2/distutils/command/config.pyi +++ b/stdlib/@python2/distutils/command/config.pyi @@ -13,9 +13,9 @@ class config(Command): user_options: Sequence[Tuple[str, str | None, str]] = ... compiler: str | CCompiler | None = ... cc: str | None = ... - include_dirs: Optional[Sequence[str]] = ... - libraries: Optional[Sequence[str]] = ... - library_dirs: Optional[Sequence[str]] = ... + include_dirs: Sequence[str] | None = ... + libraries: Sequence[str] | None = ... + library_dirs: Sequence[str] | None = ... noisy: int = ... dump_source: int = ... temp_files: Sequence[str] = ... @@ -25,62 +25,62 @@ class config(Command): def try_cpp( self, body: str | None = ..., - headers: Optional[Sequence[str]] = ..., - include_dirs: Optional[Sequence[str]] = ..., + headers: Sequence[str] | None = ..., + include_dirs: Sequence[str] | None = ..., lang: str = ..., ) -> bool: ... def search_cpp( self, pattern: Pattern[str] | str, body: str | None = ..., - headers: Optional[Sequence[str]] = ..., - include_dirs: Optional[Sequence[str]] = ..., + headers: Sequence[str] | None = ..., + include_dirs: Sequence[str] | None = ..., lang: str = ..., ) -> bool: ... def try_compile( - self, body: str, headers: Optional[Sequence[str]] = ..., include_dirs: Optional[Sequence[str]] = ..., lang: str = ... + self, body: str, headers: Sequence[str] | None = ..., include_dirs: Sequence[str] | None = ..., lang: str = ... ) -> bool: ... def try_link( self, body: str, - headers: Optional[Sequence[str]] = ..., - include_dirs: Optional[Sequence[str]] = ..., - libraries: Optional[Sequence[str]] = ..., - library_dirs: Optional[Sequence[str]] = ..., + headers: Sequence[str] | None = ..., + include_dirs: Sequence[str] | None = ..., + libraries: Sequence[str] | None = ..., + library_dirs: Sequence[str] | None = ..., lang: str = ..., ) -> bool: ... def try_run( self, body: str, - headers: Optional[Sequence[str]] = ..., - include_dirs: Optional[Sequence[str]] = ..., - libraries: Optional[Sequence[str]] = ..., - library_dirs: Optional[Sequence[str]] = ..., + headers: Sequence[str] | None = ..., + include_dirs: Sequence[str] | None = ..., + libraries: Sequence[str] | None = ..., + library_dirs: Sequence[str] | None = ..., lang: str = ..., ) -> bool: ... def check_func( self, func: str, - headers: Optional[Sequence[str]] = ..., - include_dirs: Optional[Sequence[str]] = ..., - libraries: Optional[Sequence[str]] = ..., - library_dirs: Optional[Sequence[str]] = ..., + headers: Sequence[str] | None = ..., + include_dirs: Sequence[str] | None = ..., + libraries: Sequence[str] | None = ..., + library_dirs: Sequence[str] | None = ..., decl: int = ..., call: int = ..., ) -> bool: ... def check_lib( self, library: str, - library_dirs: Optional[Sequence[str]] = ..., - headers: Optional[Sequence[str]] = ..., - include_dirs: Optional[Sequence[str]] = ..., + library_dirs: Sequence[str] | None = ..., + headers: Sequence[str] | None = ..., + include_dirs: Sequence[str] | None = ..., other_libraries: List[str] = ..., ) -> bool: ... def check_header( self, header: str, - include_dirs: Optional[Sequence[str]] = ..., - library_dirs: Optional[Sequence[str]] = ..., + include_dirs: Sequence[str] | None = ..., + library_dirs: Sequence[str] | None = ..., lang: str = ..., ) -> bool: ... diff --git a/stdlib/@python2/distutils/core.pyi b/stdlib/@python2/distutils/core.pyi index 47bb1048d3b7..997134596087 100644 --- a/stdlib/@python2/distutils/core.pyi +++ b/stdlib/@python2/distutils/core.pyi @@ -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/@python2/distutils/dist.pyi b/stdlib/@python2/distutils/dist.pyi index 33a20d308b04..4403ca609576 100644 --- a/stdlib/@python2/distutils/dist.pyi +++ b/stdlib/@python2/distutils/dist.pyi @@ -3,7 +3,7 @@ from typing import Any, Dict, Iterable, Mapping, Optional, Text, Tuple, Type class Distribution: cmdclass: Dict[str, Type[Command]] - 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, Text]]: ... - def parse_config_files(self, filenames: Optional[Iterable[Text]] = ...) -> None: ... + def parse_config_files(self, filenames: Iterable[Text] | None = ...) -> None: ... def get_command_obj(self, command: str, create: bool = ...) -> Command | None: ... diff --git a/stdlib/@python2/distutils/fancy_getopt.pyi b/stdlib/@python2/distutils/fancy_getopt.pyi index 7cb98a6a6add..9965c6333b33 100644 --- a/stdlib/@python2/distutils/fancy_getopt.pyi +++ b/stdlib/@python2/distutils/fancy_getopt.pyi @@ -4,17 +4,17 @@ _Option = Tuple[str, str | None, str] _GR = Tuple[List[str], OptionDummy] def fancy_getopt( - options: List[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: Optional[List[str]] + 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: str | None = ...) -> List[str]: ... diff --git a/stdlib/@python2/distutils/text_file.pyi b/stdlib/@python2/distutils/text_file.pyi index 7160c0f3d3af..f9c2d4fa33fb 100644 --- a/stdlib/@python2/distutils/text_file.pyi +++ b/stdlib/@python2/distutils/text_file.pyi @@ -4,7 +4,7 @@ class TextFile: def __init__( self, filename: str | None = ..., - file: Optional[IO[str]] = ..., + file: IO[str] | None = ..., *, strip_comments: bool = ..., lstrip_ws: bool = ..., diff --git a/stdlib/@python2/distutils/version.pyi b/stdlib/@python2/distutils/version.pyi index 3d18863f7596..31c94e77bff0 100644 --- a/stdlib/@python2/distutils/version.pyi +++ b/stdlib/@python2/distutils/version.pyi @@ -17,7 +17,7 @@ class Version: class StrictVersion(Version): version_re: Pattern[str] version: Tuple[int, int, int] - prerelease: Optional[Tuple[Text, int]] + prerelease: Tuple[Text, int] | None def __init__(self, vstring: Text | None = ...) -> None: ... def parse(self: _T, vstring: Text) -> _T: ... def __str__(self) -> str: ... diff --git a/stdlib/@python2/doctest.pyi b/stdlib/@python2/doctest.pyi index 301871e4b00a..6fc0b038ebe4 100644 --- a/stdlib/@python2/doctest.pyi +++ b/stdlib/@python2/doctest.pyi @@ -42,7 +42,7 @@ class Example: exc_msg: str | None = ..., lineno: int = ..., indent: int = ..., - options: Optional[Dict[int, bool]] = ..., + options: Dict[int, bool] | None = ..., ) -> None: ... def __hash__(self) -> int: ... @@ -81,8 +81,8 @@ class DocTestFinder: obj: object, name: str | None = ..., module: None | bool | types.ModuleType = ..., - globs: Optional[Dict[str, Any]] = ..., - extraglobs: Optional[Dict[str, Any]] = ..., + globs: Dict[str, Any] | None = ..., + extraglobs: Dict[str, Any] | None = ..., ) -> List[DocTest]: ... _Out = Callable[[str], Any] @@ -129,11 +129,11 @@ master: DocTestRunner | None def testmod( m: types.ModuleType | None = ..., name: str | None = ..., - globs: Optional[Dict[str, Any]] = ..., + 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: ... @@ -142,11 +142,11 @@ def testfile( module_relative: bool = ..., name: str | None = ..., package: None | str | types.ModuleType = ..., - globs: Optional[Dict[str, Any]] = ..., + 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: str | None = ..., @@ -189,8 +189,8 @@ _DocTestSuite = unittest.TestSuite def DocTestSuite( module: None | str | types.ModuleType = ..., - globs: Optional[Dict[str, Any]] = ..., - extraglobs: Optional[Dict[str, Any]] = ..., + globs: Dict[str, Any] | None = ..., + extraglobs: Dict[str, Any] | None = ..., test_finder: DocTestFinder | None = ..., **options: Any, ) -> _DocTestSuite: ... @@ -203,7 +203,7 @@ def DocFileTest( path: str, module_relative: bool = ..., package: None | str | types.ModuleType = ..., - globs: Optional[Dict[str, Any]] = ..., + globs: Dict[str, Any] | None = ..., parser: DocTestParser = ..., encoding: str | None = ..., **options: Any, @@ -211,6 +211,6 @@ def DocFileTest( def DocFileSuite(*paths: str, **kw: Any) -> _DocTestSuite: ... def script_from_examples(s: str) -> str: ... def testsource(module: 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_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/@python2/filecmp.pyi b/stdlib/@python2/filecmp.pyi index 7b5ec48b8344..b79cd50e12d6 100644 --- a/stdlib/@python2/filecmp.pyi +++ b/stdlib/@python2/filecmp.pyi @@ -9,7 +9,7 @@ def cmpfiles( class dircmp(Generic[AnyStr]): def __init__( - self, a: AnyStr, b: AnyStr, ignore: Optional[Sequence[AnyStr]] = ..., hide: Optional[Sequence[AnyStr]] = ... + self, a: AnyStr, b: AnyStr, ignore: Sequence[AnyStr] | None = ..., hide: Sequence[AnyStr] | None = ... ) -> None: ... left: AnyStr right: AnyStr diff --git a/stdlib/@python2/formatter.pyi b/stdlib/@python2/formatter.pyi index 28a4ca807cd1..f57d86c1022b 100644 --- a/stdlib/@python2/formatter.pyi +++ b/stdlib/@python2/formatter.pyi @@ -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: ... diff --git a/stdlib/@python2/ftplib.pyi b/stdlib/@python2/ftplib.pyi index 307890127812..15f76aeaea78 100644 --- a/stdlib/@python2/ftplib.pyi +++ b/stdlib/@python2/ftplib.pyi @@ -101,7 +101,7 @@ class FTP_TLS(FTP): 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: str | None diff --git a/stdlib/@python2/gettext.pyi b/stdlib/@python2/gettext.pyi index 8d6c427dafeb..c8ecde4f4a8c 100644 --- a/stdlib/@python2/gettext.pyi +++ b/stdlib/@python2/gettext.pyi @@ -33,13 +33,13 @@ class GNUTranslations(NullTranslations): BE_MAGIC: int def find( - domain: str, localedir: str | None = ..., languages: Optional[Sequence[str]] = ..., all: Any = ... -) -> Optional[str | List[str]]: ... + domain: str, localedir: str | None = ..., languages: Sequence[str] | None = ..., all: Any = ... +) -> str | List[str] | None: ... def translation( domain: str, localedir: str | None = ..., - languages: Optional[Sequence[str]] = ..., - class_: Optional[Type[NullTranslations]] = ..., + languages: Sequence[str] | None = ..., + class_: Type[NullTranslations] | None = ..., fallback: bool = ..., codeset: str | None = ..., ) -> NullTranslations: ... diff --git a/stdlib/@python2/imaplib.pyi b/stdlib/@python2/imaplib.pyi index 1535b50a9117..e893457c050b 100644 --- a/stdlib/@python2/imaplib.pyi +++ b/stdlib/@python2/imaplib.pyi @@ -19,7 +19,7 @@ class IMAP4: debug: int = ... state: str = ... literal: Text | None = ... - tagged_commands: Dict[bytes, Optional[List[bytes]]] + tagged_commands: Dict[bytes, List[bytes] | None] untagged_responses: Dict[str, List[bytes | Tuple[bytes, bytes]]] continuation_response: str = ... is_readonly: bool = ... diff --git a/stdlib/@python2/inspect.pyi b/stdlib/@python2/inspect.pyi index 400ccabbfcc7..f892a50ae252 100644 --- a/stdlib/@python2/inspect.pyi +++ b/stdlib/@python2/inspect.pyi @@ -103,10 +103,10 @@ class Traceback(NamedTuple): filename: str lineno: int function: str - code_context: Optional[List[str]] + code_context: List[str] | None index: int | None # type: ignore -_FrameInfo = Tuple[FrameType, str, int, str, Optional[List[str]], int | None] +_FrameInfo = Tuple[FrameType, str, int, str, List[str] | None, int | None] def getouterframes(frame: FrameType, context: int = ...) -> List[_FrameInfo]: ... def getframeinfo(frame: FrameType | TracebackType, context: int = ...) -> Traceback: ... diff --git a/stdlib/@python2/json.pyi b/stdlib/@python2/json.pyi index cbc1fdead816..1e0927ab7b37 100644 --- a/stdlib/@python2/json.pyi +++ b/stdlib/@python2/json.pyi @@ -7,9 +7,9 @@ def dumps( ensure_ascii: bool = ..., check_circular: bool = ..., allow_nan: bool = ..., - cls: Optional[Type[JSONEncoder]] = ..., + cls: Type[JSONEncoder] | None = ..., indent: int | None = ..., - separators: Optional[Tuple[str, str]] = ..., + separators: Tuple[str, str] | None = ..., encoding: str = ..., default: Optional[Callable[[Any], Any]] = ..., sort_keys: bool = ..., @@ -22,9 +22,9 @@ def dump( ensure_ascii: bool = ..., check_circular: bool = ..., allow_nan: bool = ..., - cls: Optional[Type[JSONEncoder]] = ..., + cls: Type[JSONEncoder] | None = ..., indent: int | None = ..., - separators: Optional[Tuple[str, str]] = ..., + separators: Tuple[str, str] | None = ..., encoding: str = ..., default: Optional[Callable[[Any], Any]] = ..., sort_keys: bool = ..., @@ -33,7 +33,7 @@ def dump( def loads( s: Text | bytes, encoding: Any = ..., - cls: Optional[Type[JSONDecoder]] = ..., + cls: Type[JSONDecoder] | None = ..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ..., parse_float: Optional[Callable[[str], Any]] = ..., parse_int: Optional[Callable[[str], Any]] = ..., @@ -44,7 +44,7 @@ def loads( def load( fp: SupportsRead[Text | bytes], encoding: str | None = ..., - cls: Optional[Type[JSONDecoder]] = ..., + cls: Type[JSONDecoder] | None = ..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ..., parse_float: Optional[Callable[[str], Any]] = ..., parse_int: Optional[Callable[[str], Any]] = ..., diff --git a/stdlib/@python2/lib2to3/pgen2/pgen.pyi b/stdlib/@python2/lib2to3/pgen2/pgen.pyi index 9bc88b26f10e..afe44deeacb1 100644 --- a/stdlib/@python2/lib2to3/pgen2/pgen.pyi +++ b/stdlib/@python2/lib2to3/pgen2/pgen.pyi @@ -10,7 +10,7 @@ class ParserGenerator: stream: IO[Text] generator: Iterator[_TokenInfo] first: Dict[Text, Dict[Text, int]] - def __init__(self, filename: StrPath, stream: Optional[IO[Text]] = ...) -> None: ... + def __init__(self, filename: StrPath, stream: IO[Text] | None = ...) -> None: ... def make_grammar(self) -> PgenGrammar: ... def make_first(self, c: PgenGrammar, name: Text) -> Dict[int, int]: ... def make_label(self, c: PgenGrammar, label: Text) -> int: ... diff --git a/stdlib/@python2/lib2to3/pytree.pyi b/stdlib/@python2/lib2to3/pytree.pyi index 9c1e6d2928de..4e5badd58e8b 100644 --- a/stdlib/@python2/lib2to3/pytree.pyi +++ b/stdlib/@python2/lib2to3/pytree.pyi @@ -5,7 +5,7 @@ _P = TypeVar("_P") _NL = Node | Leaf _Context = Tuple[Text, int, int] _Results = Dict[Text, _NL] -_RawNode = Tuple[int, Text, _Context, Optional[List[_NL]]] +_RawNode = Tuple[int, Text, _Context, List[_NL] | None] _Convert = Callable[[Grammar, _RawNode], Any] HUGE: int @@ -46,7 +46,7 @@ class Node(Base): children: List[_NL], context: Any | None = ..., prefix: Text | None = ..., - fixers_applied: Optional[List[Any]] = ..., + fixers_applied: List[Any] | None = ..., ) -> None: ... def set_child(self, i: int, child: _NL) -> None: ... def insert_child(self, i: int, child: _NL) -> None: ... diff --git a/stdlib/@python2/logging/__init__.pyi b/stdlib/@python2/logging/__init__.pyi index 9cd2adceab9d..3c3b1d7430bc 100644 --- a/stdlib/@python2/logging/__init__.pyi +++ b/stdlib/@python2/logging/__init__.pyi @@ -40,30 +40,30 @@ class Logger(Filterer): def getEffectiveLevel(self) -> int: ... def getChild(self, suffix: str) -> Logger: ... def debug( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... def info( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... def warning( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... warn = warning def error( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... def critical( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... fatal = critical def log( - self, level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + self, level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... def exception( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... def _log( - self, level: int, msg: Any, args: _ArgsType, exc_info: _ExcInfoType | None = ..., extra: Optional[Dict[str, Any]] = ... + self, level: int, msg: Any, args: _ArgsType, exc_info: _ExcInfoType | None = ..., extra: Dict[str, Any] | None = ... ) -> None: ... # undocumented def filter(self, record: LogRecord) -> bool: ... def addHandler(self, hdlr: Handler) -> None: ... @@ -80,7 +80,7 @@ class Logger(Filterer): args: _ArgsType, exc_info: _SysExcInfoType | None, func: str | None = ..., - extra: Optional[Mapping[str, Any]] = ..., + extra: Mapping[str, Any] | None = ..., ) -> LogRecord: ... CRITICAL: int @@ -165,25 +165,25 @@ class LoggerAdapter: def __init__(self, logger: Logger, extra: Mapping[str, Any]) -> None: ... def process(self, msg: Any, kwargs: MutableMapping[str, Any]) -> Tuple[Any, MutableMapping[str, Any]]: ... def debug( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... def info( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... def warning( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... def error( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... def exception( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... def critical( - self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... def log( - self, level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + self, level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... def isEnabledFor(self, level: int) -> bool: ... @@ -192,21 +192,21 @@ def getLogger() -> Logger: ... @overload def getLogger(name: Text | str) -> Logger: ... def getLoggerClass() -> type: ... -def debug(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> None: ... -def info(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> None: ... -def warning(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> None: ... +def debug(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any) -> None: ... +def info(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any) -> None: ... +def warning(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any) -> None: ... warn = warning -def error(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> None: ... +def error(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any) -> None: ... def critical( - msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... def exception( - msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... def log( - level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any + level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... fatal = critical @@ -233,7 +233,7 @@ def captureWarnings(capture: bool) -> None: ... class StreamHandler(Handler): stream: IO[str] # undocumented - def __init__(self, stream: Optional[IO[str]] = ...) -> None: ... + def __init__(self, stream: IO[str] | None = ...) -> None: ... class FileHandler(StreamHandler): baseFilename: str # undocumented diff --git a/stdlib/@python2/logging/config.pyi b/stdlib/@python2/logging/config.pyi index 196588c54622..5f1f5e4bb218 100644 --- a/stdlib/@python2/logging/config.pyi +++ b/stdlib/@python2/logging/config.pyi @@ -6,7 +6,7 @@ _Path = StrPath def dictConfig(config: Dict[str, Any]) -> None: ... def fileConfig( - fname: str | IO[str], defaults: Optional[Dict[str, str]] = ..., disable_existing_loggers: bool = ... + fname: str | IO[str], defaults: Dict[str, str] | None = ..., disable_existing_loggers: bool = ... ) -> None: ... def listen(port: int = ...) -> Thread: ... def stopListening() -> None: ... diff --git a/stdlib/@python2/logging/handlers.pyi b/stdlib/@python2/logging/handlers.pyi index b4ed36de3653..f979b54d36f8 100644 --- a/stdlib/@python2/logging/handlers.pyi +++ b/stdlib/@python2/logging/handlers.pyi @@ -111,7 +111,7 @@ class SMTPHandler(Handler): fromaddr: str, toaddrs: List[str], subject: str, - credentials: Optional[Tuple[str, str]] = ..., + credentials: Tuple[str, str] | None = ..., secure: Tuple[str] | Tuple[str, str] | None = ..., ) -> None: ... def getSubject(self, record: LogRecord) -> str: ... diff --git a/stdlib/@python2/mailbox.pyi b/stdlib/@python2/mailbox.pyi index 2477e0a6480e..8ee13710f659 100644 --- a/stdlib/@python2/mailbox.pyi +++ b/stdlib/@python2/mailbox.pyi @@ -137,7 +137,7 @@ class MaildirMessage(Message): class _mboxMMDFMessage(Message): def get_from(self) -> str: ... def set_from( - self, from_: str, time_: Optional[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: ... @@ -175,7 +175,7 @@ class _ProxyFile(Generic[AnyStr]): def close(self) -> None: ... def __enter__(self) -> _ProxyFile[AnyStr]: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc: BaseException | None, tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None ) -> None: ... def readable(self) -> bool: ... def writable(self) -> bool: ... diff --git a/stdlib/@python2/mimetypes.pyi b/stdlib/@python2/mimetypes.pyi index d1fa53c0f871..85e720738aae 100644 --- a/stdlib/@python2/mimetypes.pyi +++ b/stdlib/@python2/mimetypes.pyi @@ -4,8 +4,8 @@ from typing import IO, Dict, List, Optional, Sequence, Text, Tuple def guess_type(url: Text, strict: bool = ...) -> Tuple[str | None, str | None]: ... def guess_all_extensions(type: str, strict: bool = ...) -> List[str]: ... def guess_extension(type: str, strict: bool = ...) -> str | None: ... -def init(files: Optional[Sequence[str]] = ...) -> None: ... -def read_mime_types(file: str) -> Optional[Dict[str, str]]: ... +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 diff --git a/stdlib/@python2/modulefinder.pyi b/stdlib/@python2/modulefinder.pyi index 4e7b2f5fd12c..6331d5cf5080 100644 --- a/stdlib/@python2/modulefinder.pyi +++ b/stdlib/@python2/modulefinder.pyi @@ -31,7 +31,7 @@ class ModuleFinder: replace_paths: Sequence[Tuple[str, str]] # undocumented def __init__( self, - path: Optional[List[str]] = ..., + path: List[str] | None = ..., debug: int = ..., excludes: Container[str] = ..., replace_paths: Sequence[Tuple[str, str]] = ..., @@ -42,7 +42,7 @@ class ModuleFinder: def run_script(self, pathname: str) -> None: ... def load_file(self, pathname: str) -> None: ... # undocumented def import_hook( - self, name: str, caller: Module | None = ..., fromlist: Optional[List[str]] = ..., level: int = ... + 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 @@ -56,7 +56,7 @@ class ModuleFinder: def add_module(self, fqname: str) -> Module: ... # undocumented def find_module( self, name: str, path: str | None, parent: Module | None = ... - ) -> Tuple[Optional[IO[Any]], str | None, Tuple[str, str, int]]: ... # undocumented + ) -> Tuple[IO[Any] | None, str | None, Tuple[str, str, int]]: ... # undocumented def report(self) -> None: ... def any_missing(self) -> List[str]: ... # undocumented def any_missing_maybe(self) -> Tuple[List[str], List[str]]: ... # undocumented diff --git a/stdlib/@python2/msilib/__init__.pyi b/stdlib/@python2/msilib/__init__.pyi index ea3eaa1b8b8b..802f7f2f9358 100644 --- a/stdlib/@python2/msilib/__init__.pyi +++ b/stdlib/@python2/msilib/__init__.pyi @@ -90,7 +90,7 @@ if sys.platform == "win32": def add_file( 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: diff --git a/stdlib/@python2/multiprocessing/__init__.pyi b/stdlib/@python2/multiprocessing/__init__.pyi index e71d1c9c77b4..7f178bf85a94 100644 --- a/stdlib/@python2/multiprocessing/__init__.pyi +++ b/stdlib/@python2/multiprocessing/__init__.pyi @@ -44,7 +44,7 @@ def Value(typecode_or_type, *args, **kwds): ... def Array(typecode_or_type, size_or_initializer, **kwds): ... def Pool( processes: int | None = ..., - initializer: Optional[Callable[..., Any]] = ..., + initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ..., maxtasksperchild: int | None = ..., ) -> pool.Pool: ... diff --git a/stdlib/@python2/multiprocessing/dummy/connection.pyi b/stdlib/@python2/multiprocessing/dummy/connection.pyi index 73789028611e..141ef3e3d85d 100644 --- a/stdlib/@python2/multiprocessing/dummy/connection.pyi +++ b/stdlib/@python2/multiprocessing/dummy/connection.pyi @@ -15,7 +15,7 @@ class Connection(object): def poll(self, timeout=...) -> Any: ... class Listener(object): - _backlog_queue: Optional[Queue[Any]] + _backlog_queue: Queue[Any] | None address: Any def __init__(self, address=..., family=..., backlog=...) -> None: ... def accept(self) -> Connection: ... diff --git a/stdlib/@python2/multiprocessing/pool.pyi b/stdlib/@python2/multiprocessing/pool.pyi index b517073eb88e..d454a3308b5d 100644 --- a/stdlib/@python2/multiprocessing/pool.pyi +++ b/stdlib/@python2/multiprocessing/pool.pyi @@ -18,7 +18,7 @@ class Pool(object): def __init__( self, processes: int | None = ..., - initializer: Optional[Callable[..., None]] = ..., + initializer: Callable[..., None] | None = ..., initargs: Iterable[Any] = ..., maxtasksperchild: int | None = ..., ) -> None: ... @@ -28,7 +28,7 @@ class Pool(object): func: Callable[..., Any], args: Iterable[Any] = ..., kwds: Dict[str, Any] = ..., - callback: Optional[Callable[..., None]] = ..., + callback: Callable[..., None] | None = ..., ) -> AsyncResult: ... def map(self, func: Callable[..., Any], iterable: Iterable[Any] = ..., chunksize: int | None = ...) -> List[Any]: ... def map_async( @@ -36,7 +36,7 @@ class Pool(object): func: Callable[..., Any], iterable: Iterable[Any] = ..., chunksize: int | None = ..., - callback: Optional[Callable[..., None]] = ..., + callback: Callable[..., None] | None = ..., ) -> AsyncResult: ... def imap(self, func: Callable[..., Any], iterable: Iterable[Any] = ..., chunksize: int | None = ...) -> IMapIterator: ... def imap_unordered( @@ -48,5 +48,5 @@ class Pool(object): class ThreadPool(Pool): def __init__( - self, processes: int | None = ..., initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ... + self, processes: int | None = ..., initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ... ) -> None: ... diff --git a/stdlib/@python2/optparse.pyi b/stdlib/@python2/optparse.pyi index ac723a745849..72ffd28e86a2 100644 --- a/stdlib/@python2/optparse.pyi +++ b/stdlib/@python2/optparse.pyi @@ -92,9 +92,9 @@ class Option: default: Any nargs: int type: Any - callback: Optional[Callable[..., Any]] - callback_args: Optional[Tuple[Any, ...]] - callback_kwargs: Optional[Dict[_Text, Any]] + callback: Callable[..., Any] | None + callback_args: Tuple[Any, ...] | None + callback_kwargs: Dict[_Text, Any] | None help: _Text | None metavar: _Text | None def __init__(self, *opts: _Text | None, **attrs: Any) -> None: ... @@ -153,7 +153,7 @@ class OptionGroup(OptionContainer): def set_title(self, title: _Text) -> 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[_Text, Any], mode: Any) -> None: ... def _update_careful(self, dict: Mapping[_Text, Any]) -> None: ... def _update_loose(self, dict: Mapping[_Text, Any]) -> None: ... @@ -167,12 +167,12 @@ class OptionParser(OptionContainer): allow_interspersed_args: bool epilog: _Text | None formatter: HelpFormatter - largs: Optional[List[_Text]] + largs: List[_Text] | None option_groups: List[OptionGroup] option_list: List[Option] process_default_values: Any prog: _Text | None - rargs: Optional[List[Any]] + rargs: List[Any] | None standard_option_list: List[Option] usage: _Text | None values: Values | None @@ -180,7 +180,7 @@ class OptionParser(OptionContainer): def __init__( self, usage: _Text | None = ..., - option_list: Optional[Iterable[Option]] = ..., + option_list: Iterable[Option] | None = ..., option_class: Type[Option] = ..., version: _Text | None = ..., conflict_handler: _Text = ..., @@ -220,11 +220,11 @@ class OptionParser(OptionContainer): def get_usage(self) -> _Text: ... def get_version(self) -> _Text: ... def parse_args( - self, args: Optional[Sequence[AnyStr]] = ..., values: Values | None = ... + 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/@python2/os/__init__.pyi b/stdlib/@python2/os/__init__.pyi index 91f05a2b781f..9d95eba9b00b 100644 --- a/stdlib/@python2/os/__init__.pyi +++ b/stdlib/@python2/os/__init__.pyi @@ -231,7 +231,7 @@ def symlink(source: Text, link_name: Text) -> None: ... def unlink(path: Text) -> None: ... # TODO: add ns, dir_fd, follow_symlinks argument -def utime(path: Text, times: Optional[Tuple[float, float]]) -> None: ... +def utime(path: Text, times: Tuple[float, float] | None) -> None: ... if sys.platform != "win32": # Unix only diff --git a/stdlib/@python2/pdb.pyi b/stdlib/@python2/pdb.pyi index f639098985e4..78955452f2ae 100644 --- a/stdlib/@python2/pdb.pyi +++ b/stdlib/@python2/pdb.pyi @@ -9,8 +9,8 @@ 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) -> _T | None: ... def set_trace() -> None: ... @@ -39,9 +39,9 @@ class Pdb(Bdb, Cmd): 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 = ..., ) -> None: ... def forget(self) -> None: ... def setup(self, f: FrameType | None, tb: TracebackType | None) -> None: ... @@ -161,7 +161,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: ... diff --git a/stdlib/@python2/pickle.pyi b/stdlib/@python2/pickle.pyi index 07e32e64b449..4e3740ccc363 100644 --- a/stdlib/@python2/pickle.pyi +++ b/stdlib/@python2/pickle.pyi @@ -16,8 +16,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: diff --git a/stdlib/@python2/pickletools.pyi b/stdlib/@python2/pickletools.pyi index 678aed72ec23..e6163e574202 100644 --- a/stdlib/@python2/pickletools.pyi +++ b/stdlib/@python2/pickletools.pyi @@ -121,7 +121,7 @@ def genops(pickle: bytes | IO[bytes]) -> Iterator[Tuple[OpcodeInfo, Any | None, def optimize(p: bytes | IO[bytes]) -> bytes: ... def dis( pickle: bytes | IO[bytes], - out: Optional[IO[str]] = ..., - memo: Optional[MutableMapping[int, Any]] = ..., + out: IO[str] | None = ..., + memo: MutableMapping[int, Any] | None = ..., indentlevel: int = ..., ) -> None: ... diff --git a/stdlib/@python2/pkgutil.pyi b/stdlib/@python2/pkgutil.pyi index 2e335061051f..9ff53ad6272d 100644 --- a/stdlib/@python2/pkgutil.pyi +++ b/stdlib/@python2/pkgutil.pyi @@ -19,9 +19,9 @@ 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[MetaPathFinder | PathEntryFinder]: ... -def iter_modules(path: Optional[Iterable[str]] = ..., prefix: str = ...) -> Iterator[_ModuleInfoLike]: ... +def iter_modules(path: Iterable[str] | None = ..., prefix: str = ...) -> Iterator[_ModuleInfoLike]: ... 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: Optional[Callable[[str], None]] = ... ) -> Iterator[_ModuleInfoLike]: ... def get_data(package: str, resource: str) -> bytes | None: ... diff --git a/stdlib/@python2/posix.pyi b/stdlib/@python2/posix.pyi index 8a4bd5586938..c6637a5d72bb 100644 --- a/stdlib/@python2/posix.pyi +++ b/stdlib/@python2/posix.pyi @@ -190,7 +190,7 @@ def uname() -> Tuple[str, str, str, str, str]: ... def unlink(path: unicode) -> None: ... def unsetenv(varname: str) -> None: ... def urandom(n: int) -> str: ... -def utime(path: unicode, times: Optional[Tuple[int, int]]) -> None: ... +def utime(path: unicode, times: Tuple[int, int] | None) -> None: ... def wait() -> int: ... _r = Tuple[float, float, int, int, int, int, int, int, int, int, int, int, int, int, int, int] diff --git a/stdlib/@python2/pprint.pyi b/stdlib/@python2/pprint.pyi index 3935536370c0..8d1f795709e7 100644 --- a/stdlib/@python2/pprint.pyi +++ b/stdlib/@python2/pprint.pyi @@ -2,7 +2,7 @@ from typing import IO, Any, Dict, Optional, Tuple def pformat(object: object, indent: int = ..., width: int = ..., depth: int | None = ...) -> str: ... def pprint( - object: object, stream: Optional[IO[str]] = ..., indent: int = ..., width: int = ..., depth: int | None = ... + object: object, stream: IO[str] | None = ..., indent: int = ..., width: int = ..., depth: int | None = ... ) -> None: ... def isreadable(object: object) -> bool: ... def isrecursive(object: object) -> bool: ... @@ -10,7 +10,7 @@ def saferepr(object: object) -> str: ... class PrettyPrinter: def __init__( - self, indent: int = ..., width: int = ..., depth: int | None = ..., stream: Optional[IO[str]] = ... + self, indent: int = ..., width: int = ..., depth: int | None = ..., stream: IO[str] | None = ... ) -> None: ... def pformat(self, object: object) -> str: ... def pprint(self, object: object) -> None: ... diff --git a/stdlib/@python2/pstats.pyi b/stdlib/@python2/pstats.pyi index c8cd53367b3b..adea69a4603a 100644 --- a/stdlib/@python2/pstats.pyi +++ b/stdlib/@python2/pstats.pyi @@ -11,7 +11,7 @@ class Stats: self: _T, __arg: Union[None, str, Text, Profile, _cProfile] = ..., *args: Union[None, str, Text, Profile, _cProfile, _T], - stream: Optional[IO[Any]] = ..., + stream: IO[Any] | None = ..., ) -> None: ... def init(self, arg: Union[None, str, Text, Profile, _cProfile]) -> None: ... def load_stats(self, arg: Union[None, str, Text, Profile, _cProfile]) -> None: ... diff --git a/stdlib/@python2/py_compile.pyi b/stdlib/@python2/py_compile.pyi index cf77352bbee3..c08e98833356 100644 --- a/stdlib/@python2/py_compile.pyi +++ b/stdlib/@python2/py_compile.pyi @@ -12,4 +12,4 @@ class PyCompileError(Exception): def compile( file: _EitherStr, cfile: _EitherStr | None = ..., dfile: _EitherStr | None = ..., doraise: bool = ... ) -> None: ... -def main(args: Optional[List[Text]] = ...) -> int: ... +def main(args: List[Text] | None = ...) -> int: ... diff --git a/stdlib/@python2/pyclbr.pyi b/stdlib/@python2/pyclbr.pyi index 56a987d72402..097a113d041e 100644 --- a/stdlib/@python2/pyclbr.pyi +++ b/stdlib/@python2/pyclbr.pyi @@ -3,11 +3,11 @@ from typing import Dict, List, Optional, Sequence, Union class Class: module: str name: str - super: Optional[List[Class | str]] + super: List[Class | str] | None methods: Dict[str, int] file: int lineno: int - def __init__(self, module: str, name: str, super: Optional[List[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 @@ -16,5 +16,5 @@ class Function: lineno: int 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, 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/@python2/pydoc.pyi b/stdlib/@python2/pydoc.pyi index 625fd3b32497..97b6a37f678d 100644 --- a/stdlib/@python2/pydoc.pyi +++ b/stdlib/@python2/pydoc.pyi @@ -21,7 +21,7 @@ from typing import ( from repr import Repr # the return type of sys.exc_info(), used by ErrorDuringImport.__init__ -_Exc_Info = Tuple[Optional[Type[BaseException]], BaseException | None, TracebackType | None] +_Exc_Info = Tuple[Type[BaseException] | None, BaseException | None, TracebackType | None] __author__: str __date__: str @@ -37,7 +37,7 @@ 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: object | None = ...) -> 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]) -> AnyStr | None: ... @@ -45,7 +45,7 @@ def synopsis(filename: str, cache: MutableMapping[str, Tuple[int, str]] = ...) - class ErrorDuringImport(Exception): filename: str - exc: Optional[Type[BaseException]] + exc: Type[BaseException] | None value: BaseException | None tb: TracebackType | None def __init__(self, filename: str, exc_info: _Exc_Info) -> None: ... @@ -144,7 +144,7 @@ class HTMLDoc(Doc): def docdata( 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): @@ -209,10 +209,10 @@ html: HTMLDoc class _OldStyleClass: ... -def resolve(thing: str | object, forceload: bool = ...) -> Optional[Tuple[object, 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: 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: str | object, forceload: bool = ...) -> None: ... def writedocs(dir: str, pkgpath: str = ..., done: Any | None = ...) -> None: ... @@ -221,7 +221,7 @@ class Helper: keywords: Dict[str, str | Tuple[str, str]] symbols: Dict[str, str] topics: Dict[str, str | Tuple[str, ...]] - def __init__(self, input: Optional[IO[str]] = ..., output: Optional[IO[str]] = ...) -> None: ... + def __init__(self, input: IO[str] | None = ..., output: IO[str] | None = ...) -> None: ... input: IO[str] output: IO[str] def __call__(self, request: str | Helper | object = ...) -> None: ... diff --git a/stdlib/@python2/pyexpat/__init__.pyi b/stdlib/@python2/pyexpat/__init__.pyi index b291b5b513f1..324b8a02e5ac 100644 --- a/stdlib/@python2/pyexpat/__init__.pyi +++ b/stdlib/@python2/pyexpat/__init__.pyi @@ -75,5 +75,5 @@ def ErrorString(__code: int) -> str: ... # intern is undocumented def ParserCreate( - encoding: Text | None = ..., namespace_separator: Text | None = ..., intern: Optional[Dict[str, Any]] = ... + encoding: Text | None = ..., namespace_separator: Text | None = ..., intern: Dict[str, Any] | None = ... ) -> XMLParserType: ... diff --git a/stdlib/@python2/re.pyi b/stdlib/@python2/re.pyi index 84dfdae5c61a..8ed31dd028ac 100644 --- a/stdlib/@python2/re.pyi +++ b/stdlib/@python2/re.pyi @@ -24,13 +24,13 @@ def compile(pattern: AnyStr, flags: int = ...) -> Pattern[AnyStr]: ... @overload def compile(pattern: Pattern[AnyStr], flags: int = ...) -> Pattern[AnyStr]: ... @overload -def search(pattern: str | unicode, string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... +def search(pattern: str | unicode, string: AnyStr, flags: int = ...) -> Match[AnyStr] | None: ... @overload -def search(pattern: Pattern[str] | Pattern[unicode], string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... +def search(pattern: Pattern[str] | Pattern[unicode], string: AnyStr, flags: int = ...) -> Match[AnyStr] | None: ... @overload -def match(pattern: str | unicode, string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... +def match(pattern: str | unicode, string: AnyStr, flags: int = ...) -> Match[AnyStr] | None: ... @overload -def match(pattern: Pattern[str] | Pattern[unicode], string: AnyStr, flags: int = ...) -> Optional[Match[AnyStr]]: ... +def match(pattern: Pattern[str] | Pattern[unicode], string: AnyStr, flags: int = ...) -> Match[AnyStr] | None: ... @overload def split(pattern: str | unicode, string: AnyStr, maxsplit: int = ..., flags: int = ...) -> List[AnyStr]: ... @overload diff --git a/stdlib/@python2/rlcompleter.pyi b/stdlib/@python2/rlcompleter.pyi index 57c6682c72bf..1aea1d267087 100644 --- a/stdlib/@python2/rlcompleter.pyi +++ b/stdlib/@python2/rlcompleter.pyi @@ -3,5 +3,5 @@ from typing import Any, Dict, Optional, Union _Text = str | unicode class Completer: - def __init__(self, namespace: Optional[Dict[str, Any]] = ...) -> None: ... + def __init__(self, namespace: Dict[str, Any] | None = ...) -> None: ... def complete(self, text: _Text, state: int) -> str | None: ... diff --git a/stdlib/@python2/select.pyi b/stdlib/@python2/select.pyi index 6bc40c8ce4c2..d07aec390d0b 100644 --- a/stdlib/@python2/select.pyi +++ b/stdlib/@python2/select.pyi @@ -53,7 +53,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: float | None = ... + self, __changelist: Iterable[kevent] | None, __maxevents: int, __timeout: float | None = ... ) -> List[kevent]: ... def fileno(self) -> int: ... @classmethod diff --git a/stdlib/@python2/sets.pyi b/stdlib/@python2/sets.pyi index d617b2d89bfc..19e09d9f316b 100644 --- a/stdlib/@python2/sets.pyi +++ b/stdlib/@python2/sets.pyi @@ -33,11 +33,11 @@ class BaseSet(Iterable[_T]): def __gt__(self, other: BaseSet[_T]) -> bool: ... class ImmutableSet(BaseSet[_T], Hashable): - def __init__(self, iterable: Optional[_Setlike[_T]] = ...) -> None: ... + def __init__(self, iterable: _Setlike[_T] | None = ...) -> None: ... def __hash__(self) -> int: ... class Set(BaseSet[_T]): - def __init__(self, iterable: Optional[_Setlike[_T]] = ...) -> None: ... + def __init__(self, iterable: _Setlike[_T] | None = ...) -> None: ... def __ior__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ... def union_update(self, other: _Setlike[_T]) -> None: ... def __iand__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ... diff --git a/stdlib/@python2/site.pyi b/stdlib/@python2/site.pyi index 9c8c3e363770..d9f8da8a7e2d 100644 --- a/stdlib/@python2/site.pyi +++ b/stdlib/@python2/site.pyi @@ -6,7 +6,7 @@ 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/@python2/socket.pyi b/stdlib/@python2/socket.pyi index 5098d459164c..e981fe43eacc 100644 --- a/stdlib/@python2/socket.pyi +++ b/stdlib/@python2/socket.pyi @@ -430,7 +430,7 @@ class socket: def create_connection( address: Tuple[str | None, int], timeout: float | None = ..., - source_address: Optional[Tuple[bytearray | bytes | Text, int]] = ..., + source_address: Tuple[bytearray | bytes | Text, int] | None = ..., ) -> socket: ... def fromfd(fd: int, family: int, type: int, proto: int = ...) -> socket: ... diff --git a/stdlib/@python2/sqlite3/dbapi2.pyi b/stdlib/@python2/sqlite3/dbapi2.pyi index e78d3cb2a435..423c91678a47 100644 --- a/stdlib/@python2/sqlite3/dbapi2.pyi +++ b/stdlib/@python2/sqlite3/dbapi2.pyi @@ -67,7 +67,7 @@ def connect( detect_types: int = ..., isolation_level: str | None = ..., check_same_thread: bool = ..., - factory: Optional[Type[Connection]] = ..., + factory: Type[Connection] | None = ..., cached_statements: int = ..., ) -> Connection: ... def enable_callback_tracebacks(__enable: bool) -> None: ... diff --git a/stdlib/@python2/ssl.pyi b/stdlib/@python2/ssl.pyi index 35d0d54c6f49..5fb9864c59ca 100644 --- a/stdlib/@python2/ssl.pyi +++ b/stdlib/@python2/ssl.pyi @@ -173,7 +173,7 @@ class SSLSocket(socket.socket): proto: int = ..., fileno: int | None = ..., suppress_ragged_eofs: bool = ..., - npn_protocols: Optional[Iterable[str]] = ..., + npn_protocols: Iterable[str] | None = ..., ciphers: str | None = ..., server_hostname: str | None = ..., _context: SSLContext | None = ..., @@ -200,7 +200,7 @@ class SSLSocket(socket.socket): 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 cipher(self) -> 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: ... diff --git a/stdlib/@python2/stringold.pyi b/stdlib/@python2/stringold.pyi index 271da8357c70..adb09eb2b789 100644 --- a/stdlib/@python2/stringold.pyi +++ b/stdlib/@python2/stringold.pyi @@ -8,7 +8,7 @@ digits: str hexdigits: str octdigits: str _idmap: str -_idmapL: Optional[List[str]] +_idmapL: List[str] | None index_error = ValueError atoi_error = ValueError atof_error = ValueError diff --git a/stdlib/@python2/subprocess.pyi b/stdlib/@python2/subprocess.pyi index 0d26eaf63efb..20cff6a7df32 100644 --- a/stdlib/@python2/subprocess.pyi +++ b/stdlib/@python2/subprocess.pyi @@ -71,9 +71,9 @@ class CalledProcessError(Exception): _T = TypeVar("_T", bound=bytes) class Popen(Generic[_T]): - stdin: Optional[IO[bytes]] - stdout: Optional[IO[bytes]] - stderr: Optional[IO[bytes]] + stdin: IO[bytes] | None + stdout: IO[bytes] | None + stderr: IO[bytes] | None pid: int returncode: int def __new__( diff --git a/stdlib/@python2/sunau.pyi b/stdlib/@python2/sunau.pyi index 049416505bb3..24034b0183e9 100644 --- a/stdlib/@python2/sunau.pyi +++ b/stdlib/@python2/sunau.pyi @@ -23,7 +23,7 @@ _sunau_params = Tuple[int, int, int, int, str, str] class Au_read: def __init__(self, f: _File) -> 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: ... diff --git a/stdlib/@python2/symtable.pyi b/stdlib/@python2/symtable.pyi index c7b8092aedbb..96a56b727902 100644 --- a/stdlib/@python2/symtable.pyi +++ b/stdlib/@python2/symtable.pyi @@ -28,7 +28,7 @@ class Class(SymbolTable): def get_methods(self) -> Tuple[str, ...]: ... class Symbol(object): - 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/@python2/sysconfig.pyi b/stdlib/@python2/sysconfig.pyi index bd923405e4e0..dcecf4ffd80e 100644 --- a/stdlib/@python2/sysconfig.pyi +++ b/stdlib/@python2/sysconfig.pyi @@ -7,11 +7,11 @@ def get_config_vars() -> Dict[str, Any]: ... 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 | None: ... -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 | None: ... +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/@python2/tarfile.pyi b/stdlib/@python2/tarfile.pyi index f6ef8cafe65f..3e10b9d53d59 100644 --- a/stdlib/@python2/tarfile.pyi +++ b/stdlib/@python2/tarfile.pyi @@ -52,16 +52,16 @@ TAR_GZIPPED: int def open( name: Text | None = ..., mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., + fileobj: IO[bytes] | None = ..., bufsize: int = ..., *, format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., errors: str = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., compresslevel: int | None = ..., @@ -74,7 +74,7 @@ class TarFile(Iterable[TarInfo]): OPEN_METH: Mapping[str, str] name: Text | None mode: str - fileobj: Optional[IO[bytes]] + fileobj: IO[bytes] | None format: int | None tarinfo: Type[TarInfo] dereference: bool | None @@ -82,7 +82,7 @@ class TarFile(Iterable[TarInfo]): encoding: str | None errors: str fileobject: Type[ExFileObject] - pax_headers: Optional[Mapping[str, str]] + pax_headers: Mapping[str, str] | None debug: int | None errorlevel: int | None offset: int # undocumented @@ -91,21 +91,21 @@ class TarFile(Iterable[TarInfo]): self, name: Text | None = ..., mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., + fileobj: IO[bytes] | None = ..., format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., errors: str = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., copybufsize: int | None = ..., # undocumented ) -> None: ... def __enter__(self) -> TarFile: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __iter__(self) -> Iterator[TarInfo]: ... @classmethod @@ -113,16 +113,16 @@ class TarFile(Iterable[TarInfo]): cls, name: Text | None = ..., mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., + fileobj: IO[bytes] | None = ..., bufsize: int = ..., *, format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., errors: str = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., ) -> TarFile: ... @@ -131,15 +131,15 @@ class TarFile(Iterable[TarInfo]): cls, name: Text | None, mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., + fileobj: IO[bytes] | None = ..., *, compresslevel: int = ..., format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., ) -> TarFile: ... @@ -148,15 +148,15 @@ class TarFile(Iterable[TarInfo]): cls, name: Text | None, mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., + fileobj: IO[bytes] | None = ..., compresslevel: int = ..., *, format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., ) -> TarFile: ... @@ -165,15 +165,15 @@ class TarFile(Iterable[TarInfo]): cls, name: Text | None, mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., + fileobj: IO[bytes] | None = ..., compresslevel: int = ..., *, format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., ) -> TarFile: ... @@ -182,15 +182,15 @@ class TarFile(Iterable[TarInfo]): cls, name: Text | None, mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., + fileobj: IO[bytes] | None = ..., preset: int | None = ..., *, format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., ) -> TarFile: ... @@ -199,9 +199,9 @@ class TarFile(Iterable[TarInfo]): def getnames(self) -> List[str]: ... def list(self, verbose: bool = ...) -> None: ... def next(self) -> TarInfo | None: ... - def extractall(self, path: Text = ..., members: Optional[Iterable[TarInfo]] = ...) -> None: ... + def extractall(self, path: Text = ..., members: Iterable[TarInfo] | None = ...) -> None: ... def extract(self, member: str | TarInfo, path: Text = ...) -> None: ... - def extractfile(self, member: str | TarInfo) -> Optional[IO[bytes]]: ... + def extractfile(self, member: str | TarInfo) -> IO[bytes] | None: ... def makedir(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented def makefile(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented def makeunknown(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented @@ -219,9 +219,9 @@ class TarFile(Iterable[TarInfo]): exclude: Optional[Callable[[str], bool]] = ..., filter: Optional[Callable[[TarInfo], TarInfo | 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: str | None = ..., arcname: str | None = ..., fileobj: Optional[IO[bytes]] = ... + self, name: str | None = ..., arcname: str | None = ..., fileobj: IO[bytes] | None = ... ) -> TarInfo: ... def close(self) -> None: ... diff --git a/stdlib/@python2/telnetlib.pyi b/stdlib/@python2/telnetlib.pyi index 552606e93a93..7bd7aa9ca6c7 100644 --- a/stdlib/@python2/telnetlib.pyi +++ b/stdlib/@python2/telnetlib.pyi @@ -108,4 +108,4 @@ class Telnet: def listener(self) -> None: ... def expect( self, list: Sequence[Pattern[bytes] | bytes], timeout: float | None = ... - ) -> Tuple[int, Optional[Match[bytes]], bytes]: ... + ) -> Tuple[int, Match[bytes] | None, bytes]: ... diff --git a/stdlib/@python2/threading.pyi b/stdlib/@python2/threading.pyi index 44b81fe337bf..ab062bf200cc 100644 --- a/stdlib/@python2/threading.pyi +++ b/stdlib/@python2/threading.pyi @@ -2,7 +2,7 @@ from types import FrameType, TracebackType from typing import Any, Callable, Iterable, List, Mapping, Optional, Text, Type, TypeVar, Union # TODO recursive type -_TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] +_TF = Callable[[FrameType, str, Any], Callable[..., Any] | None] _PF = Callable[[FrameType, str, Any], None] _T = TypeVar("_T") @@ -32,10 +32,10 @@ class Thread: def __init__( self, group: None = ..., - target: Optional[Callable[..., Any]] = ..., + target: Callable[..., Any] | None = ..., name: Text | None = ..., args: Iterable[Any] = ..., - kwargs: Optional[Mapping[Text, Any]] = ..., + kwargs: Mapping[Text, Any] | None = ..., ) -> None: ... def start(self) -> None: ... def run(self) -> None: ... @@ -53,7 +53,7 @@ class Lock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... @@ -63,7 +63,7 @@ class _RLock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... @@ -74,7 +74,7 @@ class Condition: def __init__(self, lock: Lock | _RLock | None = ...) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... @@ -86,7 +86,7 @@ class Condition: class Semaphore: def __init__(self, value: int = ...) -> None: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def __enter__(self, blocking: bool = ...) -> bool: ... diff --git a/stdlib/@python2/timeit.pyi b/stdlib/@python2/timeit.pyi index 2a377eb6564e..50d56ad9ba83 100644 --- a/stdlib/@python2/timeit.pyi +++ b/stdlib/@python2/timeit.pyi @@ -8,7 +8,7 @@ default_timer: _Timer class Timer: def __init__(self, stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ...) -> 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]: ... @@ -17,4 +17,4 @@ def repeat(stmt: _stmt = ..., setup: _stmt = ..., timer: _Timer = ..., repeat: i _timerFunc = Callable[[], float] -def main(args: Optional[Sequence[str]] = ..., *, _wrap_timer: Optional[Callable[[_timerFunc], _timerFunc]] = ...) -> None: ... +def main(args: Sequence[str] | None = ..., *, _wrap_timer: Optional[Callable[[_timerFunc], _timerFunc]] = ...) -> None: ... diff --git a/stdlib/@python2/trace.pyi b/stdlib/@python2/trace.pyi index 7e42db7afa8f..b70abc7c2af6 100644 --- a/stdlib/@python2/trace.pyi +++ b/stdlib/@python2/trace.pyi @@ -10,7 +10,7 @@ class CoverageResults: def __init__( self, counts: Optional[Dict[Tuple[str, int], int]] = ..., - calledfuncs: Optional[Dict[_fileModuleFunction, int]] = ..., + calledfuncs: Dict[_fileModuleFunction, int] | None = ..., infile: StrPath | None = ..., callers: Optional[Dict[Tuple[_fileModuleFunction, _fileModuleFunction], int]] = ..., outfile: StrPath | None = ..., @@ -38,8 +38,8 @@ class Trace: def runctx( self, cmd: str | types.CodeType, - globals: Optional[Mapping[str, Any]] = ..., - locals: Optional[Mapping[str, Any]] = ..., + globals: Mapping[str, Any] | None = ..., + locals: Mapping[str, Any] | None = ..., ) -> None: ... def runfunc(self, func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... def file_module_function_of(self, frame: types.FrameType) -> _fileModuleFunction: ... diff --git a/stdlib/@python2/traceback.pyi b/stdlib/@python2/traceback.pyi index 0917b3a7a132..55c1f953c884 100644 --- a/stdlib/@python2/traceback.pyi +++ b/stdlib/@python2/traceback.pyi @@ -3,23 +3,23 @@ from typing import IO, List, Optional, Tuple, Type _PT = Tuple[str, int, str, str | None] -def print_tb(tb: TracebackType | None, limit: int | None = ..., file: Optional[IO[str]] = ...) -> None: ... +def print_tb(tb: TracebackType | None, limit: int | None = ..., file: IO[str] | None = ...) -> None: ... def print_exception( - etype: Optional[Type[BaseException]], + etype: Type[BaseException] | None, value: BaseException | None, tb: TracebackType | None, limit: int | None = ..., - file: Optional[IO[str]] = ..., + file: IO[str] | None = ..., ) -> None: ... -def print_exc(limit: int | None = ..., file: Optional[IO[str]] = ...) -> None: ... -def print_last(limit: int | None = ..., file: Optional[IO[str]] = ...) -> None: ... -def print_stack(f: FrameType | None = ..., limit: int | None = ..., file: Optional[IO[str]] = ...) -> None: ... +def print_exc(limit: int | None = ..., file: IO[str] | None = ...) -> None: ... +def print_last(limit: int | None = ..., file: IO[str] | None = ...) -> None: ... +def print_stack(f: FrameType | None = ..., limit: int | None = ..., file: IO[str] | None = ...) -> None: ... def extract_tb(tb: TracebackType | None, limit: int | None = ...) -> List[_PT]: ... def extract_stack(f: FrameType | None = ..., limit: int | None = ...) -> List[_PT]: ... def format_list(extracted_list: List[_PT]) -> List[str]: ... -def format_exception_only(etype: Optional[Type[BaseException]], value: BaseException | None) -> List[str]: ... +def format_exception_only(etype: Type[BaseException] | None, value: BaseException | None) -> List[str]: ... def format_exception( - etype: Optional[Type[BaseException]], value: BaseException | None, tb: TracebackType | None, limit: int | None = ... + etype: Type[BaseException] | None, value: BaseException | None, tb: TracebackType | None, limit: int | None = ... ) -> List[str]: ... def format_exc(limit: int | None = ...) -> str: ... def format_tb(tb: TracebackType | None, limit: int | None = ...) -> List[str]: ... diff --git a/stdlib/@python2/types.pyi b/stdlib/@python2/types.pyi index e0596ae0f49f..b1a48e63479b 100644 --- a/stdlib/@python2/types.pyi +++ b/stdlib/@python2/types.pyi @@ -27,9 +27,9 @@ class _Cell: cell_contents: Any class FunctionType: - func_closure: Optional[Tuple[_Cell, ...]] = ... + func_closure: Tuple[_Cell, ...] | None = ... func_code: CodeType = ... - func_defaults: Optional[Tuple[Any, ...]] = ... + func_defaults: Tuple[Any, ...] | None = ... func_dict: Dict[str, Any] = ... func_doc: str | None = ... func_globals: Dict[str, Any] = ... @@ -45,8 +45,8 @@ class FunctionType: code: CodeType, globals: Dict[str, Any], name: str | None = ..., - argdefs: Optional[Tuple[object, ...]] = ..., - closure: Optional[Tuple[_Cell, ...]] = ..., + argdefs: Tuple[object, ...] | None = ..., + closure: Tuple[_Cell, ...] | None = ..., ) -> None: ... def __call__(self, *args: Any, **kwargs: Any) -> Any: ... def __get__(self, obj: object | None, type: type | None) -> UnboundMethodType: ... @@ -128,7 +128,7 @@ class ModuleType: __file__: str | None __name__: str __package__: str | None - __path__: Optional[Iterable[str]] + __path__: Iterable[str] | None __dict__: Dict[str, Any] def __init__(self, name: str, doc: str | None = ...) -> None: ... diff --git a/stdlib/@python2/typing.pyi b/stdlib/@python2/typing.pyi index 4e4fbd6dd146..b0994d8fbddd 100644 --- a/stdlib/@python2/typing.pyi +++ b/stdlib/@python2/typing.pyi @@ -9,7 +9,7 @@ Any = object() class TypeVar: __name__: str - __bound__: Optional[Type[Any]] + __bound__: Type[Any] | None __constraints__: Tuple[Type[Any], ...] __covariant__: bool __contravariant__: bool @@ -17,7 +17,7 @@ class TypeVar: self, name: str, *constraints: Type[Any], - bound: Optional[Type[Any]] = ..., + bound: Type[Any] | None = ..., covariant: bool = ..., contravariant: bool = ..., ) -> None: ... @@ -264,7 +264,7 @@ class ContextManager(Protocol[_T_co]): def __enter__(self) -> _T_co: ... def __exit__( self, - __exc_type: Optional[Type[BaseException]], + __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None, ) -> bool | None: ... @@ -362,7 +362,7 @@ class IO(Iterator[AnyStr], Generic[AnyStr]): def __enter__(self) -> IO[AnyStr]: ... @abstractmethod def __exit__( - self, t: Optional[Type[BaseException]], value: BaseException | None, traceback: TracebackType | None + self, t: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> bool | None: ... class BinaryIO(IO[str]): @@ -433,8 +433,8 @@ class Pattern(Generic[AnyStr]): groupindex: Dict[AnyStr, int] groups: int pattern: AnyStr - def search(self, string: _AnyStr2, pos: int = ..., endpos: int = ...) -> Optional[Match[_AnyStr2]]: ... - def match(self, string: _AnyStr2, pos: int = ..., endpos: int = ...) -> Optional[Match[_AnyStr2]]: ... + def search(self, string: _AnyStr2, pos: int = ..., endpos: int = ...) -> Match[_AnyStr2] | None: ... + def match(self, string: _AnyStr2, pos: int = ..., endpos: int = ...) -> Match[_AnyStr2] | None: ... def split(self, string: _AnyStr2, maxsplit: int = ...) -> List[_AnyStr2]: ... # Returns either a list of _AnyStr2 or a list of tuples, depending on # whether there are groups in the pattern. @@ -452,7 +452,7 @@ class Pattern(Generic[AnyStr]): # Functions def get_type_hints( - obj: Callable[..., Any], globalns: Optional[Dict[Text, Any]] = ..., localns: Optional[Dict[Text, Any]] = ... + obj: Callable[..., Any], globalns: Dict[Text, Any] | None = ..., localns: Dict[Text, Any] | None = ... ) -> None: ... @overload def cast(tp: Type[_T], obj: Any) -> _T: ... diff --git a/stdlib/@python2/typing_extensions.pyi b/stdlib/@python2/typing_extensions.pyi index 61dcd3864f75..21d659cd7814 100644 --- a/stdlib/@python2/typing_extensions.pyi +++ b/stdlib/@python2/typing_extensions.pyi @@ -67,8 +67,8 @@ 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]: ... @@ -91,7 +91,7 @@ class ParamSpecKwargs: class ParamSpec: __name__: str - __bound__: Optional[Type[Any]] + __bound__: Type[Any] | None __covariant__: bool __contravariant__: bool def __init__( diff --git a/stdlib/@python2/unittest.pyi b/stdlib/@python2/unittest.pyi index 4fd12b43df3d..47f2820c8e08 100644 --- a/stdlib/@python2/unittest.pyi +++ b/stdlib/@python2/unittest.pyi @@ -237,7 +237,7 @@ class TextTestRunner: verbosity: int = ..., failfast: bool = ..., buffer: bool = ..., - resultclass: Optional[Type[TestResult]] = ..., + resultclass: Type[TestResult] | None = ..., ) -> None: ... def _makeResult(self) -> TestResult: ... def run(self, test: Testable) -> TestResult: ... # undocumented @@ -258,7 +258,7 @@ class TestProgram: def main( module: None | Text | types.ModuleType = ..., defaultTest: str | None = ..., - argv: Optional[Sequence[str]] = ..., + argv: Sequence[str] | None = ..., testRunner: Type[TextTestRunner] | TextTestRunner | None = ..., testLoader: TestLoader = ..., exit: bool = ..., diff --git a/stdlib/@python2/urllib2.pyi b/stdlib/@python2/urllib2.pyi index eb2deda32590..8822d4512e5b 100644 --- a/stdlib/@python2/urllib2.pyi +++ b/stdlib/@python2/urllib2.pyi @@ -97,7 +97,7 @@ class HTTPRedirectHandler(BaseHandler): class ProxyHandler(BaseHandler): proxies: Mapping[str, str] - def __init__(self, proxies: Optional[Mapping[str, str]] = ...): ... + def __init__(self, proxies: Mapping[str, str] | None = ...): ... def proxy_open(self, req: Request, proxy, type): ... class HTTPPasswordMgr: diff --git a/stdlib/@python2/warnings.pyi b/stdlib/@python2/warnings.pyi index 3bc6b87e9108..37ce72c50726 100644 --- a/stdlib/@python2/warnings.pyi +++ b/stdlib/@python2/warnings.pyi @@ -47,9 +47,9 @@ class catch_warnings: def __new__(cls, *, record: Literal[True], module: ModuleType | None = ...) -> _catch_warnings_with_records: ... @overload def __new__(cls, *, record: bool, module: ModuleType | None = ...) -> catch_warnings: ... - def __enter__(self) -> Optional[List[WarningMessage]]: ... + def __enter__(self) -> List[WarningMessage] | None: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... class _catch_warnings_without_records(catch_warnings): diff --git a/stdlib/@python2/webbrowser.pyi b/stdlib/@python2/webbrowser.pyi index 2095d9200c29..a05e46f4d701 100644 --- a/stdlib/@python2/webbrowser.pyi +++ b/stdlib/@python2/webbrowser.pyi @@ -31,7 +31,7 @@ class BackgroundBrowser(GenericBrowser): def open(self, url: Text, 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/@python2/wsgiref/handlers.pyi b/stdlib/@python2/wsgiref/handlers.pyi index 580764a160c0..6791624103df 100644 --- a/stdlib/@python2/wsgiref/handlers.pyi +++ b/stdlib/@python2/wsgiref/handlers.pyi @@ -6,7 +6,7 @@ from .headers import Headers from .types import ErrorStream, InputStream, StartResponse, WSGIApplication, WSGIEnvironment from .util import FileWrapper -_exc_info = Tuple[Optional[Type[BaseException]], BaseException | None, TracebackType | None] +_exc_info = Tuple[Type[BaseException] | None, BaseException | None, TracebackType | None] def format_date_time(timestamp: float | None) -> str: ... # undocumented @@ -22,7 +22,7 @@ class BaseHandler: os_environ: MutableMapping[str, str] - wsgi_file_wrapper: Optional[Type[FileWrapper]] + wsgi_file_wrapper: Type[FileWrapper] | None headers_class: Type[Headers] # undocumented traceback_limit: int | None diff --git a/stdlib/@python2/xml/etree/ElementInclude.pyi b/stdlib/@python2/xml/etree/ElementInclude.pyi index 878355842492..0956b978c47e 100644 --- a/stdlib/@python2/xml/etree/ElementInclude.pyi +++ b/stdlib/@python2/xml/etree/ElementInclude.pyi @@ -12,4 +12,4 @@ def default_loader(href: str | bytes | int, parse: str, encoding: str | None = . # 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 # Which can't be represented using Callable... -def include(elem: Element, loader: Optional[Callable[..., str | Element]] = ...) -> None: ... +def include(elem: Element, loader: Callable[..., str | Element] | None = ...) -> None: ... diff --git a/stdlib/@python2/xml/etree/ElementPath.pyi b/stdlib/@python2/xml/etree/ElementPath.pyi index f73c4afb6a14..076cb867be70 100644 --- a/stdlib/@python2/xml/etree/ElementPath.pyi +++ b/stdlib/@python2/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]] = ...) -> Element | None: ... -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: _T | None = ..., namespaces: Optional[Dict[str, str]] = ... + elem: Element, path: str, default: _T | None = ..., namespaces: Dict[str, str] | None = ... ) -> _T | str: ... diff --git a/stdlib/@python2/xml/etree/ElementTree.pyi b/stdlib/@python2/xml/etree/ElementTree.pyi index e9c7dfb3e1b0..32fc4042b684 100644 --- a/stdlib/@python2/xml/etree/ElementTree.pyi +++ b/stdlib/@python2/xml/etree/ElementTree.pyi @@ -67,21 +67,21 @@ class Element(MutableSequence[Element]): def clear(self) -> None: ... def extend(self, __elements: Iterable[Element]) -> None: ... def find( - self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... + self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ... ) -> Element | None: ... def findall( - self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... + self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ... ) -> List[Element]: ... @overload def findtext( self, path: _str_argument_type, default: None = ..., - namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ..., + namespaces: Dict[_str_argument_type, _str_argument_type] | None = ..., ) -> _str_result_type | None: ... @overload def findtext( - self, path: _str_argument_type, default: _T, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... + self, path: _str_argument_type, default: _T, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ... ) -> _T | _str_result_type: ... @overload def get(self, key: _str_argument_type, default: None = ...) -> _str_result_type | None: ... @@ -91,7 +91,7 @@ class Element(MutableSequence[Element]): def items(self) -> ItemsView[_str_result_type, _str_result_type]: ... def iter(self, tag: _str_argument_type | None = ...) -> Generator[Element, None, None]: ... def iterfind( - self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... + self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ... ) -> Generator[Element, None, None]: ... def itertext(self) -> Generator[_str_result_type, None, None]: ... def keys(self) -> KeysView[_str_result_type]: ... @@ -133,24 +133,24 @@ class ElementTree: def iter(self, tag: _str_argument_type | None = ...) -> Generator[Element, None, None]: ... def getiterator(self, tag: _str_argument_type | None = ...) -> List[Element]: ... def find( - self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... + self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ... ) -> Element | None: ... @overload def findtext( self, path: _str_argument_type, default: None = ..., - namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ..., + namespaces: Dict[_str_argument_type, _str_argument_type] | None = ..., ) -> _str_result_type | None: ... @overload def findtext( - self, path: _str_argument_type, default: _T, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... + self, path: _str_argument_type, default: _T, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ... ) -> _T | _str_result_type: ... def findall( - self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... + self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ... ) -> List[Element]: ... def iterfind( - self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ... + self, path: _str_argument_type, namespaces: Dict[_str_argument_type, _str_argument_type] | None = ... ) -> Generator[Element, None, None]: ... def write( self, @@ -168,7 +168,7 @@ def tostringlist(element: Element, encoding: str | None = ..., method: str | Non def dump(elem: Element) -> None: ... def parse(source: _file_or_filename, parser: XMLParser | None = ...) -> ElementTree: ... def iterparse( - source: _file_or_filename, events: Optional[Sequence[str]] = ..., parser: XMLParser | None = ... + source: _file_or_filename, events: Sequence[str] | None = ..., parser: XMLParser | None = ... ) -> Iterator[Tuple[str, Any]]: ... def XML(text: _parser_input_type, parser: XMLParser | None = ...) -> Element: ... def XMLID(text: _parser_input_type, parser: XMLParser | None = ...) -> Tuple[Element, Dict[_str_result_type, Element]]: ... diff --git a/stdlib/@python2/xmlrpclib.pyi b/stdlib/@python2/xmlrpclib.pyi index e1d6c68bc47a..4ef4a33d5622 100644 --- a/stdlib/@python2/xmlrpclib.pyi +++ b/stdlib/@python2/xmlrpclib.pyi @@ -218,7 +218,7 @@ class Transport: verbose: bool def single_request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> Tuple[Any, ...]: ... def getparser(self) -> Tuple[ExpatParser | SlowParser, Unmarshaller]: ... - def get_host_info(self, host: _hostDesc) -> Tuple[str, Optional[List[Tuple[str, str]]], Optional[Mapping[Any, Any]]]: ... + def get_host_info(self, host: _hostDesc) -> Tuple[str, Optional[List[Tuple[str, str]]], Mapping[Any, Any] | None]: ... def make_connection(self, host: _hostDesc) -> HTTPConnection: ... def close(self) -> None: ... def send_request(self, connection: HTTPConnection, handler: str, request_body: str) -> None: ... diff --git a/stdlib/@python2/zipfile.pyi b/stdlib/@python2/zipfile.pyi index 9af96ada8800..dfacc97cec42 100644 --- a/stdlib/@python2/zipfile.pyi +++ b/stdlib/@python2/zipfile.pyi @@ -18,7 +18,7 @@ class ZipExtFile(io.BufferedIOBase): PATTERN: Pattern[str] = ... - newlines: Optional[List[bytes]] + newlines: List[bytes] | None mode: str name: str def __init__( @@ -43,7 +43,7 @@ class ZipFile: debug: int comment: bytes filelist: List[ZipInfo] - fp: Optional[IO[bytes]] + fp: IO[bytes] | None NameToInfo: Dict[Text, ZipInfo] start_dir: int # undocumented def __init__( @@ -51,7 +51,7 @@ class ZipFile: ) -> None: ... def __enter__(self) -> ZipFile: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def close(self) -> None: ... def getinfo(self, name: Text) -> ZipInfo: ... @@ -60,7 +60,7 @@ class ZipFile: def open(self, name: _SZI, mode: Text = ..., pwd: bytes | None = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... def extract(self, member: _SZI, path: StrPath | None = ..., pwd: bytes | None = ...) -> str: ... def extractall( - self, path: StrPath | None = ..., members: Optional[Iterable[Text]] = ..., pwd: bytes | None = ... + self, path: StrPath | None = ..., members: Iterable[Text] | None = ..., pwd: bytes | None = ... ) -> None: ... def printdir(self) -> None: ... def setpassword(self, pwd: bytes) -> None: ... diff --git a/stdlib/_dummy_threading.pyi b/stdlib/_dummy_threading.pyi index f5770df80dde..686380756c34 100644 --- a/stdlib/_dummy_threading.pyi +++ b/stdlib/_dummy_threading.pyi @@ -3,7 +3,7 @@ from types import FrameType, TracebackType from typing import Any, Callable, Iterable, List, Mapping, Optional, Type, TypeVar, Union # TODO recursive type -_TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] +_TF = Callable[[FrameType, str, Any], Callable[..., Any] | None] _PF = Callable[[FrameType, str, Any], None] _T = TypeVar("_T") @@ -40,10 +40,10 @@ class Thread: def __init__( self, group: None = ..., - target: Optional[Callable[..., Any]] = ..., + target: Callable[..., Any] | None = ..., name: str | None = ..., args: Iterable[Any] = ..., - kwargs: Optional[Mapping[str, Any]] = ..., + kwargs: Mapping[str, Any] | None = ..., *, daemon: bool | None = ..., ) -> None: ... @@ -67,7 +67,7 @@ class Lock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... @@ -77,7 +77,7 @@ class _RLock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... @@ -88,7 +88,7 @@ class Condition: def __init__(self, lock: Lock | _RLock | None = ...) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... @@ -101,7 +101,7 @@ class Condition: class Semaphore: def __init__(self, value: int = ...) -> None: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ... def __enter__(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ... @@ -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: ... diff --git a/stdlib/_json.pyi b/stdlib/_json.pyi index ca4e081eefe5..ddfde30a312b 100644 --- a/stdlib/_json.pyi +++ b/stdlib/_json.pyi @@ -11,7 +11,7 @@ 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: int | None, diff --git a/stdlib/_thread.pyi b/stdlib/_thread.pyi index 7ea76f25bb7c..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: BaseException | None, traceback: TracebackType | None + self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: Dict[str, Any] = ...) -> int: ... 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/tkinter.pyi b/stdlib/_typeshed/tkinter.pyi index e43ae2243748..f81599db7dd2 100644 --- a/stdlib/_typeshed/tkinter.pyi +++ b/stdlib/_typeshed/tkinter.pyi @@ -4,4 +4,4 @@ from tkinter import Event, Misc, Widget from typing import Optional, Protocol class DndSource(Protocol): - def dnd_end(self, target: Widget | None, event: Optional[Event[Misc]]) -> None: ... + def dnd_end(self, target: Widget | None, event: Event[Misc] | None) -> None: ... diff --git a/stdlib/_warnings.pyi b/stdlib/_warnings.pyi index 0712786e5639..1d1f7b0c7212 100644 --- a/stdlib/_warnings.pyi +++ b/stdlib/_warnings.pyi @@ -5,7 +5,7 @@ _onceregistry: Dict[Any, Any] filters: List[Tuple[Any, ...]] @overload -def warn(message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ... +def warn(message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ... @overload def warn(message: Warning, category: Any = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ... @overload @@ -16,7 +16,7 @@ def warn_explicit( lineno: int, module: str | None = ..., registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., + module_globals: Dict[str, Any] | None = ..., source: Any | None = ..., ) -> None: ... @overload @@ -27,6 +27,6 @@ def warn_explicit( lineno: int, module: str | None = ..., registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., + module_globals: Dict[str, Any] | None = ..., source: Any | None = ..., ) -> None: ... diff --git a/stdlib/_weakrefset.pyi b/stdlib/_weakrefset.pyi index 2d0d3eaf74c1..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: ... diff --git a/stdlib/aifc.pyi b/stdlib/aifc.pyi index e97f2654d29d..475d9058e087 100644 --- a/stdlib/aifc.pyi +++ b/stdlib/aifc.pyi @@ -20,7 +20,7 @@ class Aifc_read: def __init__(self, f: _File) -> None: ... def __enter__(self) -> Aifc_read: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def initfp(self, file: IO[bytes]) -> None: ... def getfp(self) -> IO[bytes]: ... @@ -34,7 +34,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: ... @@ -44,7 +44,7 @@ class Aifc_write: def __del__(self) -> None: ... def __enter__(self) -> Aifc_write: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def initfp(self, file: IO[bytes]) -> None: ... def aiff(self) -> None: ... @@ -64,7 +64,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: ... diff --git a/stdlib/argparse.pyi b/stdlib/argparse.pyi index e1de7d37093b..07441592b6c3 100644 --- a/stdlib/argparse.pyi +++ b/stdlib/argparse.pyi @@ -72,7 +72,7 @@ class _ActionsContainer: choices: Iterable[_T] = ..., required: bool = ..., help: str | None = ..., - metavar: Optional[str | Tuple[str, ...]] = ..., + metavar: str | Tuple[str, ...] | None = ..., dest: str | None = ..., version: str = ..., **kwargs: Any, @@ -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: ... @@ -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 @@ -181,22 +181,22 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): 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: Namespace | None = ... + 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: 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: Namespace | None = ... + self, args: Sequence[str] | None = ..., namespace: Namespace | None = ... ) -> Namespace: ... def parse_known_intermixed_args( - self, args: Optional[Sequence[str]] = ..., namespace: Namespace | None = ... + 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[Action | None, str, str | None]]: ... + def _parse_optional(self, arg_string: str) -> Tuple[Action | None, str, str | None] | None: ... def _get_option_tuples(self, option_string: str) -> List[Tuple[Action, str, str | None]]: ... def _get_nargs_pattern(self, action: Action) -> str: ... def _get_values(self, action: Action, arg_strings: List[str]) -> Any: ... def _get_value(self, action: Action, arg_string: str) -> Any: ... 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 @@ -273,10 +273,10 @@ class Action(_AttributeHolder): const: Any default: Any type: Union[Callable[[str], Any], FileType, None] - choices: Optional[Iterable[Any]] + choices: Iterable[Any] | None required: bool help: str | None - metavar: Optional[str | Tuple[str, ...]] + metavar: str | Tuple[str, ...] | None def __init__( self, option_strings: Sequence[str], @@ -285,10 +285,10 @@ class Action(_AttributeHolder): const: _T | None = ..., default: _T | str | None = ..., type: Optional[Union[Callable[[str], _T], Callable[[str], _T], FileType]] = ..., - choices: Optional[Iterable[_T]] = ..., + choices: Iterable[_T] | None = ..., required: bool = ..., help: str | None = ..., - metavar: Optional[str | Tuple[str, ...]] = ..., + metavar: str | Tuple[str, ...] | None = ..., ) -> None: ... def __call__( self, @@ -308,10 +308,10 @@ if sys.version_info >= (3, 9): dest: str, default: _T | str | None = ..., type: Optional[Union[Callable[[str], _T], Callable[[str], _T], FileType]] = ..., - choices: Optional[Iterable[_T]] = ..., + choices: Iterable[_T] | None = ..., required: bool = ..., help: str | None = ..., - metavar: Optional[str | Tuple[str, ...]] = ..., + metavar: str | Tuple[str, ...] | None = ..., ) -> None: ... class Namespace(_AttributeHolder): @@ -358,7 +358,7 @@ class _StoreConstAction(Action): default: Any = ..., required: bool = ..., help: str | None = ..., - metavar: Optional[str | Tuple[str, ...]] = ..., + metavar: str | Tuple[str, ...] | None = ..., ) -> None: ... # undocumented @@ -386,7 +386,7 @@ class _AppendConstAction(Action): default: Any = ..., required: bool = ..., help: str | None = ..., - metavar: Optional[str | Tuple[str, ...]] = ..., + metavar: str | Tuple[str, ...] | None = ..., ) -> None: ... # undocumented @@ -423,7 +423,7 @@ class _SubParsersAction(Action): dest: str = ..., required: bool = ..., help: str | None = ..., - metavar: Optional[str | Tuple[str, ...]] = ..., + metavar: str | Tuple[str, ...] | None = ..., ) -> None: ... else: def __init__( @@ -433,7 +433,7 @@ class _SubParsersAction(Action): parser_class: Type[ArgumentParser], dest: str = ..., help: str | None = ..., - metavar: Optional[str | Tuple[str, ...]] = ..., + metavar: str | Tuple[str, ...] | None = ..., ) -> None: ... # TODO: Type keyword args properly. def add_parser(self, name: str, **kwargs: Any) -> ArgumentParser: ... diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index 344ee3acda01..b0e60d8ca80e 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -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: ... @@ -115,7 +115,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[Tuple[str, int]] = ..., + local_addr: Tuple[str, int] | None = ..., server_hostname: str | None = ..., ssl_handshake_timeout: float | None = ..., happy_eyeballs_delay: float | None = ..., @@ -152,7 +152,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[Tuple[str, int]] = ..., + local_addr: Tuple[str, int] | None = ..., server_hostname: str | None = ..., ssl_handshake_timeout: float | None = ..., ) -> _TransProtPair: ... @@ -185,7 +185,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[Tuple[str, int]] = ..., + local_addr: Tuple[str, int] | None = ..., server_hostname: str | None = ..., ) -> _TransProtPair: ... @overload @@ -211,7 +211,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): async def create_server( self, protocol_factory: _ProtocolFactory, - host: Optional[str | Sequence[str]] = ..., + host: str | Sequence[str] | None = ..., port: int = ..., *, family: int = ..., @@ -273,7 +273,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): async def create_server( self, protocol_factory: _ProtocolFactory, - host: Optional[str | Sequence[str]] = ..., + host: str | Sequence[str] | None = ..., port: int = ..., *, family: int = ..., @@ -305,8 +305,8 @@ 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 = ..., diff --git a/stdlib/asyncio/base_subprocess.pyi b/stdlib/asyncio/base_subprocess.pyi index ac33850d0f38..a731601de7be 100644 --- a/stdlib/asyncio/base_subprocess.pyi +++ b/stdlib/asyncio/base_subprocess.pyi @@ -3,14 +3,14 @@ from typing import IO, Any, Callable, Deque, Dict, List, Optional, Sequence, Tup from . import events, futures, protocols, transports -_File = Optional[int | IO[Any]] +_File = int | IO[Any] | None class BaseSubprocessTransport(transports.SubprocessTransport): _closed: bool # undocumented _protocol: protocols.SubprocessProtocol # undocumented _loop: events.AbstractEventLoop # undocumented - _proc: Optional[subprocess.Popen[Any]] # undocumented + _proc: subprocess.Popen[Any] | None # undocumented _pid: int | None # undocumented _returncode: int | None # undocumented _exit_waiters: List[futures.Future[Any]] # undocumented @@ -27,7 +27,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport): stdout: _File, stderr: _File, bufsize: int, - waiter: Optional[futures.Future[Any]] = ..., + waiter: futures.Future[Any] | None = ..., extra: Any | None = ..., **kwargs: Any, ) -> None: ... @@ -52,7 +52,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport): 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: BaseException | None) -> None: ... # undocumented def _pipe_data_received(self, fd: int, data: bytes) -> None: ... # undocumented diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 87d80cd34edf..3026e11da841 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -146,7 +146,7 @@ class AbstractEventLoop(metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[Tuple[str, int]] = ..., + local_addr: Tuple[str, int] | None = ..., server_hostname: str | None = ..., ssl_handshake_timeout: float | None = ..., happy_eyeballs_delay: float | None = ..., @@ -185,7 +185,7 @@ class AbstractEventLoop(metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[Tuple[str, int]] = ..., + local_addr: Tuple[str, int] | None = ..., server_hostname: str | None = ..., ssl_handshake_timeout: float | None = ..., ) -> _TransProtPair: ... @@ -220,7 +220,7 @@ class AbstractEventLoop(metaclass=ABCMeta): proto: int = ..., flags: int = ..., sock: None = ..., - local_addr: Optional[Tuple[str, int]] = ..., + local_addr: Tuple[str, int] | None = ..., server_hostname: str | None = ..., ) -> _TransProtPair: ... @overload @@ -249,7 +249,7 @@ class AbstractEventLoop(metaclass=ABCMeta): async def create_server( self, protocol_factory: _ProtocolFactory, - host: Optional[str | Sequence[str]] = ..., + host: str | Sequence[str] | None = ..., port: int = ..., *, family: int = ..., @@ -328,7 +328,7 @@ class AbstractEventLoop(metaclass=ABCMeta): async def create_server( self, protocol_factory: _ProtocolFactory, - host: Optional[str | Sequence[str]] = ..., + host: str | Sequence[str] | None = ..., port: int = ..., *, family: int = ..., @@ -377,8 +377,8 @@ 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 = ..., diff --git a/stdlib/asyncio/format_helpers.pyi b/stdlib/asyncio/format_helpers.pyi index 7c5114b24806..8dd07a7a90b2 100644 --- a/stdlib/asyncio/format_helpers.pyi +++ b/stdlib/asyncio/format_helpers.pyi @@ -13,7 +13,7 @@ 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: ... diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index 766c6fed2236..af605f9a93e6 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -12,7 +12,7 @@ if sys.version_info >= (3, 9): def __init__(self, lock: Lock | Semaphore) -> None: ... def __aenter__(self) -> Awaitable[None]: ... def __aexit__( - self, exc_type: Optional[Type[BaseException]], exc: BaseException | None, tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None ) -> Awaitable[None]: ... else: @@ -29,7 +29,7 @@ else: def __await__(self) -> Generator[Any, None, _ContextManager]: ... def __aenter__(self) -> Awaitable[None]: ... def __aexit__( - self, exc_type: Optional[Type[BaseException]], exc: BaseException | None, tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None ) -> Awaitable[None]: ... class Lock(_ContextManagerMixin): diff --git a/stdlib/asyncio/proactor_events.pyi b/stdlib/asyncio/proactor_events.pyi index 09024d8b3d61..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: Any | None = ... + self, message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ... ) -> None: ... class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport): @@ -17,8 +17,8 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTr loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, - waiter: Optional[futures.Future[Any]] = ..., - extra: Optional[Mapping[Any, Any]] = ..., + waiter: futures.Future[Any] | None = ..., + extra: Mapping[Any, Any] | None = ..., server: events.AbstractServer | None = ..., ) -> None: ... def __repr__(self) -> str: ... @@ -34,8 +34,8 @@ class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTran loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, - waiter: Optional[futures.Future[Any]] = ..., - extra: Optional[Mapping[Any, Any]] = ..., + waiter: futures.Future[Any] | None = ..., + extra: Mapping[Any, Any] | None = ..., server: events.AbstractServer | None = ..., ) -> None: ... @@ -45,8 +45,8 @@ class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.Wri loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, - waiter: Optional[futures.Future[Any]] = ..., - extra: Optional[Mapping[Any, Any]] = ..., + waiter: futures.Future[Any] | None = ..., + extra: Mapping[Any, Any] | None = ..., server: events.AbstractServer | None = ..., ) -> None: ... @@ -56,8 +56,8 @@ class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, - waiter: Optional[futures.Future[Any]] = ..., - extra: Optional[Mapping[Any, Any]] = ..., + waiter: futures.Future[Any] | None = ..., + extra: Mapping[Any, Any] | None = ..., server: events.AbstractServer | None = ..., ) -> None: ... @@ -71,8 +71,8 @@ class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePip loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, - waiter: Optional[futures.Future[Any]] = ..., - extra: Optional[Mapping[Any, Any]] = ..., + waiter: futures.Future[Any] | None = ..., + extra: Mapping[Any, Any] | None = ..., server: events.AbstractServer | None = ..., ) -> None: ... def _set_extra(self, sock: socket) -> None: ... diff --git a/stdlib/asyncio/streams.pyi b/stdlib/asyncio/streams.pyi index bea2fe79aff3..a6384f7ae80a 100644 --- a/stdlib/asyncio/streams.pyi +++ b/stdlib/asyncio/streams.pyi @@ -4,7 +4,7 @@ from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Optional, from . import events, protocols, transports -_ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Optional[Awaitable[None]]] +_ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Awaitable[None] | None] if sys.version_info < (3, 8): class IncompleteReadError(EOFError): diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index d5adafcfb117..4dbab184b876 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -19,7 +19,7 @@ _T4 = TypeVar("_T4") _T5 = TypeVar("_T5") _FT = TypeVar("_FT", bound=Future[Any]) _FutureT = Future[_T] | Generator[Any, None, _T] | Awaitable[_T] -_TaskYieldType = Optional[Future[object]] +_TaskYieldType = Future[object] | None FIRST_EXCEPTION: str FIRST_COMPLETED: str @@ -296,7 +296,7 @@ class Task(Future[_T], Generic[_T]): def cancel(self) -> bool: ... if sys.version_info < (3, 9): @classmethod - def current_task(cls, loop: AbstractEventLoop | None = ...) -> Optional[Task[Any]]: ... + def current_task(cls, loop: AbstractEventLoop | None = ...) -> Task[Any] | None: ... @classmethod def all_tasks(cls, loop: AbstractEventLoop | None = ...) -> Set[Task[Any]]: ... if sys.version_info < (3, 7): @@ -312,4 +312,4 @@ if sys.version_info >= (3, 7): ) -> Task[_T]: ... else: def create_task(coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T]) -> Task[_T]: ... - def current_task(loop: AbstractEventLoop | None = ...) -> Optional[Task[Any]]: ... + def current_task(loop: AbstractEventLoop | None = ...) -> Task[Any] | None: ... diff --git a/stdlib/asyncio/transports.pyi b/stdlib/asyncio/transports.pyi index 4959046667df..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: ... @@ -42,5 +42,5 @@ class SubprocessTransport(BaseTransport): def kill(self) -> None: ... class _FlowControlMixin(Transport): - def __init__(self, extra: Optional[Mapping[Any, Any]] = ..., loop: AbstractEventLoop | None = ...) -> 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 5ed3039fb84f..2f2f4c249690 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -82,5 +82,5 @@ if sys.version_info >= (3, 8): def setblocking(self, flag: bool) -> None: ... def __enter__(self) -> socket.socket: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... diff --git a/stdlib/asyncio/unix_events.pyi b/stdlib/asyncio/unix_events.pyi index c0b4f23bde09..7cbbfa286e86 100644 --- a/stdlib/asyncio/unix_events.pyi +++ b/stdlib/asyncio/unix_events.pyi @@ -17,7 +17,7 @@ class AbstractChildWatcher: def close(self) -> None: ... def __enter__(self: _T1) -> _T1: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: BaseException | None, tb: types.TracebackType | None + self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None ) -> None: ... if sys.version_info >= (3, 8): def is_active(self) -> bool: ... @@ -59,7 +59,7 @@ if sys.version_info >= (3, 8): _T5 = TypeVar("_T5", bound=ThreadedChildWatcher) class _Warn(Protocol): def __call__( - self, message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ..., source: Any | None = ... + self, message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ... ) -> None: ... class MultiLoopChildWatcher(AbstractChildWatcher): def __enter__(self: _T4) -> _T4: ... diff --git a/stdlib/asyncore.pyi b/stdlib/asyncore.pyi index 55fbe7c6734b..80b7747c5d0e 100644 --- a/stdlib/asyncore.pyi +++ b/stdlib/asyncore.pyi @@ -43,7 +43,7 @@ class dispatcher: def listen(self, num: int) -> None: ... def bind(self, addr: Tuple[Any, ...] | str) -> None: ... def connect(self, address: Tuple[Any, ...] | str) -> None: ... - def accept(self) -> Optional[Tuple[_socket, Any]]: ... + def accept(self) -> Tuple[_socket, Any] | None: ... def send(self, data: bytes) -> int: ... def recv(self, buffer_size: int) -> bytes: ... def close(self) -> None: ... diff --git a/stdlib/bdb.pyi b/stdlib/bdb.pyi index cba5a6750ec3..bf8f3c583260 100644 --- a/stdlib/bdb.pyi +++ b/stdlib/bdb.pyi @@ -11,7 +11,7 @@ class BdbQuit(Exception): ... class Bdb: - skip: Optional[Set[str]] + skip: Set[str] | None breaks: Dict[str, List[int]] fncache: Dict[str, str] frame_returning: FrameType | None @@ -20,7 +20,7 @@ class Bdb: 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: ... @@ -59,11 +59,11 @@ class Bdb: 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: 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: 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) -> _T | None: ... @@ -89,7 +89,7 @@ class Breakpoint: 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: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 88365dfec740..d7f6a9a12e08 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -114,14 +114,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 @@ -627,9 +627,9 @@ 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 @@ -641,7 +641,7 @@ class memoryview(Sized, Sequence[int]): def __init__(self, obj: ReadableBuffer) -> None: ... def __enter__(self) -> memoryview: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def cast(self, format: str, shape: List[int] | Tuple[int] = ...) -> memoryview: ... @overload @@ -656,7 +656,7 @@ class memoryview(Sized, Sequence[int]): @overload def __setitem__(self, i: int, o: int) -> 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]: ... @@ -1003,10 +1003,10 @@ 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: 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: 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: ... @@ -1231,7 +1231,7 @@ def print( *values: object, sep: str | None = ..., end: str | None = ..., - file: Optional[SupportsWrite[str]] = ..., + file: SupportsWrite[str] | None = ..., flush: bool = ..., ) -> None: ... @@ -1343,8 +1343,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: ... diff --git a/stdlib/cgi.pyi b/stdlib/cgi.pyi index 037507095d75..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 = ..., @@ -45,7 +45,7 @@ class MiniFieldStorage: 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] @@ -72,18 +72,18 @@ class FieldStorage(object): disposition: str disposition_options: dict[str, str] filename: str | None - file: Optional[IO[bytes]] + file: IO[bytes] | None type: str type_options: dict[str, str] innerboundary: bytes length: int done: int - list: Optional[_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 = ..., diff --git a/stdlib/cgitb.pyi b/stdlib/cgitb.pyi index a04cc9e14133..3d4e6f654995 100644 --- a/stdlib/cgitb.pyi +++ b/stdlib/cgitb.pyi @@ -2,7 +2,7 @@ from _typeshed import StrOrBytesPath from types import FrameType, TracebackType from typing import IO, Any, Callable, Dict, List, Optional, Tuple, Type -_ExcInfo = Tuple[Optional[Type[BaseException]], BaseException | None, TracebackType | None] +_ExcInfo = Tuple[Type[BaseException] | None, BaseException | None, TracebackType | None] def reset() -> str: ... # undocumented def small(text: str) -> str: ... # undocumented @@ -21,11 +21,11 @@ class Hook: # undocumented display: int = ..., logdir: StrOrBytesPath | None = ..., context: int = ..., - file: Optional[IO[str]] = ..., + file: IO[str] | None = ..., format: str = ..., ) -> None: ... def __call__( - self, etype: Optional[Type[BaseException]], evalue: BaseException | None, etb: TracebackType | None + self, etype: Type[BaseException] | None, evalue: BaseException | None, etb: TracebackType | None ) -> None: ... def handle(self, info: _ExcInfo | None = ...) -> None: ... diff --git a/stdlib/cmd.pyi b/stdlib/cmd.pyi index afcfd0a2a2ea..75d7fcba5949 100644 --- a/stdlib/cmd.pyi +++ b/stdlib/cmd.pyi @@ -16,7 +16,7 @@ class Cmd: stdout: IO[str] cmdqueue: List[str] completekey: str - def __init__(self, completekey: str = ..., stdin: Optional[IO[str]] = ..., stdout: Optional[IO[str]] = ...) -> None: ... + def __init__(self, completekey: str = ..., stdin: IO[str] | None = ..., stdout: IO[str] | None = ...) -> None: ... old_completer: Optional[Callable[[str, int], str | None]] def cmdloop(self, intro: Any | None = ...) -> None: ... def precmd(self, line: str) -> str: ... @@ -29,11 +29,11 @@ class Cmd: 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) -> bool | None: ... - 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 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/code.pyi b/stdlib/code.pyi index 69238cdd1415..08298714ab18 100644 --- a/stdlib/code.pyi +++ b/stdlib/code.pyi @@ -2,7 +2,7 @@ from types import CodeType from typing import Any, Callable, Mapping, Optional class InteractiveInterpreter: - def __init__(self, locals: Optional[Mapping[str, Any]] = ...) -> None: ... + def __init__(self, locals: Mapping[str, Any] | None = ...) -> None: ... def runsource(self, source: str, filename: str = ..., symbol: str = ...) -> bool: ... def runcode(self, code: CodeType) -> None: ... def showsyntaxerror(self, filename: str | None = ...) -> None: ... @@ -10,7 +10,7 @@ class InteractiveInterpreter: def write(self, data: str) -> None: ... class InteractiveConsole(InteractiveInterpreter): - def __init__(self, locals: Optional[Mapping[str, Any]] = ..., filename: str = ...) -> None: ... + def __init__(self, locals: Mapping[str, Any] | None = ..., filename: str = ...) -> None: ... def interact(self, banner: str | None = ..., exitmsg: str | None = ...) -> None: ... def push(self, line: str) -> bool: ... def resetbuffer(self) -> None: ... @@ -19,7 +19,7 @@ class InteractiveConsole(InteractiveInterpreter): def interact( banner: str | None = ..., readfunc: Optional[Callable[[str], str]] = ..., - local: Optional[Mapping[str, Any]] = ..., + local: Mapping[str, Any] | None = ..., exitmsg: str | None = ..., ) -> None: ... def compile_command(source: str, filename: str = ..., symbol: str = ...) -> CodeType | None: ... diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index c245fc619c4e..b274cec7d120 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -200,7 +200,7 @@ class StreamWriter(Codec): def reset(self) -> None: ... def __enter__(self: _SW) -> _SW: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: BaseException | None, tb: types.TracebackType | None + self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None ) -> None: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... @@ -215,7 +215,7 @@ class StreamReader(Codec): def reset(self) -> None: ... def __enter__(self: _SR) -> _SR: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: BaseException | None, tb: types.TracebackType | None + 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: ... @@ -239,7 +239,7 @@ class StreamReaderWriter(TextIO): def seek(self, offset: int, whence: int = ...) -> int: ... def __enter__(self: _T) -> _T: ... def __exit__( - self, typ: Optional[Type[BaseException]], exc: BaseException | None, tb: types.TracebackType | None + 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 @@ -277,7 +277,7 @@ class StreamRecoder(BinaryIO): def __getattr__(self, name: str) -> Any: ... def __enter__(self: _SRT) -> _SRT: ... def __exit__( - self, type: Optional[Type[BaseException]], value: BaseException | None, tb: types.TracebackType | None + 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__. diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 4f78973e25cb..45f8f0d6e573 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -31,7 +31,7 @@ if sys.version_info >= (3, 7): *, rename: bool = ..., module: str | None = ..., - defaults: Optional[Iterable[Any]] = ..., + defaults: Iterable[Any] | None = ..., ) -> Type[Tuple[Any, ...]]: ... else: @@ -46,7 +46,7 @@ else: 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: ... @@ -59,7 +59,7 @@ class UserDict(MutableMapping[_KT, _VT]): 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: ... @@ -294,7 +294,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/concurrent/futures/process.pyi b/stdlib/concurrent/futures/process.pyi index c5404d573d1f..e0003fe74761 100644 --- a/stdlib/concurrent/futures/process.pyi +++ b/stdlib/concurrent/futures/process.pyi @@ -19,7 +19,7 @@ if sys.version_info >= (3, 7): self, max_workers: int | None = ..., mp_context: BaseContext | None = ..., - initializer: Optional[Callable[..., None]] = ..., + initializer: Callable[..., None] | None = ..., initargs: Tuple[Any, ...] = ..., ) -> None: ... diff --git a/stdlib/concurrent/futures/thread.pyi b/stdlib/concurrent/futures/thread.pyi index a1b530893566..788c81158454 100644 --- a/stdlib/concurrent/futures/thread.pyi +++ b/stdlib/concurrent/futures/thread.pyi @@ -23,7 +23,7 @@ class ThreadPoolExecutor(Executor): self, max_workers: int | None = ..., thread_name_prefix: str = ..., - initializer: Optional[Callable[..., None]] = ..., + initializer: Callable[..., None] | None = ..., initargs: Tuple[Any, ...] = ..., ) -> None: ... else: diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index 8ae9d7d4366d..c8ae90f6573f 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -64,13 +64,13 @@ class RawConfigParser(_parser): @overload def __init__( self, - defaults: Optional[Mapping[str, str | None]] = ..., + 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 = ..., @@ -86,7 +86,7 @@ class RawConfigParser(_parser): *, 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 = ..., diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index b783699c22a2..ec79d6d18992 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -22,10 +22,10 @@ if sys.version_info >= (3, 7): _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) -_T_io = TypeVar("_T_io", bound=Optional[IO[str]]) +_T_io = TypeVar("_T_io", bound=IO[str] | None) _F = TypeVar("_F", bound=Callable[..., Any]) -_ExitFunc = Callable[[Optional[Type[BaseException]], BaseException | None, TracebackType | None], bool] +_ExitFunc = Callable[[Type[BaseException] | None, BaseException | None, TracebackType | None], bool] _CM_EF = TypeVar("_CM_EF", ContextManager[Any], _ExitFunc) class _GeneratorContextManager(ContextManager[_T_co]): @@ -57,7 +57,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: BaseException | None, exctb: TracebackType | None + self, exctype: Type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None ) -> bool: ... class redirect_stdout(ContextManager[_T_io]): @@ -81,7 +81,7 @@ class ExitStack(ContextManager[ExitStack]): def __enter__(self: _U) -> _U: ... def __exit__( self, - __exc_type: Optional[Type[BaseException]], + __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None, ) -> bool: ... @@ -89,7 +89,7 @@ class ExitStack(ContextManager[ExitStack]): if sys.version_info >= (3, 7): _S = TypeVar("_S", bound=AsyncExitStack) - _ExitCoroFunc = Callable[[Optional[Type[BaseException]], BaseException | None, TracebackType | None], Awaitable[bool]] + _ExitCoroFunc = Callable[[Type[BaseException] | None, BaseException | None, TracebackType | None], Awaitable[bool]] _CallbackCoroFunc = Callable[..., Awaitable[Any]] _ACM_EF = TypeVar("_ACM_EF", AsyncContextManager[Any], _ExitCoroFunc) class AsyncExitStack(AsyncContextManager[AsyncExitStack]): @@ -105,7 +105,7 @@ if sys.version_info >= (3, 7): def __aenter__(self: _S) -> Awaitable[_S]: ... def __aexit__( self, - __exc_type: Optional[Type[BaseException]], + __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None, ) -> Awaitable[bool]: ... 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/csv.pyi b/stdlib/csv.pyi index 5681fa109200..13539c6bd6e3 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -46,7 +46,7 @@ class unix_dialect(Dialect): quoting: int class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): - fieldnames: Optional[Sequence[_T]] + fieldnames: Sequence[_T] | None restkey: str | None restval: str | None reader: _reader @@ -67,7 +67,7 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): def __init__( self: DictReader[str], f: Iterable[str], - fieldnames: Optional[Sequence[str]] = ..., + fieldnames: Sequence[str] | None = ..., restkey: str | None = ..., restval: str | None = ..., dialect: _DialectLike = ..., diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index 0fd835fc44ab..9f4cfa78fde3 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -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 @@ -110,7 +110,7 @@ class _CData(metaclass=_CDataMeta): class _CanCastTo(_CData): ... class _PointerLike(_CanCastTo): ... -_ECT = Callable[[Optional[Type[_CData]], _FuncPointer, Tuple[_CData, ...]], _CData] +_ECT = Callable[[Type[_CData] | None, _FuncPointer, Tuple[_CData, ...]], _CData] _PF = _UnionT[Tuple[int], Tuple[int, str], Tuple[int, str, Any]] class _FuncPointer(_PointerLike, _CData): @@ -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: ... @@ -222,7 +222,7 @@ 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: Optional[_UnionT[int, bytes]] = ...) -> None: ... + def __init__(self, value: _UnionT[int, bytes] | None = ...) -> None: ... class c_double(_SimpleCData[float]): ... class c_longdouble(_SimpleCData[float]): ... @@ -250,7 +250,7 @@ class c_void_p(_PointerLike, _SimpleCData[int | None]): ... class c_wchar(_SimpleCData[str]): ... class c_wchar_p(_PointerLike, _SimpleCData[str | None]): - def __init__(self, value: Optional[_UnionT[int, 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/dataclasses.pyi b/stdlib/dataclasses.pyi index 76fe33e1db69..bddf5c3744b8 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -111,7 +111,7 @@ if sys.version_info >= (3, 10): repr: bool = ..., hash: bool | None = ..., compare: bool = ..., - metadata: Optional[Mapping[str, Any]] = ..., + metadata: Mapping[str, Any] | None = ..., kw_only: bool = ..., ) -> _T: ... @overload @@ -122,7 +122,7 @@ if sys.version_info >= (3, 10): repr: bool = ..., hash: bool | None = ..., compare: bool = ..., - metadata: Optional[Mapping[str, Any]] = ..., + metadata: Mapping[str, Any] | None = ..., kw_only: bool = ..., ) -> _T: ... @overload @@ -132,7 +132,7 @@ if sys.version_info >= (3, 10): repr: bool = ..., hash: bool | None = ..., compare: bool = ..., - metadata: Optional[Mapping[str, Any]] = ..., + metadata: Mapping[str, Any] | None = ..., kw_only: bool = ..., ) -> Any: ... @@ -145,7 +145,7 @@ else: repr: bool = ..., hash: bool | None = ..., compare: bool = ..., - metadata: Optional[Mapping[str, Any]] = ..., + metadata: Mapping[str, Any] | None = ..., ) -> _T: ... @overload def field( @@ -155,7 +155,7 @@ else: repr: bool = ..., hash: bool | None = ..., compare: bool = ..., - metadata: Optional[Mapping[str, Any]] = ..., + metadata: Mapping[str, Any] | None = ..., ) -> _T: ... @overload def field( @@ -164,7 +164,7 @@ else: repr: 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], ...]: ... @@ -187,7 +187,7 @@ if sys.version_info >= (3, 10): fields: Iterable[Union[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 = ..., @@ -204,7 +204,7 @@ else: fields: Iterable[Union[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/dbm/__init__.pyi b/stdlib/dbm/__init__.pyi index 26c129f02d48..24ffec6a9a9f 100644 --- a/stdlib/dbm/__init__.pyi +++ b/stdlib/dbm/__init__.pyi @@ -81,7 +81,7 @@ class _Database(MutableMapping[_KeyType, bytes]): def __del__(self) -> None: ... def __enter__(self) -> _Database: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... class _error(Exception): ... diff --git a/stdlib/dbm/dumb.pyi b/stdlib/dbm/dumb.pyi index eb1d5dca807e..f0bd7aa59f8a 100644 --- a/stdlib/dbm/dumb.pyi +++ b/stdlib/dbm/dumb.pyi @@ -19,7 +19,7 @@ class _Database(MutableMapping[_KeyType, bytes]): def __del__(self) -> None: ... def __enter__(self) -> _Database: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def open(file: str, flag: str = ..., mode: int = ...) -> _Database: ... diff --git a/stdlib/dbm/gnu.pyi b/stdlib/dbm/gnu.pyi index 835e0d53e6dd..308d1513cf2c 100644 --- a/stdlib/dbm/gnu.pyi +++ b/stdlib/dbm/gnu.pyi @@ -21,7 +21,7 @@ class _gdbm: def __len__(self) -> int: ... def __enter__(self) -> _gdbm: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... @overload def get(self, k: _KeyType) -> bytes | None: ... diff --git a/stdlib/dbm/ndbm.pyi b/stdlib/dbm/ndbm.pyi index 54ae1da86699..94e14365081f 100644 --- a/stdlib/dbm/ndbm.pyi +++ b/stdlib/dbm/ndbm.pyi @@ -19,7 +19,7 @@ class _dbm: def __del__(self) -> None: ... def __enter__(self) -> _dbm: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... @overload def get(self, k: _KeyType) -> bytes | None: ... diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index f1ab4948867c..78e64004f2c7 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -153,7 +153,7 @@ class _ContextManager(object): saved_context: Context def __init__(self, new_context: Context) -> None: ... def __enter__(self) -> Context: ... - def __exit__(self, t: Optional[Type[BaseException]], v: BaseException | None, tb: TracebackType | None) -> None: ... + def __exit__(self, t: Type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... _TrapType = Type[DecimalException] @@ -176,7 +176,7 @@ class Context(object): clamp: int | None = ..., flags: None | Dict[_TrapType, bool] | Container[_TrapType] = ..., traps: None | Dict[_TrapType, bool] | Container[_TrapType] = ..., - _ignored_flags: Optional[List[_TrapType]] = ..., + _ignored_flags: List[_TrapType] | None = ..., ) -> None: ... # __setattr__() only allows to set a specific set of attributes, # already defined above. diff --git a/stdlib/dis.pyi b/stdlib/dis.pyi index e9b1ad10b632..8d4b0566b74a 100644 --- a/stdlib/dis.pyi +++ b/stdlib/dis.pyi @@ -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: _have_code_or_string | None = ..., *, file: Optional[IO[str]] = ..., depth: int | None = ...) -> None: ... + def dis(x: _have_code_or_string | None = ..., *, file: IO[str] | None = ..., depth: int | None = ...) -> None: ... else: - def dis(x: _have_code_or_string | None = ..., *, file: Optional[IO[str]] = ...) -> None: ... + def dis(x: _have_code_or_string | None = ..., *, file: IO[str] | None = ...) -> None: ... -def distb(tb: types.TracebackType | None = ..., *, 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 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/ccompiler.pyi b/stdlib/distutils/ccompiler.pyi index 1721f948797b..dfed71592d54 100644 --- a/stdlib/distutils/ccompiler.pyi +++ b/stdlib/distutils/ccompiler.pyi @@ -41,10 +41,10 @@ class CCompiler: 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: ... @@ -55,11 +55,11 @@ class CCompiler: sources: List[str], output_dir: str | None = ..., macros: _Macro | None = ..., - include_dirs: Optional[List[str]] = ..., + 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, @@ -75,13 +75,13 @@ class CCompiler: objects: List[str], output_filename: str, output_dir: str | None = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., - export_symbols: Optional[List[str]] = ..., + 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]] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., build_temp: str | None = ..., target_lang: str | None = ..., ) -> None: ... @@ -90,12 +90,12 @@ class CCompiler: objects: List[str], output_progname: str, output_dir: str | None = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., + 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]] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., target_lang: str | None = ..., ) -> None: ... def link_shared_lib( @@ -103,13 +103,13 @@ class CCompiler: objects: List[str], output_libname: str, output_dir: str | None = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., - export_symbols: Optional[List[str]] = ..., + 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]] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., build_temp: str | None = ..., target_lang: str | None = ..., ) -> None: ... @@ -118,13 +118,13 @@ class CCompiler: objects: List[str], output_filename: str, output_dir: str | None = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., - export_symbols: Optional[List[str]] = ..., + 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]] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., build_temp: str | None = ..., target_lang: str | None = ..., ) -> None: ... @@ -132,10 +132,10 @@ class CCompiler: self, source: str, output_file: str | None = ..., - macros: Optional[List[_Macro]] = ..., - include_dirs: Optional[List[str]] = ..., - extra_preargs: Optional[List[str]] = ..., - extra_postargs: Optional[List[str]] = ..., + 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: ... diff --git a/stdlib/distutils/command/config.pyi b/stdlib/distutils/command/config.pyi index 7c96cd9425d3..f95d8c5e41ce 100644 --- a/stdlib/distutils/command/config.pyi +++ b/stdlib/distutils/command/config.pyi @@ -13,9 +13,9 @@ class config(Command): user_options: Sequence[Tuple[str, str | None, str]] = ... compiler: str | CCompiler | None = ... cc: str | None = ... - include_dirs: Optional[Sequence[str]] = ... - libraries: Optional[Sequence[str]] = ... - library_dirs: Optional[Sequence[str]] = ... + include_dirs: Sequence[str] | None = ... + libraries: Sequence[str] | None = ... + library_dirs: Sequence[str] | None = ... noisy: int = ... dump_source: int = ... temp_files: Sequence[str] = ... @@ -25,62 +25,62 @@ class config(Command): def try_cpp( self, body: str | None = ..., - headers: Optional[Sequence[str]] = ..., - include_dirs: Optional[Sequence[str]] = ..., + headers: Sequence[str] | None = ..., + include_dirs: Sequence[str] | None = ..., lang: str = ..., ) -> bool: ... def search_cpp( self, pattern: Pattern[str] | str, body: str | None = ..., - headers: Optional[Sequence[str]] = ..., - include_dirs: Optional[Sequence[str]] = ..., + headers: Sequence[str] | None = ..., + include_dirs: Sequence[str] | None = ..., lang: str = ..., ) -> bool: ... def try_compile( - self, body: str, headers: Optional[Sequence[str]] = ..., include_dirs: Optional[Sequence[str]] = ..., lang: str = ... + self, body: str, headers: Sequence[str] | None = ..., include_dirs: Sequence[str] | None = ..., lang: str = ... ) -> bool: ... def try_link( self, body: str, - headers: Optional[Sequence[str]] = ..., - include_dirs: Optional[Sequence[str]] = ..., - libraries: Optional[Sequence[str]] = ..., - library_dirs: Optional[Sequence[str]] = ..., + headers: Sequence[str] | None = ..., + include_dirs: Sequence[str] | None = ..., + libraries: Sequence[str] | None = ..., + library_dirs: Sequence[str] | None = ..., lang: str = ..., ) -> bool: ... def try_run( self, body: str, - headers: Optional[Sequence[str]] = ..., - include_dirs: Optional[Sequence[str]] = ..., - libraries: Optional[Sequence[str]] = ..., - library_dirs: Optional[Sequence[str]] = ..., + headers: Sequence[str] | None = ..., + include_dirs: Sequence[str] | None = ..., + libraries: Sequence[str] | None = ..., + library_dirs: Sequence[str] | None = ..., lang: str = ..., ) -> bool: ... def check_func( self, func: str, - headers: Optional[Sequence[str]] = ..., - include_dirs: Optional[Sequence[str]] = ..., - libraries: Optional[Sequence[str]] = ..., - library_dirs: Optional[Sequence[str]] = ..., + headers: Sequence[str] | None = ..., + include_dirs: Sequence[str] | None = ..., + libraries: Sequence[str] | None = ..., + library_dirs: Sequence[str] | None = ..., decl: int = ..., call: int = ..., ) -> bool: ... def check_lib( self, library: str, - library_dirs: Optional[Sequence[str]] = ..., - headers: Optional[Sequence[str]] = ..., - include_dirs: Optional[Sequence[str]] = ..., + library_dirs: Sequence[str] | None = ..., + headers: Sequence[str] | None = ..., + include_dirs: Sequence[str] | None = ..., other_libraries: List[str] = ..., ) -> bool: ... def check_header( self, header: str, - include_dirs: Optional[Sequence[str]] = ..., - library_dirs: Optional[Sequence[str]] = ..., + include_dirs: Sequence[str] | None = ..., + library_dirs: Sequence[str] | None = ..., lang: str = ..., ) -> bool: ... diff --git a/stdlib/distutils/core.pyi b/stdlib/distutils/core.pyi index 47bb1048d3b7..997134596087 100644 --- a/stdlib/distutils/core.pyi +++ b/stdlib/distutils/core.pyi @@ -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/dist.pyi b/stdlib/distutils/dist.pyi index 8d7712df812d..c8811ed7e4c1 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -14,13 +14,13 @@ class DistributionMetadata: license: str | None description: str | None long_description: str | None - keywords: Optional[str | List[str]] - platforms: Optional[str | List[str]] - classifiers: Optional[str | List[str]] + keywords: str | List[str] | None + platforms: str | List[str] | None + classifiers: str | List[str] | None download_url: str | None - provides: Optional[List[str]] - requires: Optional[List[str]] - obsoletes: Optional[List[str]] + 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: ... @@ -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 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 52d531142f43..a59a20222a72 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]] = ..., + include_dirs: List[str] | None = ..., define_macros: Optional[List[Tuple[str, str | None]]] = ..., - 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]] = ..., + 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: Optional[List[str]] = ..., + 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 786adcb41e81..a6b92503ecd1 100644 --- a/stdlib/distutils/fancy_getopt.pyi +++ b/stdlib/distutils/fancy_getopt.pyi @@ -4,17 +4,17 @@ _Option = Tuple[str, str | None, str] _GR = Tuple[List[str], OptionDummy] def fancy_getopt( - options: List[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: Optional[List[str]] + 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: str | None = ...) -> List[str]: ... diff --git a/stdlib/distutils/filelist.pyi b/stdlib/distutils/filelist.pyi index 54a2d2c24f64..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: ... diff --git a/stdlib/distutils/text_file.pyi b/stdlib/distutils/text_file.pyi index 7dbd809315ab..826e9e78daa6 100644 --- a/stdlib/distutils/text_file.pyi +++ b/stdlib/distutils/text_file.pyi @@ -4,7 +4,7 @@ class TextFile: def __init__( self, filename: str | None = ..., - file: Optional[IO[str]] = ..., + file: IO[str] | None = ..., *, strip_comments: bool = ..., lstrip_ws: bool = ..., diff --git a/stdlib/distutils/version.pyi b/stdlib/distutils/version.pyi index 4b6ed06af619..1b48b84b292b 100644 --- a/stdlib/distutils/version.pyi +++ b/stdlib/distutils/version.pyi @@ -22,7 +22,7 @@ class Version: class StrictVersion(Version): version_re: Pattern[str] version: Tuple[int, int, int] - prerelease: Optional[Tuple[str, int]] + prerelease: Tuple[str, int] | None def __init__(self, vstring: str | None = ...) -> None: ... def parse(self: _T, vstring: str) -> _T: ... def __str__(self) -> str: ... diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index c6f2f14944cc..0192e7c3eba8 100644 --- a/stdlib/doctest.pyi +++ b/stdlib/doctest.pyi @@ -44,7 +44,7 @@ class Example: exc_msg: str | None = ..., lineno: int = ..., indent: int = ..., - options: Optional[Dict[int, bool]] = ..., + options: Dict[int, bool] | None = ..., ) -> None: ... def __hash__(self) -> int: ... @@ -83,8 +83,8 @@ class DocTestFinder: obj: object, name: str | None = ..., module: None | bool | types.ModuleType = ..., - globs: Optional[Dict[str, Any]] = ..., - extraglobs: Optional[Dict[str, Any]] = ..., + globs: Dict[str, Any] | None = ..., + extraglobs: Dict[str, Any] | None = ..., ) -> List[DocTest]: ... _Out = Callable[[str], Any] @@ -131,11 +131,11 @@ master: DocTestRunner | None def testmod( m: types.ModuleType | None = ..., name: str | None = ..., - globs: Optional[Dict[str, Any]] = ..., + 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: ... @@ -144,11 +144,11 @@ def testfile( module_relative: bool = ..., name: str | None = ..., package: None | str | types.ModuleType = ..., - globs: Optional[Dict[str, Any]] = ..., + 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: str | None = ..., @@ -191,8 +191,8 @@ class _DocTestSuite(unittest.TestSuite): ... def DocTestSuite( module: None | str | types.ModuleType = ..., - globs: Optional[Dict[str, Any]] = ..., - extraglobs: Optional[Dict[str, Any]] = ..., + globs: Dict[str, Any] | None = ..., + extraglobs: Dict[str, Any] | None = ..., test_finder: DocTestFinder | None = ..., **options: Any, ) -> _DocTestSuite: ... @@ -205,7 +205,7 @@ def DocFileTest( path: str, module_relative: bool = ..., package: None | str | types.ModuleType = ..., - globs: Optional[Dict[str, Any]] = ..., + globs: Dict[str, Any] | None = ..., parser: DocTestParser = ..., encoding: str | None = ..., **options: Any, @@ -213,6 +213,6 @@ def DocFileTest( def DocFileSuite(*paths: str, **kw: Any) -> _DocTestSuite: ... def script_from_examples(s: str) -> str: ... def testsource(module: 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_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 10b0361df254..28427c25d1eb 100644 --- a/stdlib/email/_header_value_parser.pyi +++ b/stdlib/email/_header_value_parser.pyi @@ -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: ... diff --git a/stdlib/email/headerregistry.pyi b/stdlib/email/headerregistry.pyi index 729f7168aab6..3f4804a61d5f 100644 --- a/stdlib/email/headerregistry.pyi +++ b/stdlib/email/headerregistry.pyi @@ -137,5 +137,5 @@ class Group: def display_name(self) -> str | None: ... @property def addresses(self) -> Tuple[Address, ...]: ... - def __init__(self, display_name: str | None = ..., 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/mime/multipart.pyi b/stdlib/email/mime/multipart.pyi index 31fa6b39abb4..51f1d07f2235 100644 --- a/stdlib/email/mime/multipart.pyi +++ b/stdlib/email/mime/multipart.pyi @@ -10,7 +10,7 @@ class MIMEMultipart(MIMEBase): self, _subtype: str = ..., boundary: str | None = ..., - _subparts: Optional[Sequence[Message]] = ..., + _subparts: Sequence[Message] | None = ..., *, policy: Policy | None = ..., **_params: _ParamsType, diff --git a/stdlib/email/utils.pyi b/stdlib/email/utils.pyi index 693d28951635..b5b35f914da4 100644 --- a/stdlib/email/utils.pyi +++ b/stdlib/email/utils.pyi @@ -14,7 +14,7 @@ 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 diff --git a/stdlib/filecmp.pyi b/stdlib/filecmp.pyi index 3b40ae34ff2a..5438d0d5e47d 100644 --- a/stdlib/filecmp.pyi +++ b/stdlib/filecmp.pyi @@ -21,8 +21,8 @@ class dircmp(Generic[AnyStr]): self, a: AnyStr | PathLike[AnyStr], b: AnyStr | PathLike[AnyStr], - ignore: Optional[Sequence[AnyStr]] = ..., - hide: Optional[Sequence[AnyStr]] = ..., + ignore: Sequence[AnyStr] | None = ..., + hide: Sequence[AnyStr] | None = ..., ) -> None: ... left: AnyStr right: AnyStr diff --git a/stdlib/formatter.pyi b/stdlib/formatter.pyi index 28a4ca807cd1..f57d86c1022b 100644 --- a/stdlib/formatter.pyi +++ b/stdlib/formatter.pyi @@ -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: ... diff --git a/stdlib/ftplib.pyi b/stdlib/ftplib.pyi index ab532b00990b..4ff14bee5528 100644 --- a/stdlib/ftplib.pyi +++ b/stdlib/ftplib.pyi @@ -36,9 +36,9 @@ class FTP: encoding: str def __enter__(self: _T) -> _T: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... - source_address: Optional[Tuple[str, int]] + source_address: Tuple[str, int] | None def __init__( self, host: str = ..., @@ -46,10 +46,10 @@ 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: ... @@ -112,7 +112,7 @@ class FTP_TLS(FTP): 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: str | None diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index 16423143f365..e4bae49a0dec 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -124,9 +124,9 @@ if sys.version_info >= (3, 8): 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/gettext.pyi b/stdlib/gettext.pyi index a3feb12cc996..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,7 +26,7 @@ class GNUTranslations(NullTranslations): CONTEXT: str VERSIONS: Sequence[int] -def find(domain: str, localedir: StrPath | None = ..., languages: Optional[Iterable[str]] = ..., all: bool = ...) -> Any: ... +def find(domain: str, localedir: StrPath | None = ..., languages: Iterable[str] | None = ..., all: bool = ...) -> Any: ... _T = TypeVar("_T") @@ -34,7 +34,7 @@ _T = TypeVar("_T") def translation( domain: str, localedir: StrPath | None = ..., - languages: Optional[Iterable[str]] = ..., + languages: Iterable[str] | None = ..., class_: None = ..., fallback: bool = ..., codeset: str | None = ..., @@ -43,7 +43,7 @@ def translation( def translation( domain: str, localedir: StrPath | None = ..., - languages: Optional[Iterable[str]] = ..., + languages: Iterable[str] | None = ..., class_: Type[_T] = ..., fallback: Literal[False] = ..., codeset: str | None = ..., @@ -52,13 +52,13 @@ def translation( def translation( domain: str, localedir: StrPath | None = ..., - languages: Optional[Iterable[str]] = ..., + languages: Iterable[str] | None = ..., class_: Type[Any] = ..., fallback: Literal[True] = ..., codeset: str | None = ..., ) -> Any: ... def install( - domain: str, localedir: StrPath | None = ..., codeset: str | None = ..., names: Optional[Container[str]] = ... + domain: str, localedir: StrPath | None = ..., codeset: str | None = ..., names: Container[str] | None = ... ) -> None: ... def textdomain(domain: str | None = ...) -> str: ... def bindtextdomain(domain: str, localedir: StrPath | None = ...) -> str: ... diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index c918f82d8b81..c64e93d05b14 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -117,7 +117,7 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO): def __iter__(self) -> Iterator[bytes]: ... def __enter__(self) -> HTTPResponse: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: types.TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None ) -> bool | None: ... def info(self) -> email.message.Message: ... def geturl(self) -> str: ... @@ -133,12 +133,12 @@ class _HTTPConnectionProtocol(Protocol): host: str, 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: int | None = ..., 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: @@ -152,7 +152,7 @@ class HTTPConnection: host: str, port: int | None = ..., timeout: float | None = ..., - source_address: Optional[Tuple[str, int]] = ..., + source_address: Tuple[str, int] | None = ..., blocksize: int = ..., ) -> None: ... else: @@ -161,7 +161,7 @@ class HTTPConnection: host: str, port: int | None = ..., timeout: float | None = ..., - source_address: Optional[Tuple[str, int]] = ..., + source_address: Tuple[str, int] | None = ..., ) -> None: ... def request( self, @@ -174,7 +174,7 @@ class HTTPConnection: ) -> None: ... def getresponse(self) -> HTTPResponse: ... def set_debuglevel(self, level: int) -> None: ... - def set_tunnel(self, host: str, port: int | None = ..., 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: ... @@ -191,7 +191,7 @@ class HTTPSConnection(HTTPConnection): key_file: str | None = ..., cert_file: str | None = ..., timeout: float | None = ..., - source_address: Optional[Tuple[str, int]] = ..., + source_address: Tuple[str, int] | None = ..., *, context: ssl.SSLContext | None = ..., check_hostname: bool | None = ..., @@ -205,7 +205,7 @@ class HTTPSConnection(HTTPConnection): key_file: str | None = ..., cert_file: str | None = ..., timeout: float | None = ..., - source_address: Optional[Tuple[str, int]] = ..., + source_address: Tuple[str, int] | None = ..., *, context: ssl.SSLContext | None = ..., check_hostname: bool | None = ..., diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index 222bcd100fba..35c270e6ff97 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -66,8 +66,8 @@ 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: bool | None = ..., @@ -83,8 +83,8 @@ 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: bool | None = ..., @@ -99,8 +99,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: ... class Cookie: diff --git a/stdlib/http/cookies.pyi b/stdlib/http/cookies.pyi index 42208d69dc3e..89d656b0d0de 100644 --- a/stdlib/http/cookies.pyi +++ b/stdlib/http/cookies.pyi @@ -31,16 +31,16 @@ class Morsel(Dict[str, Any], Generic[_T]): @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: ... class BaseCookie(Dict[str, Morsel[_T]], Generic[_T]): def __init__(self, input: _DataType | None = ...) -> None: ... def value_decode(self, val: str) -> _T: ... def value_encode(self, val: _T) -> str: ... - 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: str | Morsel[_T]) -> None: ... diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index 2c2293ed9f93..83cd5194085a 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -21,7 +21,7 @@ class IMAP4: debug: int = ... state: str = ... literal: str | None = ... - tagged_commands: Dict[bytes, Optional[List[bytes]]] + tagged_commands: Dict[bytes, List[bytes] | None] untagged_responses: Dict[str, List[bytes | Tuple[bytes, bytes]]] continuation_response: str = ... is_readonly: bool = ... @@ -60,7 +60,7 @@ class IMAP4: def deleteacl(self, mailbox: str, who: str) -> _CommandResults: ... def enable(self, capability: str) -> _CommandResults: ... def __enter__(self) -> IMAP4: ... - def __exit__(self, t: Optional[Type[BaseException]], v: BaseException | None, tb: TracebackType | None) -> None: ... + def __exit__(self, t: Type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... def expunge(self) -> _CommandResults: ... def fetch(self, message_set: str, message_parts: str) -> Tuple[str, _AnyResponseData]: ... def getacl(self, mailbox: str) -> _CommandResults: ... diff --git a/stdlib/importlib/__init__.pyi b/stdlib/importlib/__init__.pyi index e7830bb950a0..600aec1281e4 100644 --- a/stdlib/importlib/__init__.pyi +++ b/stdlib/importlib/__init__.pyi @@ -4,8 +4,8 @@ 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: ... diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index 660b5f56056f..1371f2d669d0 100644 --- a/stdlib/importlib/abc.pyi +++ b/stdlib/importlib/abc.pyi @@ -37,11 +37,11 @@ class SourceLoader(ResourceLoader, ExecutionLoader, metaclass=ABCMeta): # Please keep in sync with sys._MetaPathFinder class MetaPathFinder(Finder): - def find_module(self, fullname: str, path: Optional[Sequence[_Path]]) -> Loader | None: ... + 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: types.ModuleType | None = ... + self, fullname: str, path: Sequence[_Path] | None, target: types.ModuleType | None = ... ) -> ModuleSpec | None: ... class PathEntryFinder(Finder): diff --git a/stdlib/importlib/machinery.pyi b/stdlib/importlib/machinery.pyi index 821482d79607..af54a7bb2bc5 100644 --- a/stdlib/importlib/machinery.pyi +++ b/stdlib/importlib/machinery.pyi @@ -16,7 +16,7 @@ class ModuleSpec: name: str loader: importlib.abc._LoaderProtocol | None origin: str | None - submodule_search_locations: Optional[List[str]] + submodule_search_locations: List[str] | None loader_state: Any cached: str | None parent: str | None @@ -26,11 +26,11 @@ class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader) # MetaPathFinder @classmethod def find_module( - cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ... + 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: types.ModuleType | None = ... + cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ..., target: types.ModuleType | None = ... ) -> ModuleSpec | None: ... # InspectLoader @classmethod @@ -53,11 +53,11 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): # MetaPathFinder @classmethod def find_module( - cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ... + 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: types.ModuleType | None = ... + cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ..., target: types.ModuleType | None = ... ) -> ModuleSpec | None: ... # InspectLoader @classmethod @@ -79,11 +79,11 @@ class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): class WindowsRegistryFinder(importlib.abc.MetaPathFinder): @classmethod def find_module( - cls, fullname: str, path: Optional[Sequence[importlib.abc._Path]] = ... + 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: types.ModuleType | None = ... + cls, fullname: str, path: Sequence[importlib.abc._Path] | None = ..., target: types.ModuleType | None = ... ) -> ModuleSpec | None: ... class PathFinder: @@ -91,10 +91,10 @@ class PathFinder: def invalidate_caches(cls) -> None: ... @classmethod def find_spec( - cls, fullname: str, path: Optional[Sequence[bytes | str]] = ..., target: types.ModuleType | None = ... + cls, fullname: str, path: Sequence[bytes | str] | None = ..., target: types.ModuleType | None = ... ) -> ModuleSpec | None: ... @classmethod - def find_module(cls, fullname: str, path: Optional[Sequence[bytes | str]] = ...) -> importlib.abc.Loader | None: ... + def find_module(cls, fullname: str, path: Sequence[bytes | str] | None = ...) -> importlib.abc.Loader | None: ... SOURCE_SUFFIXES: List[str] DEBUG_BYTECODE_SUFFIXES: List[str] diff --git a/stdlib/importlib/metadata.pyi b/stdlib/importlib/metadata.pyi index 6a54134e80b1..7bcceb81d4e6 100644 --- a/stdlib/importlib/metadata.pyi +++ b/stdlib/importlib/metadata.pyi @@ -54,9 +54,9 @@ 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: str | None @@ -82,5 +82,5 @@ if sys.version_info >= (3, 8): 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 bc16d93a88cb..57254f6a004e 100644 --- a/stdlib/importlib/util.pyi +++ b/stdlib/importlib/util.pyi @@ -23,7 +23,7 @@ def spec_from_file_location( location: StrOrBytesPath | None = ..., *, loader: importlib.abc.Loader | None = ..., - submodule_search_locations: Optional[List[str]] = ..., + submodule_search_locations: List[str] | None = ..., ) -> importlib.machinery.ModuleSpec | None: ... def module_from_spec(spec: importlib.machinery.ModuleSpec) -> types.ModuleType: ... diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index 51e7ec0755f8..16409ea03acc 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -109,8 +109,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: ... @@ -118,7 +118,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 = ... @@ -128,7 +128,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, *, parameters: Optional[Sequence[Parameter]] = ..., return_annotation: Any = ...) -> Signature: ... + def replace(self, *, parameters: Sequence[Parameter] | None = ..., return_annotation: Any = ...) -> Signature: ... if sys.version_info >= (3, 10): @classmethod def from_callable( @@ -136,8 +136,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: @@ -148,8 +148,8 @@ if sys.version_info >= (3, 10): def get_annotations( 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]: ... @@ -197,7 +197,7 @@ class BoundArguments: # seem to be supporting this at the moment: # _ClassTreeItem = Union[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] @@ -217,9 +217,9 @@ class FullArgSpec(NamedTuple): args: list[str] varargs: str | None varkw: str | None - defaults: Optional[Tuple[Any, ...]] + 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: ... @@ -237,9 +237,9 @@ def formatargspec( args: list[str], varargs: str | None = ..., varkw: str | None = ..., - defaults: Optional[Tuple[Any, ...]] = ..., - kwonlyargs: Optional[Sequence[str]] = ..., - kwonlydefaults: Optional[dict[str, Any]] = ..., + 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] = ..., @@ -252,7 +252,7 @@ def formatargvalues( args: list[str], varargs: str | None, varkw: str | None, - locals: Optional[dict[str, Any]], + locals: dict[str, Any] | None, formatarg: Optional[Callable[[str], str]] = ..., formatvarargs: Optional[Callable[[str], str]] = ..., formatvarkw: Optional[Callable[[str], str]] = ..., @@ -278,7 +278,7 @@ class Traceback(NamedTuple): filename: str lineno: int function: str - code_context: Optional[list[str]] + code_context: list[str] | None index: int | None # type: ignore class FrameInfo(NamedTuple): @@ -286,7 +286,7 @@ class FrameInfo(NamedTuple): filename: str lineno: int function: str - code_context: Optional[list[str]] + code_context: list[str] | None index: int | None # type: ignore def getframeinfo(frame: FrameType | TracebackType, context: int = ...) -> Traceback: ... diff --git a/stdlib/io.pyi b/stdlib/io.pyi index a31772e7602d..6b46faf05b31 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -27,7 +27,7 @@ class IOBase: def __next__(self) -> bytes: ... def __enter__(self: _T) -> _T: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def close(self) -> None: ... def fileno(self) -> int: ... @@ -185,4 +185,4 @@ class IncrementalNewlineDecoder(codecs.IncrementalDecoder): def __init__(self, decoder: codecs.IncrementalDecoder | None, translate: bool, errors: str = ...) -> None: ... def decode(self, input: bytes | str, final: bool = ...) -> str: ... @property - def newlines(self) -> Optional[str | Tuple[str, ...]]: ... + def newlines(self) -> str | Tuple[str, ...] | None: ... diff --git a/stdlib/ipaddress.pyi b/stdlib/ipaddress.pyi index 2982f8e55705..cfad77f03f96 100644 --- a/stdlib/ipaddress.pyi +++ b/stdlib/ipaddress.pyi @@ -126,7 +126,7 @@ class IPv6Address(_BaseAddress): @property 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 3fea627d46f3..2a1d86911764 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -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: ... diff --git a/stdlib/json/__init__.pyi b/stdlib/json/__init__.pyi index 9ac4411ba1ce..b3f86dedb8d7 100644 --- a/stdlib/json/__init__.pyi +++ b/stdlib/json/__init__.pyi @@ -11,9 +11,9 @@ def dumps( ensure_ascii: bool = ..., check_circular: bool = ..., allow_nan: bool = ..., - cls: Optional[Type[JSONEncoder]] = ..., + cls: Type[JSONEncoder] | None = ..., indent: None | int | str = ..., - separators: Optional[Tuple[str, str]] = ..., + separators: Tuple[str, str] | None = ..., default: Optional[Callable[[Any], Any]] = ..., sort_keys: bool = ..., **kwds: Any, @@ -26,9 +26,9 @@ def dump( ensure_ascii: bool = ..., check_circular: bool = ..., allow_nan: bool = ..., - cls: Optional[Type[JSONEncoder]] = ..., + cls: Type[JSONEncoder] | None = ..., indent: None | int | str = ..., - separators: Optional[Tuple[str, str]] = ..., + separators: Tuple[str, str] | None = ..., default: Optional[Callable[[Any], Any]] = ..., sort_keys: bool = ..., **kwds: Any, @@ -36,7 +36,7 @@ def dump( def loads( s: str | bytes, *, - cls: Optional[Type[JSONDecoder]] = ..., + cls: Type[JSONDecoder] | None = ..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ..., parse_float: Optional[Callable[[str], Any]] = ..., parse_int: Optional[Callable[[str], Any]] = ..., @@ -47,7 +47,7 @@ def loads( def load( fp: SupportsRead[str | bytes], *, - cls: Optional[Type[JSONDecoder]] = ..., + cls: Type[JSONDecoder] | None = ..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ..., parse_float: Optional[Callable[[str], Any]] = ..., parse_int: Optional[Callable[[str], Any]] = ..., diff --git a/stdlib/json/encoder.pyi b/stdlib/json/encoder.pyi index 1dfcae103036..dbc366238c0f 100644 --- a/stdlib/json/encoder.pyi +++ b/stdlib/json/encoder.pyi @@ -19,8 +19,8 @@ class JSONEncoder: allow_nan: bool = ..., sort_keys: bool = ..., indent: int | None = ..., - separators: Optional[Tuple[str, str]] = ..., - default: Optional[Callable[..., Any]] = ..., + 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/pgen.pyi b/stdlib/lib2to3/pgen2/pgen.pyi index c94441637c34..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: ... diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index 9b483c095c40..68e8ff54304e 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -5,7 +5,7 @@ _P = TypeVar("_P") _NL = Node | Leaf _Context = Tuple[str, int, int] _Results = Dict[str, _NL] -_RawNode = Tuple[int, str, _Context, Optional[List[_NL]]] +_RawNode = Tuple[int, str, _Context, List[_NL] | None] _Convert = Callable[[Grammar, _RawNode], Any] HUGE: int @@ -44,7 +44,7 @@ class Node(Base): children: List[_NL], context: Any | None = ..., prefix: str | None = ..., - fixers_applied: Optional[List[Any]] = ..., + fixers_applied: List[Any] | None = ..., ) -> None: ... def set_child(self, i: int, child: _NL) -> None: ... def insert_child(self, i: int, child: _NL) -> None: ... diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 2350426d3d09..35000264e1ff 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -36,8 +36,8 @@ class Manager(object): # undocumented disable: int emittedNoHandlerWarning: bool loggerDict: dict[str, Logger | PlaceHolder] - loggerClass: Optional[Type[Logger]] - logRecordFactory: Optional[Callable[..., LogRecord]] + 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: ... @@ -65,7 +65,7 @@ class Logger(Filterer): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def info( @@ -75,7 +75,7 @@ class Logger(Filterer): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def warning( @@ -85,7 +85,7 @@ class Logger(Filterer): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def warn( @@ -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 = ..., **kwargs: Any, ) -> None: ... def error( @@ -105,7 +105,7 @@ class Logger(Filterer): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def exception( @@ -115,7 +115,7 @@ class Logger(Filterer): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def critical( @@ -125,7 +125,7 @@ class Logger(Filterer): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def log( @@ -136,7 +136,7 @@ class Logger(Filterer): exc_info: _ExcInfoType = ..., stack_info: bool = ..., stacklevel: int = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def _log( @@ -145,7 +145,7 @@ class Logger(Filterer): msg: Any, args: _ArgsType, exc_info: _ExcInfoType | None = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., stack_info: bool = ..., stacklevel: int = ..., ) -> None: ... # undocumented @@ -156,7 +156,7 @@ class Logger(Filterer): *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def info( @@ -165,7 +165,7 @@ class Logger(Filterer): *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def warning( @@ -174,7 +174,7 @@ class Logger(Filterer): *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def warn( @@ -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 = ..., **kwargs: Any, ) -> None: ... def error( @@ -192,7 +192,7 @@ class Logger(Filterer): *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def critical( @@ -201,7 +201,7 @@ class Logger(Filterer): *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def log( @@ -211,7 +211,7 @@ class Logger(Filterer): *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def exception( @@ -220,7 +220,7 @@ class Logger(Filterer): *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def _log( @@ -229,7 +229,7 @@ class Logger(Filterer): msg: Any, args: _ArgsType, exc_info: _ExcInfoType | None = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., stack_info: bool = ..., ) -> None: ... # undocumented fatal = critical @@ -251,7 +251,7 @@ class Logger(Filterer): args: _ArgsType, exc_info: _SysExcInfoType | None, func: str | None = ..., - extra: Optional[Mapping[str, Any]] = ..., + extra: Mapping[str, Any] | None = ..., sinfo: str | None = ..., ) -> LogRecord: ... def hasHandlers(self) -> bool: ... @@ -365,8 +365,8 @@ class LoggerAdapter: logger: Logger manager: Manager # undocumented if sys.version_info >= (3, 10): - extra: Optional[Mapping[str, Any]] - def __init__(self, logger: Logger, extra: Optional[Mapping[str, Any]]) -> None: ... + extra: Mapping[str, Any] | None + def __init__(self, logger: Logger, extra: Mapping[str, Any] | None) -> None: ... else: extra: Mapping[str, Any] def __init__(self, logger: Logger, extra: Mapping[str, Any]) -> None: ... @@ -379,7 +379,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( @@ -389,7 +389,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( @@ -399,7 +399,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( @@ -409,7 +409,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( @@ -419,7 +419,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( @@ -429,7 +429,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( @@ -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: ... def log( @@ -450,7 +450,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: @@ -460,7 +460,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( @@ -469,7 +469,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( @@ -478,7 +478,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( @@ -487,7 +487,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( @@ -496,7 +496,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( @@ -505,7 +505,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( @@ -514,7 +514,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( @@ -524,7 +524,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: ... @@ -537,7 +537,7 @@ class LoggerAdapter: msg: Any, args: _ArgsType, exc_info: _ExcInfoType | None = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., stack_info: bool = ..., ) -> None: ... # undocumented @property @@ -554,7 +554,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 = ..., **kwargs: Any, ) -> None: ... def info( @@ -563,7 +563,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 = ..., **kwargs: Any, ) -> None: ... def warning( @@ -572,7 +572,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 = ..., **kwargs: Any, ) -> None: ... def warn( @@ -581,7 +581,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 = ..., **kwargs: Any, ) -> None: ... def error( @@ -590,7 +590,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 = ..., **kwargs: Any, ) -> None: ... def critical( @@ -599,7 +599,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 = ..., **kwargs: Any, ) -> None: ... def exception( @@ -608,7 +608,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 = ..., **kwargs: Any, ) -> None: ... def log( @@ -618,7 +618,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 = ..., **kwargs: Any, ) -> None: ... @@ -628,7 +628,7 @@ else: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def info( @@ -636,7 +636,7 @@ else: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def warning( @@ -644,7 +644,7 @@ else: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def warn( @@ -652,7 +652,7 @@ else: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def error( @@ -660,7 +660,7 @@ else: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def critical( @@ -668,7 +668,7 @@ else: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def exception( @@ -676,7 +676,7 @@ else: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... def log( @@ -685,7 +685,7 @@ else: *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., - extra: Optional[dict[str, Any]] = ..., + extra: dict[str, Any] | None = ..., **kwargs: Any, ) -> None: ... @@ -710,8 +710,8 @@ if sys.version_info >= (3, 8): datefmt: str | None = ..., style: str = ..., level: _Level | None = ..., - stream: Optional[SupportsWrite[str]] = ..., - handlers: Optional[Iterable[Handler]] = ..., + stream: SupportsWrite[str] | None = ..., + handlers: Iterable[Handler] | None = ..., force: bool = ..., ) -> None: ... @@ -724,8 +724,8 @@ else: datefmt: str | None = ..., style: str = ..., level: _Level | None = ..., - stream: Optional[SupportsWrite[str]] = ..., - handlers: Optional[Iterable[Handler]] = ..., + stream: SupportsWrite[str] | None = ..., + handlers: Iterable[Handler] | None = ..., ) -> None: ... def shutdown(handlerList: Sequence[Any] = ...) -> None: ... # handlerList is undocumented @@ -738,9 +738,9 @@ lastResort: StreamHandler | None class StreamHandler(Handler): stream: SupportsWrite[str] # undocumented terminator: str - def __init__(self, stream: Optional[SupportsWrite[str]] = ...) -> None: ... + def __init__(self, stream: SupportsWrite[str] | None = ...) -> None: ... if sys.version_info >= (3, 7): - def setStream(self, stream: SupportsWrite[str]) -> Optional[SupportsWrite[str]]: ... + def setStream(self, stream: SupportsWrite[str]) -> SupportsWrite[str] | None: ... class FileHandler(StreamHandler): baseFilename: str # undocumented diff --git a/stdlib/logging/config.pyi b/stdlib/logging/config.pyi index 4bf960471153..8147f34a13d1 100644 --- a/stdlib/logging/config.pyi +++ b/stdlib/logging/config.pyi @@ -24,7 +24,7 @@ def dictConfig(config: dict[str, Any]) -> None: ... if sys.version_info >= (3, 10): def fileConfig( fname: _Path | IO[str] | RawConfigParser, - defaults: Optional[dict[str, str]] = ..., + defaults: dict[str, str] | None = ..., disable_existing_loggers: bool = ..., encoding: str | None = ..., ) -> None: ... @@ -32,7 +32,7 @@ if sys.version_info >= (3, 10): else: def fileConfig( fname: _Path | IO[str] | RawConfigParser, - defaults: Optional[dict[str, str]] = ..., + defaults: dict[str, str] | None = ..., disable_existing_loggers: bool = ..., ) -> None: ... diff --git a/stdlib/logging/handlers.pyi b/stdlib/logging/handlers.pyi index c55ca9bd9e28..304488fc2cfb 100644 --- a/stdlib/logging/handlers.pyi +++ b/stdlib/logging/handlers.pyi @@ -210,7 +210,7 @@ class SMTPHandler(Handler): fromaddr: str, toaddrs: str | list[str], subject: str, - credentials: Optional[tuple[str, str]] = ..., + credentials: tuple[str, str] | None = ..., secure: Union[tuple[()], tuple[str], tuple[str, str], None] = ..., timeout: float = ..., ) -> None: ... @@ -236,7 +236,7 @@ class HTTPHandler(Handler): url: str # undocumented method: str # undocumented secure: bool # undocumented - credentials: Optional[tuple[str, str]] # undocumented + credentials: tuple[str, str] | None # undocumented context: ssl.SSLContext | None # undocumented def __init__( self, @@ -244,7 +244,7 @@ class HTTPHandler(Handler): url: str, method: str = ..., secure: bool = ..., - credentials: Optional[tuple[str, str]] = ..., + credentials: tuple[str, str] | None = ..., context: ssl.SSLContext | None = ..., ) -> None: ... def mapLogRecord(self, record: LogRecord) -> dict[str, Any]: ... diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index 57c35ec9768b..2af493368545 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -153,7 +153,7 @@ class MaildirMessage(Message): class _mboxMMDFMessage(Message): def get_from(self) -> str: ... def set_from( - self, from_: str, time_: Optional[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: ... @@ -191,7 +191,7 @@ class _ProxyFile(Generic[AnyStr]): def close(self) -> None: ... def __enter__(self) -> _ProxyFile[AnyStr]: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc: BaseException | None, tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None ) -> None: ... def readable(self) -> bool: ... def writable(self) -> bool: ... diff --git a/stdlib/mimetypes.pyi b/stdlib/mimetypes.pyi index 8c14019503d9..4156fe161be0 100644 --- a/stdlib/mimetypes.pyi +++ b/stdlib/mimetypes.pyi @@ -10,8 +10,8 @@ else: def guess_all_extensions(type: str, strict: bool = ...) -> List[str]: ... def guess_extension(type: str, strict: bool = ...) -> str | None: ... -def init(files: Optional[Sequence[str]] = ...) -> None: ... -def read_mime_types(file: str) -> Optional[Dict[str, str]]: ... +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 diff --git a/stdlib/modulefinder.pyi b/stdlib/modulefinder.pyi index fc018e7f1c0d..0955ad3a1fea 100644 --- a/stdlib/modulefinder.pyi +++ b/stdlib/modulefinder.pyi @@ -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]] = ..., + excludes: Container[str] | None = ..., replace_paths: Optional[Sequence[Tuple[str, str]]] = ..., ) -> 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,7 +53,7 @@ class ModuleFinder: def run_script(self, pathname: str) -> None: ... def load_file(self, pathname: str) -> None: ... # undocumented def import_hook( - self, name: str, caller: Module | None = ..., fromlist: Optional[List[str]] = ..., level: int = ... + 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 @@ -68,7 +68,7 @@ class ModuleFinder: def add_module(self, fqname: str) -> Module: ... # undocumented def find_module( self, name: str, path: str | None, parent: Module | None = ... - ) -> Tuple[Optional[IO[Any]], str | None, Tuple[str, str, int]]: ... # undocumented + ) -> Tuple[IO[Any] | None, str | None, Tuple[str, str, int]]: ... # undocumented def report(self) -> None: ... def any_missing(self) -> List[str]: ... # undocumented def any_missing_maybe(self) -> Tuple[List[str], List[str]]: ... # undocumented diff --git a/stdlib/msilib/__init__.pyi b/stdlib/msilib/__init__.pyi index a8e641c1cf1a..1b25db5b5ca9 100644 --- a/stdlib/msilib/__init__.pyi +++ b/stdlib/msilib/__init__.pyi @@ -91,7 +91,7 @@ if sys.platform == "win32": def add_file( 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: diff --git a/stdlib/multiprocessing/__init__.pyi b/stdlib/multiprocessing/__init__.pyi index 5744e3c70e0d..8133bff63fa9 100644 --- a/stdlib/multiprocessing/__init__.pyi +++ b/stdlib/multiprocessing/__init__.pyi @@ -60,7 +60,7 @@ RawArray = context._default_context.RawArray Value = context._default_context.Value Array = context._default_context.Array -def Barrier(parties: int, action: Optional[Callable[..., Any]] = ..., timeout: float | None = ...) -> _BarrierType: ... +def Barrier(parties: int, action: Callable[..., Any] | None = ..., timeout: float | None = ...) -> _BarrierType: ... def BoundedSemaphore(value: int = ...) -> _BoundedSemaphoreType: ... def Condition(lock: _LockLike | None = ...) -> _ConditionType: ... def Event() -> _EventType: ... @@ -70,7 +70,7 @@ def Semaphore(value: int = ...) -> _SemaphoreType: ... def Pipe(duplex: bool = ...) -> tuple[connection.Connection, connection.Connection]: ... def Pool( processes: int | None = ..., - initializer: Optional[Callable[..., Any]] = ..., + initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ..., maxtasksperchild: int | None = ..., ) -> pool.Pool: ... diff --git a/stdlib/multiprocessing/connection.pyi b/stdlib/multiprocessing/connection.pyi index 03b8f5e13f2a..8b99181d2e50 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -30,7 +30,7 @@ class _ConnectionBase: def poll(self, timeout: float | None = ...) -> bool: ... def __enter__(self) -> _ConnectionBase: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_value: BaseException | None, exc_tb: types.TracebackType | None + self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... class Connection(_ConnectionBase): ... @@ -50,7 +50,7 @@ class Listener: def last_accepted(self) -> _Address | None: ... def __enter__(self) -> Listener: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_value: BaseException | None, exc_tb: types.TracebackType | None + self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... def deliver_challenge(connection: Connection, authkey: bytes) -> None: ... diff --git a/stdlib/multiprocessing/context.pyi b/stdlib/multiprocessing/context.pyi index 8ff88bbc68e0..5245df301d44 100644 --- a/stdlib/multiprocessing/context.pyi +++ b/stdlib/multiprocessing/context.pyi @@ -40,7 +40,7 @@ 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: float | None = ... + self, parties: int, action: Callable[..., Any] | None = ..., timeout: float | None = ... ) -> synchronize.Barrier: ... def BoundedSemaphore(self, value: int = ...) -> synchronize.BoundedSemaphore: ... def Condition(self, lock: _LockLike | None = ...) -> synchronize.Condition: ... @@ -54,7 +54,7 @@ class BaseContext(object): def Pool( self, processes: int | None = ..., - initializer: Optional[Callable[..., Any]] = ..., + initializer: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ..., maxtasksperchild: int | None = ..., ) -> multiprocessing.pool.Pool: ... diff --git a/stdlib/multiprocessing/dummy/__init__.pyi b/stdlib/multiprocessing/dummy/__init__.pyi index ea0cc06d8e4b..55fda28bf776 100644 --- a/stdlib/multiprocessing/dummy/__init__.pyi +++ b/stdlib/multiprocessing/dummy/__init__.pyi @@ -22,7 +22,7 @@ class DummyProcess(threading.Thread): def __init__( self, group: Any = ..., - target: Optional[Callable[..., Any]] = ..., + target: Callable[..., Any] | None = ..., name: str | None = ..., args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ..., @@ -44,7 +44,7 @@ class Value: def Array(typecode: Any, sequence: Sequence[Any], lock: Any = ...) -> array.array[Any]: ... def Manager() -> Any: ... def Pool( - processes: int | None = ..., 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 0d1858b35a20..0be98fc479e4 100644 --- a/stdlib/multiprocessing/dummy/connection.pyi +++ b/stdlib/multiprocessing/dummy/connection.pyi @@ -17,19 +17,19 @@ class Connection(object): send_bytes: Any def __enter__(self: _ConnectionT) -> _ConnectionT: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __init__(self, _in: Any, _out: Any) -> None: ... def close(self) -> None: ... 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: _ListenerT) -> _ListenerT: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __init__(self, address: _Address | None = ..., family: int | None = ..., backlog: int = ...) -> None: ... def accept(self) -> Connection: ... diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index dc53d10e3b14..43cd91d7dccb 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -102,7 +102,7 @@ class BaseManager(ContextManager[BaseManager]): ) -> 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: float | None = ...) -> None: ... # undocumented @property @@ -111,10 +111,10 @@ class BaseManager(ContextManager[BaseManager]): 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 afcca36ef20b..554db0ba7e2b 100644 --- a/stdlib/multiprocessing/pool.pyi +++ b/stdlib/multiprocessing/pool.pyi @@ -38,7 +38,7 @@ class Pool(ContextManager[Pool]): def __init__( self, processes: int | None = ..., - initializer: Optional[Callable[..., None]] = ..., + initializer: Callable[..., None] | None = ..., initargs: Iterable[Any] = ..., maxtasksperchild: int | None = ..., context: Any | None = ..., @@ -81,7 +81,7 @@ class Pool(ContextManager[Pool]): class ThreadPool(Pool, ContextManager[ThreadPool]): def __init__( - self, processes: int | None = ..., 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 bd441c2316f5..1c29e7f79a5b 100644 --- a/stdlib/multiprocessing/process.pyi +++ b/stdlib/multiprocessing/process.pyi @@ -8,7 +8,7 @@ class BaseProcess: def __init__( self, group: None = ..., - target: Optional[Callable[..., Any]] = ..., + target: Callable[..., Any] | None = ..., name: str | None = ..., args: Tuple[Any, ...] = ..., kwargs: Mapping[str, Any] = ..., diff --git a/stdlib/multiprocessing/shared_memory.pyi b/stdlib/multiprocessing/shared_memory.pyi index 33bc53a3eb33..ec86882d1d21 100644 --- a/stdlib/multiprocessing/shared_memory.pyi +++ b/stdlib/multiprocessing/shared_memory.pyi @@ -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: str | None = ...) -> 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/synchronize.pyi b/stdlib/multiprocessing/synchronize.pyi index 3dbd675479ef..b1ace8874c70 100644 --- a/stdlib/multiprocessing/synchronize.pyi +++ b/stdlib/multiprocessing/synchronize.pyi @@ -7,7 +7,7 @@ _LockLike = Lock | RLock class Barrier(threading.Barrier): def __init__( - self, parties: int, action: Optional[Callable[..., Any]] = ..., timeout: float | None = ..., *ctx: BaseContext + self, parties: int, action: Callable[..., Any] | None = ..., timeout: float | None = ..., *ctx: BaseContext ) -> None: ... class BoundedSemaphore(Semaphore): diff --git a/stdlib/optparse.pyi b/stdlib/optparse.pyi index 16926d08bc1b..97c57d8391d9 100644 --- a/stdlib/optparse.pyi +++ b/stdlib/optparse.pyi @@ -88,9 +88,9 @@ class Option: default: Any nargs: int type: Any - callback: Optional[Callable[..., Any]] - callback_args: Optional[Tuple[Any, ...]] - callback_kwargs: Optional[Dict[str, Any]] + 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: ... @@ -149,7 +149,7 @@ class OptionGroup(OptionContainer): 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: ... @@ -163,12 +163,12 @@ class OptionParser(OptionContainer): allow_interspersed_args: bool 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: str | None - rargs: Optional[List[Any]] + rargs: List[Any] | None standard_option_list: List[Option] usage: str | None values: Values | None @@ -176,7 +176,7 @@ class OptionParser(OptionContainer): def __init__( self, usage: str | None = ..., - option_list: Optional[Iterable[Option]] = ..., + option_list: Iterable[Option] | None = ..., option_class: Type[Option] = ..., version: str | None = ..., conflict_handler: str = ..., @@ -216,11 +216,11 @@ class OptionParser(OptionContainer): def get_usage(self) -> str: ... def get_version(self) -> str: ... def parse_args( - self, args: Optional[Sequence[AnyStr]] = ..., values: Values | None = ... + 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 f8b28985bd59..eaa31640e359 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -376,7 +376,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: ... @@ -849,9 +849,9 @@ 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): diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index 9567618a7869..8be0db8f484d 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -56,7 +56,7 @@ class Path(PurePath): def __new__(cls: Type[_P], *args: StrPath, **kwargs: Any) -> _P: ... def __enter__(self: _P) -> _P: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_value: BaseException | None, traceback: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None ) -> bool | None: ... @classmethod def cwd(cls: Type[_P]) -> _P: ... diff --git a/stdlib/pdb.pyi b/stdlib/pdb.pyi index a43b56fc737a..ae4383f361d5 100644 --- a/stdlib/pdb.pyi +++ b/stdlib/pdb.pyi @@ -12,8 +12,8 @@ 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) -> _T | None: ... @@ -48,9 +48,9 @@ class Pdb(Bdb, Cmd): 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: ... @@ -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 4505e0586e8e..6a94d26f17d9 100644 --- a/stdlib/pickle.pyi +++ b/stdlib/pickle.pyi @@ -31,10 +31,10 @@ 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: @@ -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: @@ -87,7 +87,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 8b1b7bcabe15..f9eaa67daa73 100644 --- a/stdlib/pickletools.pyi +++ b/stdlib/pickletools.pyi @@ -156,8 +156,8 @@ def genops(pickle: bytes | IO[bytes]) -> Iterator[Tuple[OpcodeInfo, Any | None, def optimize(p: bytes | IO[bytes]) -> bytes: ... def dis( pickle: bytes | IO[bytes], - out: Optional[IO[str]] = ..., - memo: Optional[MutableMapping[int, Any]] = ..., + 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 173f48e01689..105a6fe240e6 100644 --- a/stdlib/pkgutil.pyi +++ b/stdlib/pkgutil.pyi @@ -20,10 +20,10 @@ 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[MetaPathFinder | PathEntryFinder]: ... -def iter_modules(path: Optional[Iterable[str]] = ..., prefix: str = ...) -> Iterator[ModuleInfo]: ... +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: Optional[Callable[[str], None]] = ... ) -> Iterator[ModuleInfo]: ... def get_data(package: str, resource: str) -> bytes | None: ... diff --git a/stdlib/pprint.pyi b/stdlib/pprint.pyi index b40d793f6bc0..f32b58427e37 100644 --- a/stdlib/pprint.pyi +++ b/stdlib/pprint.pyi @@ -32,7 +32,7 @@ else: if sys.version_info >= (3, 10): def pp( object: object, - stream: Optional[IO[str]] = ..., + stream: IO[str] | None = ..., indent: int = ..., width: int = ..., depth: int | None = ..., @@ -45,7 +45,7 @@ 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: int | None = ..., @@ -57,7 +57,7 @@ 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: int | None = ..., @@ -70,7 +70,7 @@ 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: int | None = ..., @@ -82,7 +82,7 @@ elif sys.version_info >= (3, 8): else: def pprint( object: object, - stream: Optional[IO[str]] = ..., + stream: IO[str] | None = ..., indent: int = ..., width: int = ..., depth: int | None = ..., @@ -101,7 +101,7 @@ class PrettyPrinter: indent: int = ..., width: int = ..., depth: int | None = ..., - stream: Optional[IO[str]] = ..., + stream: IO[str] | None = ..., *, compact: bool = ..., sort_dicts: bool = ..., @@ -113,7 +113,7 @@ class PrettyPrinter: indent: int = ..., width: int = ..., depth: int | None = ..., - stream: Optional[IO[str]] = ..., + stream: IO[str] | None = ..., *, compact: bool = ..., sort_dicts: bool = ..., @@ -124,7 +124,7 @@ class PrettyPrinter: indent: int = ..., width: int = ..., depth: int | None = ..., - stream: Optional[IO[str]] = ..., + stream: IO[str] | None = ..., *, compact: bool = ..., ) -> None: ... diff --git a/stdlib/pstats.pyi b/stdlib/pstats.pyi index 42c2b1d4f8e5..012fddc7493a 100644 --- a/stdlib/pstats.pyi +++ b/stdlib/pstats.pyi @@ -26,7 +26,7 @@ class Stats: self: _T, __arg: None | str | Profile | _cProfile = ..., *args: Union[None, str, Profile, _cProfile, _T], - stream: Optional[IO[Any]] = ..., + stream: IO[Any] | None = ..., ) -> None: ... def init(self, arg: None | str | Profile | _cProfile) -> None: ... def load_stats(self, arg: None | str | Profile | _cProfile) -> None: ... diff --git a/stdlib/py_compile.pyi b/stdlib/py_compile.pyi index 169a09a63ee8..7816ee2bf9a5 100644 --- a/stdlib/py_compile.pyi +++ b/stdlib/py_compile.pyi @@ -42,4 +42,4 @@ else: 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 d8f70f9c3521..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[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[Class | str]], + super: List[Class | str] | None, file: str, lineno: int, parent: Class | None = ..., ) -> None: ... else: - def __init__(self, module: str, name: str, super: Optional[List[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 @@ -33,5 +33,5 @@ class Function: 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, 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 540feb10f20c..e3274b73aa8d 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -19,7 +19,7 @@ from typing import ( ) # the return type of sys.exc_info(), used by ErrorDuringImport.__init__ -_Exc_Info = Tuple[Optional[Type[BaseException]], BaseException | None, TracebackType | None] +_Exc_Info = Tuple[Type[BaseException] | None, BaseException | None, TracebackType | None] __author__: str __date__: str @@ -35,7 +35,7 @@ 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: object | None = ...) -> 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]) -> AnyStr | None: ... @@ -43,7 +43,7 @@ def synopsis(filename: str, cache: MutableMapping[str, Tuple[int, str]] = ...) - class ErrorDuringImport(Exception): filename: str - exc: Optional[Type[BaseException]] + exc: Type[BaseException] | None value: BaseException | None tb: TracebackType | None def __init__(self, filename: str, exc_info: _Exc_Info) -> None: ... @@ -142,7 +142,7 @@ class HTMLDoc(Doc): def docdata( 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): @@ -207,10 +207,10 @@ html: HTMLDoc class _OldStyleClass: ... -def resolve(thing: str | object, forceload: bool = ...) -> Optional[Tuple[object, 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: 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: str | object, forceload: bool = ...) -> None: ... def writedocs(dir: str, pkgpath: str = ..., done: Any | None = ...) -> None: ... @@ -219,7 +219,7 @@ class Helper: keywords: Dict[str, str | Tuple[str, str]] symbols: Dict[str, str] topics: Dict[str, str | Tuple[str, ...]] - def __init__(self, input: Optional[IO[str]] = ..., output: Optional[IO[str]] = ...) -> None: ... + def __init__(self, input: IO[str] | None = ..., output: IO[str] | None = ...) -> None: ... input: IO[str] output: IO[str] def __call__(self, request: str | Helper | object = ...) -> None: ... diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index 7327c8aa00b8..87759de02bb9 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -75,5 +75,5 @@ def ErrorString(__code: int) -> str: ... # intern is undocumented def ParserCreate( - encoding: str | None = ..., namespace_separator: str | None = ..., intern: Optional[Dict[str, Any]] = ... + encoding: str | None = ..., namespace_separator: str | None = ..., intern: Dict[str, Any] | None = ... ) -> XMLParserType: ... diff --git a/stdlib/random.pyi b/stdlib/random.pyi index 2201f32f0e9f..9649ded7d55b 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -19,15 +19,15 @@ class Random(_random.Random): def choices( self, 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(self, x: MutableSequence[Any], random: Optional[Callable[[], float]] = ...) -> None: ... if sys.version_info >= (3, 9): def sample( - self, population: 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: Sequence[_T] | Set[_T], k: int) -> list[_T]: ... @@ -63,15 +63,15 @@ 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: ... if sys.version_info >= (3, 9): - def sample(population: 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: Sequence[_T] | Set[_T], k: int) -> list[_T]: ... diff --git a/stdlib/re.pyi b/stdlib/re.pyi index f8e6b3fe4c9a..588be2338292 100644 --- a/stdlib/re.pyi +++ b/stdlib/re.pyi @@ -56,19 +56,19 @@ 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[AnyStr | Any]: ... @overload diff --git a/stdlib/rlcompleter.pyi b/stdlib/rlcompleter.pyi index ae2f0f734091..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 __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 9b502e945402..dff93402437a 100644 --- a/stdlib/runpy.pyi +++ b/stdlib/runpy.pyi @@ -17,6 +17,6 @@ class _ModifiedArgv0: def __exit__(self, *args: Any) -> None: ... def run_module( - mod_name: str, init_globals: Optional[Dict[str, Any]] = ..., run_name: str | None = ..., 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: str | None = ...) -> 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/select.pyi b/stdlib/select.pyi index 57d981b02bc5..88891f4feb84 100644 --- a/stdlib/select.pyi +++ b/stdlib/select.pyi @@ -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: float | None = ... + self, __changelist: Iterable[kevent] | None, __maxevents: int, __timeout: float | None = ... ) -> List[kevent]: ... def fileno(self) -> int: ... @classmethod @@ -104,7 +104,7 @@ if sys.platform == "linux": def __enter__(self) -> epoll: ... def __exit__( self, - exc_type: Optional[Type[BaseException]] = ..., + exc_type: Type[BaseException] | None = ..., exc_val: BaseException | None = ..., exc_tb: TracebackType | None = ..., ) -> None: ... diff --git a/stdlib/site.pyi b/stdlib/site.pyi index 9c8c3e363770..d9f8da8a7e2d 100644 --- a/stdlib/site.pyi +++ b/stdlib/site.pyi @@ -6,7 +6,7 @@ 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/smtplib.pyi b/stdlib/smtplib.pyi index afa316e58f1f..9f93b7ced373 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -77,7 +77,7 @@ class SMTP: ) -> None: ... def __enter__(self) -> SMTP: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_value: BaseException | None, tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, tb: TracebackType | None ) -> None: ... def set_debuglevel(self, debuglevel: int) -> None: ... def connect(self, host: str = ..., port: int = ..., source_address: _SourceAddress | None = ...) -> _Reply: ... @@ -123,7 +123,7 @@ class SMTP: self, msg: _Message, from_addr: str | None = ..., - to_addrs: Optional[str | Sequence[str]] = ..., + to_addrs: str | Sequence[str] | None = ..., mail_options: Sequence[str] = ..., rcpt_options: Sequence[str] = ..., ) -> _SendErrs: ... diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index 5926439a7cd4..65a33f4efd00 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -613,7 +613,7 @@ def getfqdn(name: str = ...) -> str: ... def create_connection( address: tuple[str | None, int], timeout: float | None = ..., # noqa: F811 - source_address: Optional[tuple[bytearray | bytes | str, int]] = ..., + source_address: tuple[bytearray | bytes | str, int] | None = ..., ) -> socket: ... if sys.version_info >= (3, 8): diff --git a/stdlib/socketserver.pyi b/stdlib/socketserver.pyi index d24329c755f8..98190fdb30ad 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -32,7 +32,7 @@ class BaseServer: def verify_request(self, request: _RequestType, client_address: _AddressType) -> bool: ... def __enter__(self: _T) -> _T: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: types.TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ... def service_actions(self) -> None: ... def shutdown_request(self, request: _RequestType) -> None: ... # undocumented @@ -87,7 +87,7 @@ if sys.platform != "win32": if sys.platform != "win32": class ForkingMixIn: timeout: float | None # undocumented - active_children: Optional[Set[int]] # undocumented + active_children: Set[int] | None # undocumented max_children: int # undocumented if sys.version_info >= (3, 7): block_on_close: bool diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index ad725c537021..f6716c04d5f4 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -71,7 +71,7 @@ if sys.version_info >= (3, 7): detect_types: int = ..., isolation_level: str | None = ..., check_same_thread: bool = ..., - factory: Optional[Type[Connection]] = ..., + factory: Type[Connection] | None = ..., cached_statements: int = ..., uri: bool = ..., ) -> Connection: ... @@ -83,7 +83,7 @@ else: detect_types: int = ..., isolation_level: str | None = ..., check_same_thread: bool = ..., - factory: Optional[Type[Connection]] = ..., + factory: Type[Connection] | None = ..., cached_statements: int = ..., uri: bool = ..., ) -> Connection: ... diff --git a/stdlib/sre_parse.pyi b/stdlib/sre_parse.pyi index e482af1db162..c46bd74af87f 100644 --- a/stdlib/sre_parse.pyi +++ b/stdlib/sre_parse.pyi @@ -47,10 +47,10 @@ class SubPattern: 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: int | slice) -> None: ... diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index 19ff972129ff..d9052c61d4de 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -236,7 +236,7 @@ class SSLSocket(socket.socket): proto: int = ..., fileno: int | None = ..., suppress_ragged_eofs: bool = ..., - npn_protocols: Optional[Iterable[str]] = ..., + npn_protocols: Iterable[str] | None = ..., ciphers: str | None = ..., server_hostname: str | None = ..., _context: SSLContext | None = ..., @@ -268,7 +268,7 @@ class SSLSocket(socket.socket): 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 cipher(self) -> Tuple[str, str, int] | None: ... def shared_ciphers(self) -> Optional[List[Tuple[str, str, int]]]: ... def compression(self) -> str | None: ... def get_channel_binding(self, cb_type: str = ...) -> bytes | None: ... @@ -369,7 +369,7 @@ class SSLObject: def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ... def selected_alpn_protocol(self) -> str | None: ... def selected_npn_protocol(self) -> str | None: ... - def cipher(self) -> Optional[Tuple[str, str, int]]: ... + def cipher(self) -> Tuple[str, str, int] | None: ... def shared_ciphers(self) -> Optional[List[Tuple[str, str, int]]]: ... def compression(self) -> str | None: ... def pending(self) -> int: ... diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index 1a5d4716d4f0..407fd58df4bd 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: ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index ec5aa6b0bf72..7c72efbedee3 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -707,9 +707,9 @@ class CalledProcessError(SubprocessError): 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 @@ -1009,7 +1009,7 @@ class Popen(Generic[AnyStr]): def kill(self) -> None: ... def __enter__(self: _S) -> _S: ... def __exit__( - self, type: Optional[Type[BaseException]], value: BaseException | None, traceback: TracebackType | None + self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -1030,7 +1030,7 @@ if sys.platform == "win32": hStdOutput: Any | None = ..., hStdError: Any | None = ..., wShowWindow: int = ..., - lpAttributeList: Optional[Mapping[str, Any]] = ..., + lpAttributeList: Mapping[str, Any] | None = ..., ) -> None: ... dwFlags: int hStdInput: Any | None diff --git a/stdlib/sunau.pyi b/stdlib/sunau.pyi index 614da563abca..45307f1f8e1d 100644 --- a/stdlib/sunau.pyi +++ b/stdlib/sunau.pyi @@ -32,7 +32,7 @@ class Au_read: def __init__(self, f: _File) -> None: ... def __enter__(self) -> Au_read: ... 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: ... 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 280dcb92652d..7e9f64fdcb2e 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -54,7 +54,7 @@ exec_prefix: str executable: str float_repr_style: str hexversion: int -last_type: Optional[Type[BaseException]] +last_type: Type[BaseException] | None last_value: BaseException | None last_traceback: TracebackType | None maxsize: int diff --git a/stdlib/sysconfig.pyi b/stdlib/sysconfig.pyi index bd923405e4e0..dcecf4ffd80e 100644 --- a/stdlib/sysconfig.pyi +++ b/stdlib/sysconfig.pyi @@ -7,11 +7,11 @@ def get_config_vars() -> Dict[str, Any]: ... 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 | None: ... -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 | None: ... +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 cbce391796e1..19d9a56b4fd0 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -72,16 +72,16 @@ ENCODING: str def open( name: StrOrBytesPath | None = ..., mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., # depends on mode + fileobj: IO[bytes] | None = ..., # depends on mode bufsize: int = ..., *, format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., errors: str = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., compresslevel: int | None = ..., @@ -102,7 +102,7 @@ class TarFile: encoding: str | None errors: str fileobject: Type[ExFileObject] - pax_headers: Optional[Mapping[str, str]] + pax_headers: Mapping[str, str] | None debug: int | None errorlevel: int | None offset: int # undocumented @@ -112,19 +112,19 @@ class TarFile: mode: Literal["r", "a", "w", "x"] = ..., fileobj: _Fileobj | None = ..., format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., errors: str = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., copybufsize: int | None = ..., # undocumented ) -> None: ... def __enter__(self) -> TarFile: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __iter__(self) -> Iterator[TarInfo]: ... @classmethod @@ -132,16 +132,16 @@ class TarFile: cls, name: StrOrBytesPath | None = ..., mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., # depends on mode + fileobj: IO[bytes] | None = ..., # depends on mode bufsize: int = ..., *, format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., errors: str = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., ) -> TarFile: ... @@ -154,11 +154,11 @@ class TarFile: *, compresslevel: int = ..., format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., ) -> TarFile: ... @@ -172,11 +172,11 @@ class TarFile: compresslevel: int = ..., *, format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., ) -> TarFile: ... @@ -190,11 +190,11 @@ class TarFile: compresslevel: int = ..., *, format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., ) -> TarFile: ... @@ -208,11 +208,11 @@ class TarFile: compresslevel: int = ..., *, format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., ) -> TarFile: ... @@ -226,11 +226,11 @@ class TarFile: compresslevel: int = ..., *, format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., ) -> TarFile: ... @@ -239,30 +239,30 @@ class TarFile: cls, name: StrOrBytesPath | None, mode: Literal["r", "w", "x"] = ..., - fileobj: Optional[IO[bytes]] = ..., + fileobj: IO[bytes] | None = ..., preset: int | None = ..., *, format: int | None = ..., - tarinfo: Optional[Type[TarInfo]] = ..., + tarinfo: Type[TarInfo] | None = ..., dereference: bool | None = ..., ignore_zeros: bool | None = ..., encoding: str | None = ..., - pax_headers: Optional[Mapping[str, str]] = ..., + pax_headers: Mapping[str, str] | None = ..., debug: int | None = ..., errorlevel: int | None = ..., ) -> TarFile: ... 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 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: str | TarInfo, path: StrOrBytesPath = ..., set_attrs: bool = ..., *, numeric_owner: bool = ... ) -> None: ... - def extractfile(self, member: 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 @@ -291,9 +291,9 @@ class TarFile: *, filter: Optional[Callable[[TarInfo], TarInfo | 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: str | None = ..., arcname: str | None = ..., fileobj: Optional[IO[bytes]] = ... + self, name: str | None = ..., arcname: str | None = ..., fileobj: IO[bytes] | None = ... ) -> TarInfo: ... def close(self) -> None: ... diff --git a/stdlib/telnetlib.pyi b/stdlib/telnetlib.pyi index 86d20e60243f..5317e082811f 100644 --- a/stdlib/telnetlib.pyi +++ b/stdlib/telnetlib.pyi @@ -108,6 +108,6 @@ class Telnet: def listener(self) -> None: ... def expect( self, list: Sequence[Pattern[bytes] | bytes], timeout: float | None = ... - ) -> Tuple[int, Optional[Match[bytes]], bytes]: ... + ) -> Tuple[int, Match[bytes] | None, bytes]: ... def __enter__(self) -> Telnet: ... def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index aa78713d0033..32db744b5d12 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -24,7 +24,7 @@ if sys.version_info >= (3, 8): newline: str | None = ..., suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., - dir: Optional[_DirT[AnyStr]] = ..., + dir: _DirT[AnyStr] | None = ..., delete: bool = ..., *, errors: str | None = ..., @@ -37,7 +37,7 @@ if sys.version_info >= (3, 8): newline: str | None = ..., suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., - dir: Optional[_DirT[AnyStr]] = ..., + dir: _DirT[AnyStr] | None = ..., delete: bool = ..., *, errors: str | None = ..., @@ -50,7 +50,7 @@ if sys.version_info >= (3, 8): newline: str | None = ..., suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., - dir: Optional[_DirT[AnyStr]] = ..., + dir: _DirT[AnyStr] | None = ..., delete: bool = ..., *, errors: str | None = ..., @@ -65,7 +65,7 @@ else: newline: str | None = ..., suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., - dir: Optional[_DirT[AnyStr]] = ..., + dir: _DirT[AnyStr] | None = ..., delete: bool = ..., ) -> _TemporaryFileWrapper[str]: ... @overload @@ -76,7 +76,7 @@ else: newline: str | None = ..., suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., - dir: Optional[_DirT[AnyStr]] = ..., + dir: _DirT[AnyStr] | None = ..., delete: bool = ..., ) -> _TemporaryFileWrapper[bytes]: ... @overload @@ -87,7 +87,7 @@ else: newline: str | None = ..., suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., - dir: Optional[_DirT[AnyStr]] = ..., + dir: _DirT[AnyStr] | None = ..., delete: bool = ..., ) -> _TemporaryFileWrapper[Any]: ... @@ -103,7 +103,7 @@ else: newline: str | None = ..., suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., - dir: Optional[_DirT[AnyStr]] = ..., + dir: _DirT[AnyStr] | None = ..., *, errors: str | None = ..., ) -> IO[str]: ... @@ -115,7 +115,7 @@ else: newline: str | None = ..., suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., - dir: Optional[_DirT[AnyStr]] = ..., + dir: _DirT[AnyStr] | None = ..., *, errors: str | None = ..., ) -> IO[bytes]: ... @@ -127,7 +127,7 @@ else: newline: str | None = ..., suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., - dir: Optional[_DirT[AnyStr]] = ..., + dir: _DirT[AnyStr] | None = ..., *, errors: str | None = ..., ) -> IO[Any]: ... @@ -140,7 +140,7 @@ else: newline: str | None = ..., suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., - dir: Optional[_DirT[AnyStr]] = ..., + dir: _DirT[AnyStr] | None = ..., ) -> IO[str]: ... @overload def TemporaryFile( @@ -150,7 +150,7 @@ else: newline: str | None = ..., suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., - dir: Optional[_DirT[AnyStr]] = ..., + dir: _DirT[AnyStr] | None = ..., ) -> IO[bytes]: ... @overload def TemporaryFile( @@ -160,7 +160,7 @@ else: newline: str | None = ..., suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., - dir: Optional[_DirT[AnyStr]] = ..., + dir: _DirT[AnyStr] | None = ..., ) -> IO[Any]: ... class _TemporaryFileWrapper(Generic[AnyStr], IO[AnyStr]): @@ -170,7 +170,7 @@ class _TemporaryFileWrapper(Generic[AnyStr], IO[AnyStr]): def __init__(self, file: IO[AnyStr], name: str, delete: bool = ...) -> None: ... def __enter__(self) -> _TemporaryFileWrapper[AnyStr]: ... def __exit__( - self, exc: Optional[Type[BaseException]], value: BaseException | None, tb: TracebackType | None + self, exc: Type[BaseException] | None, value: BaseException | None, tb: TracebackType | None ) -> bool | None: ... def __getattr__(self, name: str) -> Any: ... def close(self) -> None: ... @@ -291,7 +291,7 @@ class SpooledTemporaryFile(IO[AnyStr]): def rollover(self) -> None: ... def __enter__(self: _S) -> _S: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... # These methods are copied from the abstract methods of IO, because # SpooledTemporaryFile implements IO. @@ -321,12 +321,12 @@ class TemporaryDirectory(Generic[AnyStr]): def __init__(self: TemporaryDirectory[str], suffix: None = ..., prefix: None = ..., dir: None = ...) -> None: ... @overload def __init__( - self, suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., 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: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -335,16 +335,16 @@ class TemporaryDirectory(Generic[AnyStr]): def mkstemp() -> Tuple[int, str]: ... @overload def mkstemp( - suffix: AnyStr | None = ..., prefix: AnyStr | None = ..., 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: AnyStr | None = ..., prefix: AnyStr | None = ..., 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: AnyStr | None = ..., prefix: AnyStr | None = ..., 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/threading.pyi b/stdlib/threading.pyi index f5770df80dde..686380756c34 100644 --- a/stdlib/threading.pyi +++ b/stdlib/threading.pyi @@ -3,7 +3,7 @@ from types import FrameType, TracebackType from typing import Any, Callable, Iterable, List, Mapping, Optional, Type, TypeVar, Union # TODO recursive type -_TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] +_TF = Callable[[FrameType, str, Any], Callable[..., Any] | None] _PF = Callable[[FrameType, str, Any], None] _T = TypeVar("_T") @@ -40,10 +40,10 @@ class Thread: def __init__( self, group: None = ..., - target: Optional[Callable[..., Any]] = ..., + target: Callable[..., Any] | None = ..., name: str | None = ..., args: Iterable[Any] = ..., - kwargs: Optional[Mapping[str, Any]] = ..., + kwargs: Mapping[str, Any] | None = ..., *, daemon: bool | None = ..., ) -> None: ... @@ -67,7 +67,7 @@ class Lock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... @@ -77,7 +77,7 @@ class _RLock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... @@ -88,7 +88,7 @@ class Condition: def __init__(self, lock: Lock | _RLock | None = ...) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... def release(self) -> None: ... @@ -101,7 +101,7 @@ class Condition: class Semaphore: def __init__(self, value: int = ...) -> None: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def acquire(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ... def __enter__(self, blocking: bool = ..., timeout: float | None = ...) -> bool: ... @@ -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: ... diff --git a/stdlib/timeit.pyi b/stdlib/timeit.pyi index 18ab9bd93db4..ad173584838a 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 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: Optional[Callable[[_timerFunc], _timerFunc]] = ...) -> None: ... diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 5bf47cd6b678..76a8e02d5a11 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -396,11 +396,11 @@ class Misc: @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 @@ -485,7 +485,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, ...]: ... @@ -611,7 +611,7 @@ class Tk(Misc, Wm): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -696,7 +696,7 @@ class Pack: # replaced by **kwargs. def pack_configure( self, - cnf: Optional[Mapping[str, Any]] = ..., + cnf: Mapping[str, Any] | None = ..., *, after: Misc = ..., anchor: _Anchor = ..., @@ -740,7 +740,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"] = ..., @@ -782,7 +782,7 @@ class _GridInfo(_InMiscNonTotal): # empty dict if widget hasn't been gridded class Grid: def grid_configure( self, - cnf: Optional[Mapping[str, Any]] = ..., + cnf: Mapping[str, Any] | None = ..., *, column: int = ..., columnspan: int = ..., @@ -848,7 +848,7 @@ class Toplevel(BaseWidget, Wm): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -877,7 +877,7 @@ class Toplevel(BaseWidget, Wm): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -904,7 +904,7 @@ class Button(Widget): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -952,7 +952,7 @@ class Button(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -1001,7 +1001,7 @@ class Canvas(Widget, XView, YView): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -1043,7 +1043,7 @@ class Canvas(Widget, XView, YView): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -1308,7 +1308,7 @@ class Checkbutton(Widget): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -1367,7 +1367,7 @@ class Checkbutton(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -1425,7 +1425,7 @@ class Entry(Widget, XView): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -1469,7 +1469,7 @@ class Entry(Widget, XView): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -1536,7 +1536,7 @@ class Frame(Widget): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -1562,7 +1562,7 @@ class Frame(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -1588,7 +1588,7 @@ class Label(Widget): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -1626,7 +1626,7 @@ class Label(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -1668,7 +1668,7 @@ class Listbox(Widget, XView, YView): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activestyle: Literal["dotbox", "none", "underline"] = ..., background: _Color = ..., @@ -1718,7 +1718,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 = ..., @@ -1783,7 +1783,7 @@ class Menu(Widget): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeborderwidth: _ScreenUnits = ..., @@ -1814,7 +1814,7 @@ class Menu(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeborderwidth: _ScreenUnits = ..., @@ -1847,7 +1847,7 @@ class Menu(Widget): def insert(self, index, itemType, cnf=..., **kw): ... def add_cascade( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, accelerator: str = ..., activebackground: _Color = ..., @@ -1868,7 +1868,7 @@ class Menu(Widget): ) -> None: ... def add_checkbutton( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, accelerator: str = ..., activebackground: _Color = ..., @@ -1894,7 +1894,7 @@ class Menu(Widget): ) -> None: ... def add_command( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, accelerator: str = ..., activebackground: _Color = ..., @@ -1914,7 +1914,7 @@ class Menu(Widget): ) -> None: ... def add_radiobutton( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, accelerator: str = ..., activebackground: _Color = ..., @@ -1937,11 +1937,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 = ..., @@ -1963,7 +1963,7 @@ class Menu(Widget): def insert_checkbutton( self, index: _MenuIndex, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, accelerator: str = ..., activebackground: _Color = ..., @@ -1990,7 +1990,7 @@ class Menu(Widget): def insert_command( self, index: _MenuIndex, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, accelerator: str = ..., activebackground: _Color = ..., @@ -2011,7 +2011,7 @@ class Menu(Widget): def insert_radiobutton( self, index: _MenuIndex, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, accelerator: str = ..., activebackground: _Color = ..., @@ -2034,7 +2034,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, index2: Any | None = ...): ... def entrycget(self, index, option): ... def entryconfigure(self, index, cnf: Any | None = ..., **kw): ... @@ -2051,7 +2051,7 @@ class Menubutton(Widget): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -2092,7 +2092,7 @@ class Menubutton(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -2137,7 +2137,7 @@ class Message(Widget): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, anchor: _Anchor = ..., aspect: int = ..., @@ -2167,7 +2167,7 @@ class Message(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, anchor: _Anchor = ..., aspect: int = ..., @@ -2200,7 +2200,7 @@ class Radiobutton(Widget): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -2248,7 +2248,7 @@ class Radiobutton(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activeforeground: _Color = ..., @@ -2304,7 +2304,7 @@ class Scale(Widget): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., background: _Color = ..., @@ -2346,7 +2346,7 @@ class Scale(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., background: _Color = ..., @@ -2395,7 +2395,7 @@ class Scrollbar(Widget): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activerelief: _Relief = ..., @@ -2408,7 +2408,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: Union[Callable[..., Tuple[float, float] | None], str] = ..., cursor: _Cursor = ..., elementborderwidth: _ScreenUnits = ..., highlightbackground: _Color = ..., @@ -2427,7 +2427,7 @@ class Scrollbar(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., activerelief: _Relief = ..., @@ -2436,7 +2436,7 @@ class Scrollbar(Widget): bg: _Color = ..., border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., - command: Union[Callable[..., Optional[Tuple[float, float]]], str] = ..., + command: Union[Callable[..., Tuple[float, float] | None], str] = ..., cursor: _Cursor = ..., elementborderwidth: _ScreenUnits = ..., highlightbackground: _Color = ..., @@ -2467,7 +2467,7 @@ class Text(Widget, XView, YView): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, autoseparators: bool = ..., background: _Color = ..., @@ -2523,7 +2523,7 @@ class Text(Widget, XView, YView): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, autoseparators: bool = ..., background: _Color = ..., @@ -2574,7 +2574,7 @@ class Text(Widget, XView, YView): @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 @@ -2582,7 +2582,7 @@ class Text(Widget, XView, YView): @overload def debug(self, boolean: bool) -> None: ... def delete(self, index1: _TextIndex, index2: _TextIndex | None = ...) -> None: ... - def dlineinfo(self, index: _TextIndex) -> Optional[Tuple[int, int, int, int, int]]: ... + def dlineinfo(self, index: _TextIndex) -> Tuple[int, int, int, int, int] | None: ... @overload def dump( self, @@ -2686,7 +2686,7 @@ class Text(Widget, XView, YView): def tag_configure( self, tagName: str, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bgstipple: _Bitmap = ..., @@ -2817,10 +2817,10 @@ class PhotoImage(Image): 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: Optional[Tuple[int, int]] = ... + self, data: str | _TkinterSequence[str] | _TkinterSequence2D[_Color], to: Tuple[int, int] | None = ... ) -> None: ... def write( - self, filename: StrOrBytesPath, format: str | None = ..., 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: ... @@ -2848,7 +2848,7 @@ class Spinbox(Widget, XView): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., background: _Color = ..., @@ -2906,7 +2906,7 @@ class Spinbox(Widget, XView): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, activebackground: _Color = ..., background: _Color = ..., @@ -2987,7 +2987,7 @@ class LabelFrame(Widget): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -3020,7 +3020,7 @@ class LabelFrame(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -3052,7 +3052,7 @@ class PanedWindow(Widget): def __init__( self, master: Misc | None = ..., - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., @@ -3080,7 +3080,7 @@ class PanedWindow(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: _Color = ..., bd: _ScreenUnits = ..., diff --git a/stdlib/tkinter/dnd.pyi b/stdlib/tkinter/dnd.pyi index 488fefb6274e..ab152b069248 100644 --- a/stdlib/tkinter/dnd.pyi +++ b/stdlib/tkinter/dnd.pyi @@ -5,8 +5,8 @@ from typing import ClassVar, Optional class DndHandler: 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: ... diff --git a/stdlib/tkinter/tix.pyi b/stdlib/tkinter/tix.pyi index 2e54954efa51..d5d8e987a07f 100644 --- a/stdlib/tkinter/tix.pyi +++ b/stdlib/tkinter/tix.pyi @@ -37,7 +37,7 @@ 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_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: ... @@ -52,7 +52,7 @@ class TixWidget(tkinter.Widget): self, master: tkinter.Misc | None = ..., widgetName: str | None = ..., - static_options: Optional[List[str]] = ..., + static_options: List[str] | None = ..., cnf: Dict[str, Any] = ..., kw: Dict[str, 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 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 552225049efe..f5a99fb63f89 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -57,7 +57,7 @@ class Button(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, command: tkinter._ButtonCommand = ..., compound: _TtkCompound = ..., @@ -107,7 +107,7 @@ class Checkbutton(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, command: tkinter._ButtonCommand = ..., compound: _TtkCompound = ..., @@ -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 = ..., @@ -183,7 +183,7 @@ class Entry(Widget, tkinter.Entry): @overload # type: ignore def config( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: tkinter._Color = ..., cursor: tkinter._Cursor = ..., @@ -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 = ..., @@ -266,7 +266,7 @@ class Combobox(Entry): @overload # type: ignore def config( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, background: tkinter._Color = ..., cursor: tkinter._Cursor = ..., @@ -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 = ..., @@ -360,7 +360,7 @@ class Label(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, anchor: tkinter._Anchor = ..., background: tkinter._Color = ..., @@ -411,7 +411,7 @@ class Labelframe(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, border: tkinter._ScreenUnits = ..., borderwidth: tkinter._ScreenUnits = ..., @@ -457,7 +457,7 @@ class Menubutton(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, compound: _TtkCompound = ..., 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 = ..., @@ -535,7 +535,7 @@ 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 = ..., @@ -549,7 +549,7 @@ class Panedwindow(Widget, tkinter.PanedWindow): @overload # type: ignore def config( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, cursor: tkinter._Cursor = ..., height: int = ..., @@ -587,7 +587,7 @@ class Progressbar(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, cursor: tkinter._Cursor = ..., length: tkinter._ScreenUnits = ..., @@ -632,7 +632,7 @@ class Radiobutton(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, command: tkinter._ButtonCommand = ..., compound: _TtkCompound = ..., @@ -676,7 +676,7 @@ class Scale(Widget, tkinter.Scale): @overload # type: ignore def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, command: Union[str, Callable[[str], Any]] = ..., cursor: tkinter._Cursor = ..., @@ -696,7 +696,7 @@ class Scale(Widget, tkinter.Scale): @overload # type: ignore def config( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, command: Union[str, Callable[[str], Any]] = ..., cursor: tkinter._Cursor = ..., @@ -720,7 +720,7 @@ class Scrollbar(Widget, tkinter.Scrollbar): master: tkinter.Misc | None = ..., *, class_: str = ..., - command: Union[Callable[..., Optional[Tuple[float, float]]], str] = ..., + command: Union[Callable[..., Tuple[float, float] | None], str] = ..., cursor: tkinter._Cursor = ..., name: str = ..., orient: Literal["horizontal", "vertical"] = ..., @@ -730,9 +730,9 @@ 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: Union[Callable[..., Tuple[float, float] | None], str] = ..., cursor: tkinter._Cursor = ..., orient: Literal["horizontal", "vertical"] = ..., style: str = ..., @@ -744,9 +744,9 @@ class Scrollbar(Widget, tkinter.Scrollbar): @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: Union[Callable[..., Tuple[float, float] | None], str] = ..., cursor: tkinter._Cursor = ..., orient: Literal["horizontal", "vertical"] = ..., style: str = ..., @@ -770,7 +770,7 @@ class Separator(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, cursor: tkinter._Cursor = ..., orient: Literal["horizontal", "vertical"] = ..., @@ -795,7 +795,7 @@ class Sizegrip(Widget): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, cursor: tkinter._Cursor = ..., style: str = ..., @@ -840,7 +840,7 @@ 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]] = ..., @@ -897,7 +897,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): @overload def configure( self, - cnf: Optional[Dict[str, Any]] = ..., + cnf: Dict[str, Any] | None = ..., *, columns: str | tkinter._TkinterSequence[str] = ..., cursor: tkinter._Cursor = ..., diff --git a/stdlib/trace.pyi b/stdlib/trace.pyi index 7e42db7afa8f..b70abc7c2af6 100644 --- a/stdlib/trace.pyi +++ b/stdlib/trace.pyi @@ -10,7 +10,7 @@ class CoverageResults: def __init__( self, counts: Optional[Dict[Tuple[str, int], int]] = ..., - calledfuncs: Optional[Dict[_fileModuleFunction, int]] = ..., + calledfuncs: Dict[_fileModuleFunction, int] | None = ..., infile: StrPath | None = ..., callers: Optional[Dict[Tuple[_fileModuleFunction, _fileModuleFunction], int]] = ..., outfile: StrPath | None = ..., @@ -38,8 +38,8 @@ class Trace: def runctx( self, cmd: str | types.CodeType, - globals: Optional[Mapping[str, Any]] = ..., - locals: Optional[Mapping[str, Any]] = ..., + globals: Mapping[str, Any] | None = ..., + locals: Mapping[str, Any] | None = ..., ) -> None: ... def runfunc(self, func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... def file_module_function_of(self, frame: types.FrameType) -> _fileModuleFunction: ... diff --git a/stdlib/traceback.pyi b/stdlib/traceback.pyi index 9c52f2b3b897..09818a03513b 100644 --- a/stdlib/traceback.pyi +++ b/stdlib/traceback.pyi @@ -5,47 +5,47 @@ from typing import IO, Any, Dict, Generator, Iterable, Iterator, List, Mapping, _PT = Tuple[str, int, str, str | None] -def print_tb(tb: TracebackType | None, limit: int | None = ..., 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]], + __exc: Type[BaseException] | None, value: BaseException | None = ..., tb: TracebackType | None = ..., limit: int | None = ..., - file: Optional[IO[str]] = ..., + file: IO[str] | None = ..., chain: bool = ..., ) -> None: ... else: def print_exception( - etype: Optional[Type[BaseException]], + etype: Type[BaseException] | None, value: BaseException | None, tb: TracebackType | None, limit: int | None = ..., - file: Optional[IO[str]] = ..., + file: IO[str] | None = ..., chain: bool = ..., ) -> None: ... -def print_exc(limit: int | None = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... -def print_last(limit: int | None = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... -def print_stack(f: FrameType | None = ..., limit: int | None = ..., file: Optional[IO[str]] = ...) -> None: ... +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: BaseException | None = ...) -> 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: BaseException | None) -> 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]], + __exc: Type[BaseException] | None, value: BaseException | None = ..., tb: TracebackType | None = ..., limit: int | None = ..., @@ -54,7 +54,7 @@ if sys.version_info >= (3, 10): else: def format_exception( - etype: Optional[Type[BaseException]], + etype: Type[BaseException] | None, value: BaseException | None, tb: TracebackType | None, limit: int | None = ..., @@ -90,7 +90,7 @@ class TracebackException: lookup_lines: bool = ..., capture_locals: bool = ..., compact: bool = ..., - _seen: Optional[Set[int]] = ..., + _seen: Set[int] | None = ..., ) -> None: ... @classmethod def from_exception( @@ -112,7 +112,7 @@ class TracebackException: limit: int | None = ..., lookup_lines: bool = ..., capture_locals: bool = ..., - _seen: Optional[Set[int]] = ..., + _seen: Set[int] | None = ..., ) -> None: ... @classmethod def from_exception( @@ -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,7 +134,7 @@ class FrameSummary(Iterable[Any]): name: str, *, lookup_line: bool = ..., - locals: Optional[Mapping[str, str]] = ..., + locals: Mapping[str, str] | None = ..., line: str | None = ..., ) -> None: ... # TODO: more precise typing for __getitem__ and __iter__, diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 9ef93dd5cfbd..c4ec0d8cb981 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -163,7 +163,7 @@ 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: ... @@ -176,7 +176,7 @@ class GeneratorType(Generator[_T_co, _T_contra, _V_co]): def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... 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 @@ -312,7 +312,7 @@ if sys.version_info >= (3, 7): def new_class( name: str, bases: Iterable[object] = ..., - kwds: Optional[Dict[str, Any]] = ..., + kwds: Dict[str, Any] | None = ..., exec_body: Optional[Callable[[Dict[str, Any]], None]] = ..., ) -> type: ... def resolve_bases(bases: Iterable[object]) -> Tuple[Any, ...]: ... @@ -321,12 +321,12 @@ else: def new_class( name: str, bases: Tuple[type, ...] = ..., - kwds: Optional[Dict[str, Any]] = ..., + kwds: Dict[str, Any] | None = ..., exec_body: Optional[Callable[[Dict[str, Any]], 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 53b616a6b3d4..418286eb7493 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -16,7 +16,7 @@ Any = object() class TypeVar: __name__: str - __bound__: Optional[Type[Any]] + __bound__: Type[Any] | None __constraints__: Tuple[Type[Any], ...] __covariant__: bool __contravariant__: bool @@ -66,7 +66,7 @@ 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__( @@ -217,7 +217,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]): @@ -422,7 +422,7 @@ class ContextManager(Protocol[_T_co]): def __enter__(self) -> _T_co: ... def __exit__( self, - __exc_type: Optional[Type[BaseException]], + __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None, ) -> bool | None: ... @@ -431,7 +431,7 @@ class ContextManager(Protocol[_T_co]): class AsyncContextManager(Protocol[_T_co]): def __aenter__(self) -> Awaitable[_T_co]: ... def __aexit__( - self, exc_type: Optional[Type[BaseException]], exc_value: BaseException | None, traceback: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None ) -> Awaitable[bool | None]: ... class Mapping(_Collection[_KT], Generic[_KT, _VT_co]): @@ -528,7 +528,7 @@ class IO(Iterator[AnyStr], Generic[AnyStr]): def __enter__(self) -> IO[AnyStr]: ... @abstractmethod def __exit__( - self, t: Optional[Type[BaseException]], value: BaseException | None, traceback: TracebackType | None + self, t: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> bool | None: ... class BinaryIO(IO[bytes]): @@ -584,10 +584,10 @@ 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 search(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Match[AnyStr] | None: ... + def match(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Match[AnyStr] | None: ... # New in Python 3.4 - def fullmatch(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Optional[Match[AnyStr]]: ... + 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]]: ... @@ -624,14 +624,14 @@ 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): @@ -692,7 +692,7 @@ if sys.version_info >= (3, 7): __forward_value__: Any | None __forward_is_argument__: bool def __init__(self, arg: str, is_argument: bool = ...) -> None: ... - def _evaluate(self, globalns: Optional[Dict[str, Any]], localns: Optional[Dict[str, Any]]) -> Any | None: ... + 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 573d2706a0c7..15e283fca92d 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -74,8 +74,8 @@ 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]: ... @@ -103,7 +103,7 @@ 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__( diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index 9dc264859ca3..e725aa5e6fd4 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -255,7 +255,7 @@ class _AssertRaisesContext(Generic[_E]): exception: _E def __enter__(self) -> _AssertRaisesContext[_E]: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... @@ -267,7 +267,7 @@ class _AssertWarnsContext: warnings: List[WarningMessage] def __enter__(self) -> _AssertWarnsContext: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... class _AssertLogsContext: @@ -277,5 +277,5 @@ class _AssertLogsContext: def __init__(self, test_case: TestCase, logger_name: str, level: int) -> None: ... def __enter__(self) -> _AssertLogsContext: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... diff --git a/stdlib/unittest/loader.pyi b/stdlib/unittest/loader.pyi index ca7ba16713fa..1102015fa117 100644 --- a/stdlib/unittest/loader.pyi +++ b/stdlib/unittest/loader.pyi @@ -14,7 +14,7 @@ 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: ... @@ -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 519660833560..18dbd553f577 100644 --- a/stdlib/unittest/main.pyi +++ b/stdlib/unittest/main.pyi @@ -21,12 +21,12 @@ class TestProgram: warnings: str | None if sys.version_info >= (3, 7): - testNamePatterns: Optional[List[str]] + testNamePatterns: List[str] | None def __init__( self, module: None | str | ModuleType = ..., defaultTest: str | Iterable[str] | None = ..., - argv: Optional[List[str]] = ..., + argv: List[str] | None = ..., testRunner: Type[_TestRunner] | _TestRunner | None = ..., testLoader: unittest.loader.TestLoader = ..., exit: bool = ..., diff --git a/stdlib/unittest/runner.pyi b/stdlib/unittest/runner.pyi index 0cf589297a35..a84c58849e21 100644 --- a/stdlib/unittest/runner.pyi +++ b/stdlib/unittest/runner.pyi @@ -27,7 +27,7 @@ class TextTestRunner(object): failfast: bool = ..., buffer: bool = ..., resultclass: _ResultClassType | None = ..., - warnings: Optional[Type[Warning]] = ..., + warnings: Type[Warning] | None = ..., *, tb_locals: bool = ..., ) -> None: ... diff --git a/stdlib/urllib/error.pyi b/stdlib/urllib/error.pyi index 65ea3812dfb5..88a8cd781843 100644 --- a/stdlib/urllib/error.pyi +++ b/stdlib/urllib/error.pyi @@ -10,7 +10,7 @@ class URLError(IOError): class HTTPError(URLError, addinfourl): code: int - def __init__(self, url: str, code: int, msg: str, hdrs: Mapping[str, str], fp: Optional[IO[bytes]]) -> None: ... + def __init__(self, url: str, code: int, msg: str, hdrs: Mapping[str, str], fp: IO[bytes] | None) -> None: ... class ContentTooShortError(URLError): content: Tuple[str, Message] diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 2b8b20a100a5..7d35c5fbe95d 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -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 @@ -143,7 +143,7 @@ class HTTPCookieProcessor(BaseHandler): def https_response(self, request: Request, response: HTTPResponse) -> HTTPResponse: ... # undocumented class ProxyHandler(BaseHandler): - def __init__(self, proxies: Optional[Dict[str, str]] = ...) -> None: ... + 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 @@ -228,7 +228,7 @@ class HTTPSHandler(AbstractHTTPHandler): 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 @@ -279,7 +279,7 @@ def urlcleanup() -> None: ... class URLopener: version: ClassVar[str] - def __init__(self, proxies: Optional[Dict[str, str]] = ..., **x509: str) -> None: ... + 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( diff --git a/stdlib/urllib/response.pyi b/stdlib/urllib/response.pyi index 1f19f3eeb27f..7c5314b808fd 100644 --- a/stdlib/urllib/response.pyi +++ b/stdlib/urllib/response.pyi @@ -9,7 +9,7 @@ class addbase(BinaryIO): def __init__(self, fp: IO[bytes]) -> None: ... def __enter__(self: _AIUT) -> _AIUT: ... def __exit__( - self, type: Optional[Type[BaseException]], value: BaseException | None, traceback: TracebackType | None + self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> None: ... def __iter__(self: _AIUT) -> _AIUT: ... def __next__(self) -> bytes: ... diff --git a/stdlib/urllib/robotparser.pyi b/stdlib/urllib/robotparser.pyi index a2f16edeb129..1bafbae74d8b 100644 --- a/stdlib/urllib/robotparser.pyi +++ b/stdlib/urllib/robotparser.pyi @@ -16,4 +16,4 @@ class RobotFileParser: 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/venv/__init__.pyi b/stdlib/venv/__init__.pyi index c1f5e285533e..870bca5a3789 100644 --- a/stdlib/venv/__init__.pyi +++ b/stdlib/venv/__init__.pyi @@ -69,4 +69,4 @@ else: 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 fded0f5a3c3e..e40a17746b45 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -49,9 +49,9 @@ class catch_warnings: def __new__(cls, *, record: Literal[True], module: ModuleType | None = ...) -> _catch_warnings_with_records: ... @overload def __new__(cls, *, record: bool, module: ModuleType | None = ...) -> catch_warnings: ... - def __enter__(self) -> Optional[List[WarningMessage]]: ... + def __enter__(self) -> List[WarningMessage] | None: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... class _catch_warnings_without_records(catch_warnings): diff --git a/stdlib/webbrowser.pyi b/stdlib/webbrowser.pyi index 924a8b6e7d7b..216af49c2e78 100644 --- a/stdlib/webbrowser.pyi +++ b/stdlib/webbrowser.pyi @@ -38,7 +38,7 @@ 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 05b19a8f13aa..c0a750cdbf78 100644 --- a/stdlib/winreg.pyi +++ b/stdlib/winreg.pyi @@ -92,7 +92,7 @@ class HKEYType: def __int__(self) -> int: ... def __enter__(self) -> HKEYType: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> bool | None: ... def Close(self) -> None: ... def Detach(self) -> int: ... diff --git a/stdlib/wsgiref/handlers.pyi b/stdlib/wsgiref/handlers.pyi index 3c1a822092e6..df77a0642ce2 100644 --- a/stdlib/wsgiref/handlers.pyi +++ b/stdlib/wsgiref/handlers.pyi @@ -6,7 +6,7 @@ from .headers import Headers from .types import ErrorStream, InputStream, StartResponse, WSGIApplication, WSGIEnvironment from .util import FileWrapper -_exc_info = Tuple[Optional[Type[BaseException]], BaseException | None, TracebackType | None] +_exc_info = Tuple[Type[BaseException] | None, BaseException | None, TracebackType | None] def format_date_time(timestamp: float | None) -> str: ... # undocumented def read_environ() -> Dict[str, str]: ... @@ -23,7 +23,7 @@ class BaseHandler: os_environ: MutableMapping[str, str] - wsgi_file_wrapper: Optional[Type[FileWrapper]] + wsgi_file_wrapper: Type[FileWrapper] | None headers_class: Type[Headers] # undocumented traceback_limit: int | None diff --git a/stdlib/xml/etree/ElementInclude.pyi b/stdlib/xml/etree/ElementInclude.pyi index 09842ba4146f..02bb217ecead 100644 --- a/stdlib/xml/etree/ElementInclude.pyi +++ b/stdlib/xml/etree/ElementInclude.pyi @@ -16,10 +16,10 @@ def default_loader(href: str | bytes | int, parse: str, encoding: str | None = . if sys.version_info >= (3, 9): def include( elem: Element, - loader: Optional[Callable[..., str | Element]] = ..., + loader: Callable[..., str | Element] | None = ..., base_url: str | None = ..., max_depth: int | None = ..., ) -> None: ... else: - def include(elem: Element, loader: Optional[Callable[..., 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 f73c4afb6a14..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]] = ...) -> Element | None: ... -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: _T | None = ..., namespaces: Optional[Dict[str, 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 eb1c8edff5a0..b641468a20c5 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -42,10 +42,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 = ..., ) -> str: ... @overload def canonicalize( @@ -56,10 +56,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 Element(MutableSequence[Element]): @@ -71,12 +71,12 @@ class Element(MutableSequence[Element]): 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]] = ...) -> Element | None: ... - 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]] = ...) -> str | None: ... + 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]] = ...) -> _T | str: ... + def findtext(self, path: str, default: _T, namespaces: Dict[str, str] | None = ...) -> _T | str: ... @overload def get(self, key: str, default: None = ...) -> str | None: ... @overload @@ -84,7 +84,7 @@ class Element(MutableSequence[Element]): def insert(self, __index: int, __subelement: Element) -> None: ... def items(self) -> ItemsView[str, str]: ... def iter(self, tag: str | None = ...) -> Generator[Element, None, None]: ... - def iterfind(self, path: str, namespaces: Optional[Dict[str, str]] = ...) -> 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: ... @@ -121,13 +121,13 @@ class ElementTree: def iter(self, tag: str | None = ...) -> Generator[Element, None, None]: ... if sys.version_info < (3, 9): def getiterator(self, tag: str | None = ...) -> List[Element]: ... - def find(self, path: str, namespaces: Optional[Dict[str, str]] = ...) -> Element | None: ... + 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]] = ...) -> str | None: ... + 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]] = ...) -> _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, @@ -235,11 +235,11 @@ if sys.version_info >= (3, 9): def parse(source: _File, parser: XMLParser | None = ...) -> ElementTree: ... def iterparse( - source: _File, events: Optional[Sequence[str]] = ..., parser: XMLParser | None = ... + source: _File, events: Sequence[str] | None = ..., parser: XMLParser | None = ... ) -> Iterator[Tuple[str, Any]]: ... class XMLPullParser: - def __init__(self, events: Optional[Sequence[str]] = ..., *, _parser: XMLParser | None = ...) -> 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]]: ... @@ -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: diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index 704929ed7305..c807fdaab768 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -303,7 +303,7 @@ class ServerProxy: def __call__(self, attr: str) -> Union[Callable[[], None], Transport]: ... def __enter__(self) -> ServerProxy: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __close(self) -> None: ... # undocumented def __request(self, methodname: str, params: Tuple[_Marshallable, ...]) -> Tuple[_Marshallable, ...]: ... # undocumented diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index 9e1b2eafa911..a0cd2f1bf38b 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -31,7 +31,7 @@ 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): @@ -101,7 +101,7 @@ class ZipFile: debug: int comment: bytes filelist: List[ZipInfo] - fp: Optional[IO[bytes]] + fp: IO[bytes] | None NameToInfo: Dict[str, ZipInfo] start_dir: int # undocumented if sys.version_info >= (3, 8): @@ -130,7 +130,7 @@ class ZipFile: ) -> None: ... def __enter__(self) -> ZipFile: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: BaseException | None, exc_tb: TracebackType | None + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def close(self) -> None: ... def getinfo(self, name: str) -> ZipInfo: ... @@ -141,7 +141,7 @@ class ZipFile: ) -> IO[bytes]: ... def extract(self, member: str | ZipInfo, path: StrPath | None = ..., pwd: bytes | None = ...) -> str: ... def extractall( - self, path: StrPath | None = ..., members: Optional[Iterable[str]] = ..., pwd: bytes | None = ... + 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: ... diff --git a/stdlib/zoneinfo/__init__.pyi b/stdlib/zoneinfo/__init__.pyi index 8b056b2c9e19..a6b2bb831bb1 100644 --- a/stdlib/zoneinfo/__init__.pyi +++ b/stdlib/zoneinfo/__init__.pyi @@ -23,7 +23,7 @@ class ZoneInfo(tzinfo): # 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] From 4d1ce15f99c41d8b85541b378f8b94f330f7ee6e Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:42:01 -0700 Subject: [PATCH 08/16] for x in $(rg '\bOptional\b' -c | grep stdlib | pyp 'x.split(":")[0] if x.endswith(":1") else None'); do fastmod -g $x --accept-all '\s*from typing import Optional$' ''; done --- stdlib/@python2/_ast.pyi | 1 - stdlib/@python2/_sha256.pyi | 2 +- stdlib/@python2/_sha512.pyi | 2 +- stdlib/@python2/codeop.pyi | 1 - stdlib/@python2/ctypes/util.pyi | 1 - stdlib/@python2/distutils/archive_util.pyi | 2 +- stdlib/@python2/ensurepip/__init__.pyi | 2 +- stdlib/asyncio/exceptions.pyi | 1 - stdlib/asyncio/selector_events.pyi | 1 - stdlib/codeop.pyi | 1 - stdlib/ctypes/util.pyi | 1 - stdlib/distutils/archive_util.pyi | 2 +- stdlib/distutils/debug.pyi | 2 +- stdlib/email/errors.pyi | 1 - stdlib/email/mime/message.pyi | 1 - stdlib/email/mime/text.pyi | 1 - stdlib/ensurepip/__init__.pyi | 2 +- stdlib/unittest/__init__.pyi | 1 - 18 files changed, 7 insertions(+), 18 deletions(-) diff --git a/stdlib/@python2/_ast.pyi b/stdlib/@python2/_ast.pyi index 42922f2d640f..05cbc70c41d2 100644 --- a/stdlib/@python2/_ast.pyi +++ b/stdlib/@python2/_ast.pyi @@ -1,5 +1,4 @@ import typing -from typing import Optional __version__: str PyCF_ONLY_AST: int diff --git a/stdlib/@python2/_sha256.pyi b/stdlib/@python2/_sha256.pyi index 38b80d09b736..5427e384390d 100644 --- a/stdlib/@python2/_sha256.pyi +++ b/stdlib/@python2/_sha256.pyi @@ -1,4 +1,4 @@ -from typing import Optional + class sha224(object): name: str diff --git a/stdlib/@python2/_sha512.pyi b/stdlib/@python2/_sha512.pyi index 51a0d0ec3259..e07adaed60cc 100644 --- a/stdlib/@python2/_sha512.pyi +++ b/stdlib/@python2/_sha512.pyi @@ -1,4 +1,4 @@ -from typing import Optional + class sha384(object): name: str diff --git a/stdlib/@python2/codeop.pyi b/stdlib/@python2/codeop.pyi index 35cb4c5e3e60..8ed5710c9891 100644 --- a/stdlib/@python2/codeop.pyi +++ b/stdlib/@python2/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/@python2/ctypes/util.pyi b/stdlib/@python2/ctypes/util.pyi index 5d0a732de9f8..c0274f5e539b 100644 --- a/stdlib/@python2/ctypes/util.pyi +++ b/stdlib/@python2/ctypes/util.pyi @@ -1,5 +1,4 @@ import sys -from typing import Optional def find_library(name: str) -> str | None: ... diff --git a/stdlib/@python2/distutils/archive_util.pyi b/stdlib/@python2/distutils/archive_util.pyi index 9b386ca1861a..7208326a8607 100644 --- a/stdlib/@python2/distutils/archive_util.pyi +++ b/stdlib/@python2/distutils/archive_util.pyi @@ -1,4 +1,4 @@ -from typing import Optional + def make_archive( base_name: str, diff --git a/stdlib/@python2/ensurepip/__init__.pyi b/stdlib/@python2/ensurepip/__init__.pyi index 876cdcbe59a4..8657f4cd29d5 100644 --- a/stdlib/@python2/ensurepip/__init__.pyi +++ b/stdlib/@python2/ensurepip/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Optional + def version() -> str: ... def bootstrap( 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/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/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/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/distutils/archive_util.pyi b/stdlib/distutils/archive_util.pyi index 0cc06b3332de..317221e7b8b4 100644 --- a/stdlib/distutils/archive_util.pyi +++ b/stdlib/distutils/archive_util.pyi @@ -1,4 +1,4 @@ -from typing import Optional + def make_archive( base_name: str, diff --git a/stdlib/distutils/debug.pyi b/stdlib/distutils/debug.pyi index 9aacb8d4879c..73af13047df6 100644 --- a/stdlib/distutils/debug.pyi +++ b/stdlib/distutils/debug.pyi @@ -1,3 +1,3 @@ -from typing import Optional + DEBUG: bool | None 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/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 716010b9a6fa..41b430f11a81 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__( diff --git a/stdlib/ensurepip/__init__.pyi b/stdlib/ensurepip/__init__.pyi index bed46578fbb3..5153f559d7df 100644 --- a/stdlib/ensurepip/__init__.pyi +++ b/stdlib/ensurepip/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Optional + def version() -> str: ... def bootstrap( 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 ( From 5a6c03229f26d8a6faa9aa2a84f59a9ff4e91a57 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:42:07 -0700 Subject: [PATCH 09/16] for x in $(rg '\bOptional\b' -c | grep stdlib | pyp 'x.split(":")[0] if x.endswith(":1") else None'); do fastmod -g $x --accept-all '^\s+Optional,$' ''; done --- stdlib/@python2/UserDict.pyi | 2 +- stdlib/@python2/codecs.pyi | 2 +- stdlib/@python2/csv.pyi | 2 +- stdlib/@python2/ctypes/__init__.pyi | 2 +- stdlib/@python2/typing_extensions.pyi | 2 +- stdlib/@python2/xml/etree/ElementTree.pyi | 2 +- stdlib/codecs.pyi | 2 +- stdlib/concurrent/futures/_base.pyi | 2 +- stdlib/configparser.pyi | 2 +- stdlib/contextlib.pyi | 2 +- stdlib/ctypes/__init__.pyi | 2 +- stdlib/functools.pyi | 2 +- stdlib/http/client.pyi | 2 +- stdlib/multiprocessing/managers.pyi | 2 +- stdlib/tokenize.pyi | 2 +- stdlib/typing_extensions.pyi | 2 +- stdlib/xml/etree/ElementTree.pyi | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/stdlib/@python2/UserDict.pyi b/stdlib/@python2/UserDict.pyi index f8d1aab9a8f5..435f23728f92 100644 --- a/stdlib/@python2/UserDict.pyi +++ b/stdlib/@python2/UserDict.pyi @@ -7,7 +7,7 @@ from typing import ( Iterator, List, Mapping, - Optional, + Sized, Tuple, TypeVar, diff --git a/stdlib/@python2/codecs.pyi b/stdlib/@python2/codecs.pyi index eadb76723f4e..71c3c4c1af28 100644 --- a/stdlib/@python2/codecs.pyi +++ b/stdlib/@python2/codecs.pyi @@ -9,7 +9,7 @@ from typing import ( Iterable, Iterator, List, - Optional, + Protocol, Text, TextIO, diff --git a/stdlib/@python2/csv.pyi b/stdlib/@python2/csv.pyi index f21b5cfdd547..d1c9092d51f7 100644 --- a/stdlib/@python2/csv.pyi +++ b/stdlib/@python2/csv.pyi @@ -24,7 +24,7 @@ from typing import ( Iterator, List, Mapping, - Optional, + Sequence, Text, Type, diff --git a/stdlib/@python2/ctypes/__init__.pyi b/stdlib/@python2/ctypes/__init__.pyi index d446f9ee481a..749d108d75c0 100644 --- a/stdlib/@python2/ctypes/__init__.pyi +++ b/stdlib/@python2/ctypes/__init__.pyi @@ -9,7 +9,7 @@ from typing import ( Iterator, List, Mapping, - Optional, + Sequence, Text, Tuple, diff --git a/stdlib/@python2/typing_extensions.pyi b/stdlib/@python2/typing_extensions.pyi index 21d659cd7814..b0593368a192 100644 --- a/stdlib/@python2/typing_extensions.pyi +++ b/stdlib/@python2/typing_extensions.pyi @@ -14,7 +14,7 @@ from typing import ( Mapping, NewType as NewType, NoReturn as NoReturn, - Optional, + Text as Text, Tuple, Type as Type, diff --git a/stdlib/@python2/xml/etree/ElementTree.pyi b/stdlib/@python2/xml/etree/ElementTree.pyi index 32fc4042b684..be97f52059c5 100644 --- a/stdlib/@python2/xml/etree/ElementTree.pyi +++ b/stdlib/@python2/xml/etree/ElementTree.pyi @@ -11,7 +11,7 @@ from typing import ( KeysView, List, MutableSequence, - Optional, + Sequence, Text, Tuple, diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index b274cec7d120..fd2a7ede1603 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -10,7 +10,7 @@ from typing import ( Iterable, Iterator, List, - Optional, + Protocol, TextIO, Tuple, diff --git a/stdlib/concurrent/futures/_base.pyi b/stdlib/concurrent/futures/_base.pyi index 2c1dc0dc7e74..4705cb198cbd 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -10,7 +10,7 @@ from typing import ( Iterable, Iterator, List, - Optional, + Protocol, Sequence, Set, diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index c8ae90f6573f..a94a1ab09272 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -11,7 +11,7 @@ from typing import ( List, Mapping, MutableMapping, - Optional, + Pattern, Sequence, Tuple, diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index ec79d6d18992..11ed0591ebcb 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -9,7 +9,7 @@ from typing import ( Callable, ContextManager, Iterator, - Optional, + Type, TypeVar, overload, diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index 9f4cfa78fde3..0b3438ab14c6 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -9,7 +9,7 @@ from typing import ( Iterator, List, Mapping, - Optional, + Sequence, Tuple, Type, diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index e4bae49a0dec..141c31965c52 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -9,7 +9,7 @@ from typing import ( Iterable, Mapping, NamedTuple, - Optional, + Sequence, Set, Sized, diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index c64e93d05b14..920474a1f9dc 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/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index 43cd91d7dccb..b66ef2c17ccd 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -13,7 +13,7 @@ from typing import ( Iterable, List, Mapping, - Optional, + Sequence, Tuple, TypeVar, diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index ac9b4c4809c5..ee6c23870844 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/typing_extensions.pyi b/stdlib/typing_extensions.pyi index 15e283fca92d..f43f6b362656 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -22,7 +22,7 @@ from typing import ( Mapping, NewType as NewType, NoReturn as NoReturn, - Optional, + Text as Text, Tuple, Type as Type, diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index b641468a20c5..1aeb229f4dd4 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, From e4c086bb00f8188c5ee7a322ef74519e62a37c6a Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:42:14 -0700 Subject: [PATCH 10/16] for x in $(rg '\bOptional\b' -c | grep stdlib | pyp 'x.split(":")[0] if x.endswith(":1") else None'); do fastmod -g $x --accept-all '(from typing import )Optional, (.*)' '$1$2'; done --- stdlib/@python2/asynchat.pyi | 2 +- stdlib/@python2/audioop.pyi | 2 +- stdlib/@python2/distutils/command/install.pyi | 2 +- stdlib/@python2/distutils/file_util.pyi | 2 +- stdlib/@python2/distutils/version.pyi | 2 +- stdlib/@python2/fractions.pyi | 2 +- stdlib/@python2/importlib.pyi | 2 +- stdlib/@python2/sndhdr.pyi | 2 +- stdlib/@python2/whichdb.pyi | 2 +- stdlib/@python2/winsound.pyi | 2 +- stdlib/@python2/zipimport.pyi | 2 +- stdlib/_tracemalloc.pyi | 2 +- stdlib/_typeshed/tkinter.pyi | 2 +- stdlib/asynchat.pyi | 2 +- stdlib/asyncio/protocols.pyi | 2 +- stdlib/audioop.pyi | 2 +- stdlib/distutils/command/install.pyi | 2 +- stdlib/distutils/file_util.pyi | 2 +- stdlib/distutils/version.pyi | 2 +- stdlib/email/mime/base.pyi | 2 +- stdlib/email/mime/multipart.pyi | 2 +- stdlib/encodings/utf_8.pyi | 2 +- stdlib/fractions.pyi | 2 +- stdlib/getpass.pyi | 2 +- stdlib/secrets.pyi | 2 +- stdlib/venv/__init__.pyi | 2 +- stdlib/winsound.pyi | 2 +- 27 files changed, 27 insertions(+), 27 deletions(-) diff --git a/stdlib/@python2/asynchat.pyi b/stdlib/@python2/asynchat.pyi index 4e03ad9efac3..c45eb4917c4d 100644 --- a/stdlib/@python2/asynchat.pyi +++ b/stdlib/@python2/asynchat.pyi @@ -1,7 +1,7 @@ import asyncore import socket from abc import abstractmethod -from typing import Optional, Sequence, Tuple, Union +from typing import Sequence, Tuple, Union class simple_producer: def __init__(self, data: bytes, buffer_size: int = ...) -> None: ... diff --git a/stdlib/@python2/audioop.pyi b/stdlib/@python2/audioop.pyi index 53ba6a46ec44..71671afe487e 100644 --- a/stdlib/@python2/audioop.pyi +++ b/stdlib/@python2/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/@python2/distutils/command/install.pyi b/stdlib/@python2/distutils/command/install.pyi index ba1a4d68d15e..2824236735f0 100644 --- a/stdlib/@python2/distutils/command/install.pyi +++ b/stdlib/@python2/distutils/command/install.pyi @@ -1,5 +1,5 @@ from distutils.cmd import Command -from typing import Optional, Text +from typing import Text class install(Command): user: bool diff --git a/stdlib/@python2/distutils/file_util.pyi b/stdlib/@python2/distutils/file_util.pyi index 8c2b302efa6a..cfe840e71040 100644 --- a/stdlib/@python2/distutils/file_util.pyi +++ b/stdlib/@python2/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/@python2/distutils/version.pyi b/stdlib/@python2/distutils/version.pyi index 31c94e77bff0..467066b7312a 100644 --- a/stdlib/@python2/distutils/version.pyi +++ b/stdlib/@python2/distutils/version.pyi @@ -1,5 +1,5 @@ from abc import abstractmethod -from typing import Optional, Pattern, Text, Tuple, TypeVar, Union +from typing import Pattern, Text, Tuple, TypeVar, Union _T = TypeVar("_T", bound=Version) diff --git a/stdlib/@python2/fractions.pyi b/stdlib/@python2/fractions.pyi index bb759fb66ae2..dac9639946f2 100644 --- a/stdlib/@python2/fractions.pyi +++ b/stdlib/@python2/fractions.pyi @@ -1,6 +1,6 @@ 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 = int | float | Decimal | Real diff --git a/stdlib/@python2/importlib.pyi b/stdlib/@python2/importlib.pyi index e64ca53adda2..530cb1a3c79c 100644 --- a/stdlib/@python2/importlib.pyi +++ b/stdlib/@python2/importlib.pyi @@ -1,4 +1,4 @@ import types -from typing import Optional, Text +from typing import Text def import_module(name: Text, package: Text | None = ...) -> types.ModuleType: ... diff --git a/stdlib/@python2/sndhdr.pyi b/stdlib/@python2/sndhdr.pyi index 31d97d83716d..5c434028bc1c 100644 --- a/stdlib/@python2/sndhdr.pyi +++ b/stdlib/@python2/sndhdr.pyi @@ -1,4 +1,4 @@ -from typing import Optional, Text, Tuple, Union +from typing import Text, Tuple, Union _SndHeaders = Tuple[str, int, int, int, int | str] diff --git a/stdlib/@python2/whichdb.pyi b/stdlib/@python2/whichdb.pyi index 19720c6a5b3a..1c678e9392e8 100644 --- a/stdlib/@python2/whichdb.pyi +++ b/stdlib/@python2/whichdb.pyi @@ -1,3 +1,3 @@ -from typing import Optional, Text +from typing import Text def whichdb(filename: Text) -> str | None: ... diff --git a/stdlib/@python2/winsound.pyi b/stdlib/@python2/winsound.pyi index 91ec0b717157..78a0b643d6db 100644 --- a/stdlib/@python2/winsound.pyi +++ b/stdlib/@python2/winsound.pyi @@ -1,5 +1,5 @@ import sys -from typing import Optional, Union, overload +from typing import Union, overload from typing_extensions import Literal if sys.platform == "win32": diff --git a/stdlib/@python2/zipimport.pyi b/stdlib/@python2/zipimport.pyi index 10c3b07d97a3..04f06b07ea6b 100644 --- a/stdlib/@python2/zipimport.pyi +++ b/stdlib/@python2/zipimport.pyi @@ -1,5 +1,5 @@ from types import CodeType, ModuleType -from typing import Optional, Union +from typing import Union class ZipImportError(ImportError): ... diff --git a/stdlib/_tracemalloc.pyi b/stdlib/_tracemalloc.pyi index 0b7550c7ef51..27637637f6c5 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/tkinter.pyi b/stdlib/_typeshed/tkinter.pyi index f81599db7dd2..50006409e95c 100644 --- a/stdlib/_typeshed/tkinter.pyi +++ b/stdlib/_typeshed/tkinter.pyi @@ -1,7 +1,7 @@ # See the README.md file in this directory for more information. from tkinter import Event, Misc, Widget -from typing import Optional, Protocol +from typing import Protocol class DndSource(Protocol): def dnd_end(self, target: Widget | None, event: Event[Misc] | None) -> None: ... diff --git a/stdlib/asynchat.pyi b/stdlib/asynchat.pyi index 4fabf46f4ed6..3d383a85d04d 100644 --- a/stdlib/asynchat.pyi +++ b/stdlib/asynchat.pyi @@ -1,7 +1,7 @@ import asyncore import socket from abc import abstractmethod -from typing import Optional, Union +from typing import Union class simple_producer: def __init__(self, data: bytes, buffer_size: int = ...) -> None: ... diff --git a/stdlib/asyncio/protocols.pyi b/stdlib/asyncio/protocols.pyi index a6b356550edb..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 Optional, 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 53ba6a46ec44..71671afe487e 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/distutils/command/install.pyi b/stdlib/distutils/command/install.pyi index d2715abeeedb..56d2c9bcbacc 100644 --- a/stdlib/distutils/command/install.pyi +++ b/stdlib/distutils/command/install.pyi @@ -1,5 +1,5 @@ from distutils.cmd import Command -from typing import Optional, Tuple +from typing import Tuple SCHEME_KEYS: Tuple[str, ...] diff --git a/stdlib/distutils/file_util.pyi b/stdlib/distutils/file_util.pyi index 8c2b302efa6a..cfe840e71040 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/version.pyi b/stdlib/distutils/version.pyi index 1b48b84b292b..d1e8bf5019e8 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, Union _T = TypeVar("_T", bound=Version) diff --git a/stdlib/email/mime/base.pyi b/stdlib/email/mime/base.pyi index 3a323ee79a7e..a737af8e9012 100644 --- a/stdlib/email/mime/base.pyi +++ b/stdlib/email/mime/base.pyi @@ -1,6 +1,6 @@ import email.message from email.policy import Policy -from typing import Optional, Tuple, Union +from typing import Tuple, Union _ParamsType = Union[str, None, Tuple[str, str | None, str]] diff --git a/stdlib/email/mime/multipart.pyi b/stdlib/email/mime/multipart.pyi index 51f1d07f2235..1b9a2d4ac16f 100644 --- a/stdlib/email/mime/multipart.pyi +++ b/stdlib/email/mime/multipart.pyi @@ -1,7 +1,7 @@ from email.message import Message from email.mime.base import MIMEBase from email.policy import Policy -from typing import Optional, Sequence, Tuple, Union +from typing import Sequence, Tuple, Union _ParamsType = Union[str, None, Tuple[str, str | None, str]] diff --git a/stdlib/encodings/utf_8.pyi b/stdlib/encodings/utf_8.pyi index 416e90caa239..892f2f082af0 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/fractions.pyi b/stdlib/fractions.pyi index cdb323f980e8..37a14bf6ee1b 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 = int | float | Decimal | Real diff --git a/stdlib/getpass.pyi b/stdlib/getpass.pyi index fe4be95d285a..27f4c6a9b635 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/secrets.pyi b/stdlib/secrets.pyi index bcf9bf1526d1..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 Optional, Sequence, TypeVar +from typing import Sequence, TypeVar _T = TypeVar("_T") diff --git a/stdlib/venv/__init__.pyi b/stdlib/venv/__init__.pyi index 870bca5a3789..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 Optional, Sequence +from typing import Sequence class EnvBuilder: system_site_packages: bool diff --git a/stdlib/winsound.pyi b/stdlib/winsound.pyi index 91ec0b717157..78a0b643d6db 100644 --- a/stdlib/winsound.pyi +++ b/stdlib/winsound.pyi @@ -1,5 +1,5 @@ import sys -from typing import Optional, Union, overload +from typing import Union, overload from typing_extensions import Literal if sys.platform == "win32": From 3a8801f4151b080187f003d1997dec8501f8342b Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:42:21 -0700 Subject: [PATCH 11/16] for x in $(rg '\bOptional\b' -c | grep stdlib | pyp 'x.split(":")[0] if x.endswith(":1") else None'); do fastmod -g $x --accept-all '(from typing import.*), Optional' '$1'; done --- stdlib/@python2/BaseHTTPServer.pyi | 2 +- stdlib/@python2/ConfigParser.pyi | 2 +- stdlib/@python2/Cookie.pyi | 2 +- stdlib/@python2/Queue.pyi | 2 +- stdlib/@python2/SimpleHTTPServer.pyi | 2 +- stdlib/@python2/SocketServer.pyi | 2 +- stdlib/@python2/StringIO.pyi | 2 +- stdlib/@python2/UserString.pyi | 2 +- stdlib/@python2/_bisect.pyi | 2 +- stdlib/@python2/_codecs.pyi | 2 +- stdlib/@python2/_collections.pyi | 2 +- stdlib/@python2/_csv.pyi | 2 +- stdlib/@python2/_curses.pyi | 2 +- stdlib/@python2/_dummy_threading.pyi | 2 +- stdlib/@python2/_io.pyi | 2 +- stdlib/@python2/_msi.pyi | 2 +- stdlib/@python2/_osx_support.pyi | 2 +- stdlib/@python2/_socket.pyi | 2 +- stdlib/@python2/_sre.pyi | 2 +- stdlib/@python2/_thread.pyi | 2 +- stdlib/@python2/_typeshed/xml.pyi | 2 +- stdlib/@python2/_weakrefset.pyi | 2 +- stdlib/@python2/_winreg.pyi | 2 +- stdlib/@python2/aifc.pyi | 2 +- stdlib/@python2/ast.pyi | 2 +- stdlib/@python2/asyncore.pyi | 2 +- stdlib/@python2/base64.pyi | 2 +- stdlib/@python2/bdb.pyi | 2 +- stdlib/@python2/bz2.pyi | 2 +- stdlib/@python2/cProfile.pyi | 2 +- stdlib/@python2/cStringIO.pyi | 2 +- stdlib/@python2/calendar.pyi | 2 +- stdlib/@python2/cgi.pyi | 2 +- stdlib/@python2/cgitb.pyi | 2 +- stdlib/@python2/compileall.pyi | 2 +- stdlib/@python2/contextlib.pyi | 2 +- stdlib/@python2/cookielib.pyi | 2 +- stdlib/@python2/copy.pyi | 2 +- stdlib/@python2/datetime.pyi | 2 +- stdlib/@python2/dbm/__init__.pyi | 2 +- stdlib/@python2/dbm/dumb.pyi | 2 +- stdlib/@python2/dbm/gnu.pyi | 2 +- stdlib/@python2/dbm/ndbm.pyi | 2 +- stdlib/@python2/decimal.pyi | 2 +- stdlib/@python2/distutils/ccompiler.pyi | 2 +- stdlib/@python2/distutils/command/config.pyi | 2 +- stdlib/@python2/distutils/command/install_egg_info.pyi | 2 +- stdlib/@python2/distutils/command/upload.pyi | 2 +- stdlib/@python2/distutils/config.pyi | 2 +- stdlib/@python2/distutils/core.pyi | 2 +- stdlib/@python2/distutils/dist.pyi | 2 +- stdlib/@python2/distutils/extension.pyi | 2 +- stdlib/@python2/distutils/fancy_getopt.pyi | 2 +- stdlib/@python2/distutils/spawn.pyi | 2 +- stdlib/@python2/distutils/sysconfig.pyi | 2 +- stdlib/@python2/distutils/text_file.pyi | 2 +- stdlib/@python2/distutils/util.pyi | 2 +- stdlib/@python2/dummy_thread.pyi | 2 +- stdlib/@python2/email/_parseaddr.pyi | 2 +- stdlib/@python2/email/mime/application.pyi | 2 +- stdlib/@python2/email/utils.pyi | 2 +- stdlib/@python2/filecmp.pyi | 2 +- stdlib/@python2/formatter.pyi | 2 +- stdlib/@python2/gettext.pyi | 2 +- stdlib/@python2/grp.pyi | 2 +- stdlib/@python2/hmac.pyi | 2 +- stdlib/@python2/httplib.pyi | 2 +- stdlib/@python2/imaplib.pyi | 2 +- stdlib/@python2/imghdr.pyi | 2 +- stdlib/@python2/lib2to3/pgen2/driver.pyi | 2 +- stdlib/@python2/lib2to3/pgen2/grammar.pyi | 2 +- stdlib/@python2/lib2to3/pgen2/parse.pyi | 2 +- stdlib/@python2/lib2to3/pgen2/pgen.pyi | 2 +- stdlib/@python2/lib2to3/pytree.pyi | 2 +- stdlib/@python2/linecache.pyi | 2 +- stdlib/@python2/locale.pyi | 2 +- stdlib/@python2/logging/__init__.pyi | 2 +- stdlib/@python2/logging/config.pyi | 2 +- stdlib/@python2/logging/handlers.pyi | 2 +- stdlib/@python2/macpath.pyi | 2 +- stdlib/@python2/mailcap.pyi | 2 +- stdlib/@python2/mimetypes.pyi | 2 +- stdlib/@python2/mmap.pyi | 2 +- stdlib/@python2/modulefinder.pyi | 2 +- stdlib/@python2/msilib/__init__.pyi | 2 +- stdlib/@python2/msilib/schema.pyi | 2 +- stdlib/@python2/msilib/sequence.pyi | 2 +- stdlib/@python2/msilib/text.pyi | 2 +- stdlib/@python2/multiprocessing/__init__.pyi | 2 +- stdlib/@python2/multiprocessing/dummy/__init__.pyi | 2 +- stdlib/@python2/multiprocessing/dummy/connection.pyi | 2 +- stdlib/@python2/multiprocessing/pool.pyi | 2 +- stdlib/@python2/multiprocessing/process.pyi | 2 +- stdlib/@python2/multiprocessing/util.pyi | 2 +- stdlib/@python2/netrc.pyi | 2 +- stdlib/@python2/nntplib.pyi | 2 +- stdlib/@python2/ntpath.pyi | 2 +- stdlib/@python2/numbers.pyi | 2 +- stdlib/@python2/os/path.pyi | 2 +- stdlib/@python2/os2emxpath.pyi | 2 +- stdlib/@python2/pdb.pyi | 2 +- stdlib/@python2/pickle.pyi | 2 +- stdlib/@python2/pickletools.pyi | 2 +- stdlib/@python2/platform.pyi | 2 +- stdlib/@python2/popen2.pyi | 2 +- stdlib/@python2/poplib.pyi | 2 +- stdlib/@python2/posix.pyi | 2 +- stdlib/@python2/posixpath.pyi | 2 +- stdlib/@python2/pprint.pyi | 2 +- stdlib/@python2/pstats.pyi | 2 +- stdlib/@python2/py_compile.pyi | 2 +- stdlib/@python2/pyclbr.pyi | 2 +- stdlib/@python2/re.pyi | 2 +- stdlib/@python2/rfc822.pyi | 2 +- stdlib/@python2/rlcompleter.pyi | 2 +- stdlib/@python2/runpy.pyi | 2 +- stdlib/@python2/select.pyi | 2 +- stdlib/@python2/sets.pyi | 2 +- stdlib/@python2/shelve.pyi | 2 +- stdlib/@python2/shlex.pyi | 2 +- stdlib/@python2/site.pyi | 2 +- stdlib/@python2/smtpd.pyi | 2 +- stdlib/@python2/socket.pyi | 2 +- stdlib/@python2/sqlite3/dbapi2.pyi | 2 +- stdlib/@python2/sre_parse.pyi | 2 +- stdlib/@python2/ssl.pyi | 2 +- stdlib/@python2/stringold.pyi | 2 +- stdlib/@python2/sunau.pyi | 2 +- stdlib/@python2/symtable.pyi | 2 +- stdlib/@python2/sys.pyi | 2 +- stdlib/@python2/sysconfig.pyi | 2 +- stdlib/@python2/tempfile.pyi | 2 +- stdlib/@python2/threading.pyi | 2 +- stdlib/@python2/time.pyi | 2 +- stdlib/@python2/traceback.pyi | 2 +- stdlib/@python2/turtle.pyi | 2 +- stdlib/@python2/types.pyi | 2 +- stdlib/@python2/urllib2.pyi | 2 +- stdlib/@python2/urlparse.pyi | 2 +- stdlib/@python2/uu.pyi | 2 +- stdlib/@python2/uuid.pyi | 2 +- stdlib/@python2/warnings.pyi | 2 +- stdlib/@python2/wave.pyi | 2 +- stdlib/@python2/wsgiref/handlers.pyi | 2 +- stdlib/@python2/wsgiref/headers.pyi | 2 +- stdlib/@python2/wsgiref/simple_server.pyi | 2 +- stdlib/@python2/wsgiref/util.pyi | 2 +- stdlib/@python2/wsgiref/validate.pyi | 2 +- stdlib/@python2/xml/dom/domreg.pyi | 2 +- stdlib/@python2/xml/dom/minicompat.pyi | 2 +- stdlib/@python2/xml/dom/minidom.pyi | 2 +- stdlib/@python2/xml/etree/ElementInclude.pyi | 2 +- stdlib/@python2/xml/etree/ElementPath.pyi | 2 +- stdlib/@python2/xml/sax/__init__.pyi | 2 +- stdlib/@python2/xml/sax/xmlreader.pyi | 2 +- stdlib/_ast.pyi | 2 +- stdlib/_codecs.pyi | 2 +- stdlib/_csv.pyi | 2 +- stdlib/_curses.pyi | 2 +- stdlib/_dummy_thread.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/_typeshed/xml.pyi | 2 +- stdlib/_weakrefset.pyi | 2 +- stdlib/_winapi.pyi | 2 +- stdlib/aifc.pyi | 2 +- stdlib/ast.pyi | 2 +- stdlib/asyncio/base_subprocess.pyi | 2 +- stdlib/asyncio/base_tasks.pyi | 2 +- stdlib/asyncio/format_helpers.pyi | 2 +- stdlib/asyncio/futures.pyi | 2 +- stdlib/asyncio/locks.pyi | 2 +- stdlib/asyncio/proactor_events.pyi | 2 +- stdlib/asyncio/queues.pyi | 2 +- stdlib/asyncio/runners.pyi | 2 +- stdlib/asyncio/staggered.pyi | 2 +- stdlib/asyncio/streams.pyi | 2 +- stdlib/asyncio/tasks.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/base64.pyi | 2 +- stdlib/bdb.pyi | 2 +- stdlib/bz2.pyi | 2 +- stdlib/cProfile.pyi | 2 +- stdlib/calendar.pyi | 2 +- stdlib/cgi.pyi | 2 +- stdlib/cgitb.pyi | 2 +- stdlib/compileall.pyi | 2 +- stdlib/concurrent/futures/process.pyi | 2 +- stdlib/concurrent/futures/thread.pyi | 2 +- stdlib/contextvars.pyi | 2 +- stdlib/copy.pyi | 2 +- stdlib/crypt.pyi | 2 +- stdlib/csv.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/dis.pyi | 2 +- stdlib/distutils/ccompiler.pyi | 2 +- stdlib/distutils/command/config.pyi | 2 +- stdlib/distutils/command/install_egg_info.pyi | 2 +- stdlib/distutils/config.pyi | 2 +- stdlib/distutils/core.pyi | 2 +- stdlib/distutils/dist.pyi | 2 +- stdlib/distutils/fancy_getopt.pyi | 2 +- stdlib/distutils/filelist.pyi | 2 +- stdlib/distutils/spawn.pyi | 2 +- stdlib/distutils/sysconfig.pyi | 2 +- stdlib/distutils/util.pyi | 2 +- stdlib/email/_header_value_parser.pyi | 2 +- stdlib/email/charset.pyi | 2 +- stdlib/email/generator.pyi | 2 +- stdlib/email/header.pyi | 2 +- stdlib/email/headerregistry.pyi | 2 +- stdlib/email/iterators.pyi | 2 +- stdlib/email/message.pyi | 2 +- stdlib/email/mime/application.pyi | 2 +- stdlib/email/mime/audio.pyi | 2 +- stdlib/email/mime/image.pyi | 2 +- stdlib/email/policy.pyi | 2 +- stdlib/email/utils.pyi | 2 +- stdlib/encodings/__init__.pyi | 2 +- stdlib/filecmp.pyi | 2 +- stdlib/formatter.pyi | 2 +- stdlib/gc.pyi | 2 +- stdlib/gettext.pyi | 2 +- stdlib/glob.pyi | 2 +- stdlib/grp.pyi | 2 +- stdlib/gzip.pyi | 2 +- stdlib/hashlib.pyi | 2 +- stdlib/hmac.pyi | 2 +- stdlib/html/parser.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/ipaddress.pyi | 2 +- stdlib/json/encoder.pyi | 2 +- stdlib/lib2to3/pgen2/driver.pyi | 2 +- stdlib/lib2to3/pgen2/grammar.pyi | 2 +- stdlib/lib2to3/pgen2/parse.pyi | 2 +- stdlib/lib2to3/pgen2/pgen.pyi | 2 +- stdlib/lib2to3/pytree.pyi | 2 +- stdlib/linecache.pyi | 2 +- stdlib/locale.pyi | 2 +- stdlib/logging/__init__.pyi | 2 +- stdlib/lzma.pyi | 2 +- stdlib/macpath.pyi | 2 +- stdlib/mailcap.pyi | 2 +- stdlib/math.pyi | 2 +- stdlib/mimetypes.pyi | 2 +- stdlib/mmap.pyi | 2 +- stdlib/msilib/__init__.pyi | 2 +- stdlib/msilib/schema.pyi | 2 +- stdlib/msilib/sequence.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/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/netrc.pyi | 2 +- stdlib/nntplib.pyi | 2 +- stdlib/numbers.pyi | 2 +- stdlib/opcode.pyi | 2 +- stdlib/pathlib.pyi | 2 +- stdlib/pdb.pyi | 2 +- stdlib/pickletools.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/pstats.pyi | 2 +- stdlib/py_compile.pyi | 2 +- stdlib/pyclbr.pyi | 2 +- stdlib/queue.pyi | 2 +- stdlib/re.pyi | 2 +- stdlib/rlcompleter.pyi | 2 +- stdlib/runpy.pyi | 2 +- stdlib/sched.pyi | 2 +- stdlib/select.pyi | 2 +- stdlib/selectors.pyi | 2 +- stdlib/shelve.pyi | 2 +- stdlib/shlex.pyi | 2 +- stdlib/signal.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/sre_constants.pyi | 2 +- stdlib/sre_parse.pyi | 2 +- stdlib/statistics.pyi | 2 +- stdlib/string.pyi | 2 +- stdlib/sunau.pyi | 2 +- stdlib/symtable.pyi | 2 +- stdlib/sysconfig.pyi | 2 +- stdlib/tempfile.pyi | 2 +- stdlib/time.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/traceback.pyi | 2 +- stdlib/tracemalloc.pyi | 2 +- stdlib/turtle.pyi | 2 +- 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/response.pyi | 2 +- stdlib/urllib/robotparser.pyi | 2 +- stdlib/uu.pyi | 2 +- stdlib/uuid.pyi | 2 +- stdlib/warnings.pyi | 2 +- stdlib/wave.pyi | 2 +- stdlib/winreg.pyi | 2 +- stdlib/wsgiref/handlers.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/etree/ElementInclude.pyi | 2 +- stdlib/xml/etree/ElementPath.pyi | 2 +- stdlib/xml/sax/__init__.pyi | 2 +- stdlib/xml/sax/xmlreader.pyi | 2 +- stdlib/xmlrpc/client.pyi | 2 +- stdlib/zipimport.pyi | 2 +- stdlib/zlib.pyi | 2 +- stdlib/zoneinfo/__init__.pyi | 2 +- 370 files changed, 370 insertions(+), 370 deletions(-) diff --git a/stdlib/@python2/BaseHTTPServer.pyi b/stdlib/@python2/BaseHTTPServer.pyi index a9ef767a9c3a..d2683e863922 100644 --- a/stdlib/@python2/BaseHTTPServer.pyi +++ b/stdlib/@python2/BaseHTTPServer.pyi @@ -1,6 +1,6 @@ import mimetools import SocketServer -from typing import Any, BinaryIO, Callable, Mapping, Optional, Tuple, Union +from typing import Any, BinaryIO, Callable, Mapping, Tuple, Union class HTTPServer(SocketServer.TCPServer): server_name: str diff --git a/stdlib/@python2/ConfigParser.pyi b/stdlib/@python2/ConfigParser.pyi index 2f63632c9371..804cc9a05e68 100644 --- a/stdlib/@python2/ConfigParser.pyi +++ b/stdlib/@python2/ConfigParser.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsNoArgReadline -from typing import IO, Any, Dict, List, Optional, Sequence, Tuple, Union +from typing import IO, Any, Dict, List, Sequence, Tuple, Union DEFAULTSECT: str MAX_INTERPOLATION_DEPTH: int diff --git a/stdlib/@python2/Cookie.pyi b/stdlib/@python2/Cookie.pyi index c2249577ba3a..3d01c3c66152 100644 --- a/stdlib/@python2/Cookie.pyi +++ b/stdlib/@python2/Cookie.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional +from typing import Any, Dict class CookieError(Exception): ... diff --git a/stdlib/@python2/Queue.pyi b/stdlib/@python2/Queue.pyi index 311c304c1a4d..24743a80280d 100644 --- a/stdlib/@python2/Queue.pyi +++ b/stdlib/@python2/Queue.pyi @@ -1,4 +1,4 @@ -from typing import Any, Deque, Generic, Optional, TypeVar +from typing import Any, Deque, Generic, TypeVar _T = TypeVar("_T") diff --git a/stdlib/@python2/SimpleHTTPServer.pyi b/stdlib/@python2/SimpleHTTPServer.pyi index 472ed8fdf4d1..8d9a3e4e4444 100644 --- a/stdlib/@python2/SimpleHTTPServer.pyi +++ b/stdlib/@python2/SimpleHTTPServer.pyi @@ -1,6 +1,6 @@ import BaseHTTPServer from StringIO import StringIO -from typing import IO, Any, AnyStr, Mapping, Optional, Union +from typing import IO, Any, AnyStr, Mapping, Union class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): server_version: str diff --git a/stdlib/@python2/SocketServer.pyi b/stdlib/@python2/SocketServer.pyi index 991efaf240b9..63dae77f21b4 100644 --- a/stdlib/@python2/SocketServer.pyi +++ b/stdlib/@python2/SocketServer.pyi @@ -1,6 +1,6 @@ import sys from socket import SocketType -from typing import Any, BinaryIO, Callable, ClassVar, List, Optional, Text, Tuple, Union +from typing import Any, BinaryIO, Callable, ClassVar, List, Text, Tuple, Union class BaseServer: address_family: int diff --git a/stdlib/@python2/StringIO.pyi b/stdlib/@python2/StringIO.pyi index 9e5a0c1316d3..efa90f8e0330 100644 --- a/stdlib/@python2/StringIO.pyi +++ b/stdlib/@python2/StringIO.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, List, Optional +from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, List class StringIO(IO[AnyStr], Generic[AnyStr]): closed: bool diff --git a/stdlib/@python2/UserString.pyi b/stdlib/@python2/UserString.pyi index 0abe36516140..4ce76550b96d 100644 --- a/stdlib/@python2/UserString.pyi +++ b/stdlib/@python2/UserString.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, List, MutableSequence, Optional, Sequence, Text, Tuple, TypeVar, Union, overload +from typing import Any, Iterable, List, MutableSequence, Sequence, Text, Tuple, TypeVar, Union, overload _UST = TypeVar("_UST", bound=UserString) _MST = TypeVar("_MST", bound=MutableString) diff --git a/stdlib/@python2/_bisect.pyi b/stdlib/@python2/_bisect.pyi index 1467bb336315..e3327a0af4e6 100644 --- a/stdlib/@python2/_bisect.pyi +++ b/stdlib/@python2/_bisect.pyi @@ -1,4 +1,4 @@ -from typing import MutableSequence, Optional, Sequence, TypeVar +from typing import MutableSequence, Sequence, TypeVar _T = TypeVar("_T") diff --git a/stdlib/@python2/_codecs.pyi b/stdlib/@python2/_codecs.pyi index ab8f9938765d..10ac3a3cfb96 100644 --- a/stdlib/@python2/_codecs.pyi +++ b/stdlib/@python2/_codecs.pyi @@ -1,6 +1,6 @@ import codecs import sys -from typing import Any, Callable, Dict, Optional, Text, Tuple, Union +from typing import Any, Callable, Dict, Text, Tuple, Union # For convenience: _Handler = Callable[[Exception], Tuple[Text, int]] diff --git a/stdlib/@python2/_collections.pyi b/stdlib/@python2/_collections.pyi index 1241f79c6e04..a56a209dcc45 100644 --- a/stdlib/@python2/_collections.pyi +++ b/stdlib/@python2/_collections.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Generic, Iterator, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Generic, Iterator, TypeVar, Union _K = TypeVar("_K") _V = TypeVar("_V") diff --git a/stdlib/@python2/_csv.pyi b/stdlib/@python2/_csv.pyi index 277bc1465eae..8fdb31def5a3 100644 --- a/stdlib/@python2/_csv.pyi +++ b/stdlib/@python2/_csv.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Iterator, List, Optional, Protocol, Sequence, Text, Type, Union +from typing import Any, Iterable, Iterator, List, Protocol, Sequence, Text, Type, Union QUOTE_ALL: int QUOTE_MINIMAL: int diff --git a/stdlib/@python2/_curses.pyi b/stdlib/@python2/_curses.pyi index 4f78c78ba908..ccd01181e047 100644 --- a/stdlib/@python2/_curses.pyi +++ b/stdlib/@python2/_curses.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, BinaryIO, Optional, Tuple, Union, overload +from typing import IO, Any, BinaryIO, Tuple, Union, overload _chtype = str | bytes | int diff --git a/stdlib/@python2/_dummy_threading.pyi b/stdlib/@python2/_dummy_threading.pyi index ab062bf200cc..6823a8d477fa 100644 --- a/stdlib/@python2/_dummy_threading.pyi +++ b/stdlib/@python2/_dummy_threading.pyi @@ -1,5 +1,5 @@ from types import FrameType, TracebackType -from typing import Any, Callable, Iterable, List, Mapping, Optional, Text, Type, TypeVar, Union +from typing import Any, Callable, Iterable, List, Mapping, Text, Type, TypeVar, Union # TODO recursive type _TF = Callable[[FrameType, str, Any], Callable[..., Any] | None] diff --git a/stdlib/@python2/_io.pyi b/stdlib/@python2/_io.pyi index 368f3f44f725..3e62b942ddcd 100644 --- a/stdlib/@python2/_io.pyi +++ b/stdlib/@python2/_io.pyi @@ -1,5 +1,5 @@ from mmap import mmap -from typing import IO, Any, BinaryIO, Iterable, List, Optional, Text, TextIO, Tuple, Type, TypeVar, Union +from typing import IO, Any, BinaryIO, Iterable, List, Text, TextIO, Tuple, Type, TypeVar, Union _bytearray_like = bytearray | mmap diff --git a/stdlib/@python2/_msi.pyi b/stdlib/@python2/_msi.pyi index f70a6df31a74..159ce1523e0a 100644 --- a/stdlib/@python2/_msi.pyi +++ b/stdlib/@python2/_msi.pyi @@ -1,5 +1,5 @@ import sys -from typing import List, Optional, Union +from typing import List, Union if sys.platform == "win32": diff --git a/stdlib/@python2/_osx_support.pyi b/stdlib/@python2/_osx_support.pyi index 0362ebef3a2f..b6d1b9687b25 100644 --- a/stdlib/@python2/_osx_support.pyi +++ b/stdlib/@python2/_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, Union _T = TypeVar("_T") _K = TypeVar("_K") diff --git a/stdlib/@python2/_socket.pyi b/stdlib/@python2/_socket.pyi index 1782d4c4dd9b..6cbba020c639 100644 --- a/stdlib/@python2/_socket.pyi +++ b/stdlib/@python2/_socket.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Optional, Tuple, Union, overload +from typing import IO, Any, Tuple, Union, overload AF_APPLETALK: int AF_ASH: int diff --git a/stdlib/@python2/_sre.pyi b/stdlib/@python2/_sre.pyi index 1c0a608c259d..3aed5cd89471 100644 --- a/stdlib/@python2/_sre.pyi +++ b/stdlib/@python2/_sre.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union, overload +from typing import Any, Dict, Iterable, List, Mapping, Sequence, Tuple, Union, overload CODESIZE: int MAGIC: int diff --git a/stdlib/@python2/_thread.pyi b/stdlib/@python2/_thread.pyi index b900fc7874af..562ece61e042 100644 --- a/stdlib/@python2/_thread.pyi +++ b/stdlib/@python2/_thread.pyi @@ -1,5 +1,5 @@ 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/@python2/_typeshed/xml.pyi b/stdlib/@python2/_typeshed/xml.pyi index 1f7bd9aeb1de..6a5d2531ca72 100644 --- a/stdlib/@python2/_typeshed/xml.pyi +++ b/stdlib/@python2/_typeshed/xml.pyi @@ -1,6 +1,6 @@ # Stub-only types. This module does not exist at runtime. -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/@python2/_weakrefset.pyi b/stdlib/@python2/_weakrefset.pyi index a7ebd8e24e9d..cc2d1c66139a 100644 --- a/stdlib/@python2/_weakrefset.pyi +++ b/stdlib/@python2/_weakrefset.pyi @@ -1,4 +1,4 @@ -from typing import Any, Generic, Iterable, Iterator, MutableSet, Optional, TypeVar, Union +from typing import Any, Generic, Iterable, Iterator, MutableSet, TypeVar, Union _S = TypeVar("_S") _T = TypeVar("_T") diff --git a/stdlib/@python2/_winreg.pyi b/stdlib/@python2/_winreg.pyi index 8e4cbfa0e146..8bf9859bbe31 100644 --- a/stdlib/@python2/_winreg.pyi +++ b/stdlib/@python2/_winreg.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Any, Optional, Tuple, Type, Union +from typing import Any, Tuple, Type, Union _KeyType = HKEYType | int diff --git a/stdlib/@python2/aifc.pyi b/stdlib/@python2/aifc.pyi index ec34113c2c2a..8ba7521bc24b 100644 --- a/stdlib/@python2/aifc.pyi +++ b/stdlib/@python2/aifc.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, List, NamedTuple, Optional, Text, Tuple, Union, overload +from typing import IO, Any, List, NamedTuple, Text, Tuple, Union, overload from typing_extensions import Literal class Error(Exception): ... diff --git a/stdlib/@python2/ast.pyi b/stdlib/@python2/ast.pyi index e52ebb43d21c..103c84b98b8b 100644 --- a/stdlib/@python2/ast.pyi +++ b/stdlib/@python2/ast.pyi @@ -4,7 +4,7 @@ # from _ast below when loaded in an unorthodox way by the Dropbox # internal Bazel integration. import typing as _typing -from typing import Any, Iterator, Optional, Union +from typing import Any, Iterator, Union from _ast import * from _ast import AST, Module diff --git a/stdlib/@python2/asyncore.pyi b/stdlib/@python2/asyncore.pyi index 7a159c5fc520..d50dddd481cd 100644 --- a/stdlib/@python2/asyncore.pyi +++ b/stdlib/@python2/asyncore.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import FileDescriptorLike from socket import SocketType -from typing import Any, Dict, Optional, Tuple, Union, overload +from typing import Any, Dict, Tuple, Union, overload # cyclic dependence with asynchat _maptype = Dict[int, Any] diff --git a/stdlib/@python2/base64.pyi b/stdlib/@python2/base64.pyi index 4bc926c09594..b2d437190d87 100644 --- a/stdlib/@python2/base64.pyi +++ b/stdlib/@python2/base64.pyi @@ -1,4 +1,4 @@ -from typing import IO, Optional, Union +from typing import IO, Union _encodable = bytes | unicode _decodable = bytes | unicode diff --git a/stdlib/@python2/bdb.pyi b/stdlib/@python2/bdb.pyi index bf8f3c583260..c43b27b09f95 100644 --- a/stdlib/@python2/bdb.pyi +++ b/stdlib/@python2/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, Union _T = TypeVar("_T") _TraceDispatch = Callable[[FrameType, str, Any], Any] # TODO: Recursive type diff --git a/stdlib/@python2/bz2.pyi b/stdlib/@python2/bz2.pyi index 7712d887b4fb..453ed7d452d8 100644 --- a/stdlib/@python2/bz2.pyi +++ b/stdlib/@python2/bz2.pyi @@ -1,6 +1,6 @@ import io from _typeshed import ReadableBuffer, WriteableBuffer -from typing import IO, Any, Iterable, List, Optional, Text, TypeVar, Union +from typing import IO, Any, Iterable, List, Text, TypeVar, Union from typing_extensions import SupportsIndex _PathOrFile = Text | IO[bytes] diff --git a/stdlib/@python2/cProfile.pyi b/stdlib/@python2/cProfile.pyi index 0e436859d92a..8e6506ddcae5 100644 --- a/stdlib/@python2/cProfile.pyi +++ b/stdlib/@python2/cProfile.pyi @@ -1,5 +1,5 @@ from types import CodeType -from typing import Any, Callable, Dict, Optional, Text, Tuple, TypeVar, Union +from typing import Any, Callable, Dict, Text, Tuple, TypeVar, Union def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( diff --git a/stdlib/@python2/cStringIO.pyi b/stdlib/@python2/cStringIO.pyi index 90a9fa16c181..6ced2d48e3f3 100644 --- a/stdlib/@python2/cStringIO.pyi +++ b/stdlib/@python2/cStringIO.pyi @@ -1,5 +1,5 @@ from abc import ABCMeta -from typing import IO, Iterable, Iterator, List, Optional, Union, overload +from typing import IO, Iterable, Iterator, List, Union, overload # This class isn't actually abstract, but you can't instantiate it # directly, so we might as well treat it as abstract in the stub. diff --git a/stdlib/@python2/calendar.pyi b/stdlib/@python2/calendar.pyi index b9ad9ff4a069..3ea4fd1edb0e 100644 --- a/stdlib/@python2/calendar.pyi +++ b/stdlib/@python2/calendar.pyi @@ -1,6 +1,6 @@ import datetime from time import struct_time -from typing import Any, Iterable, List, Optional, Sequence, Tuple, Union +from typing import Any, Iterable, List, Sequence, Tuple, Union _LocaleType = Tuple[str | None, str | None] diff --git a/stdlib/@python2/cgi.pyi b/stdlib/@python2/cgi.pyi index c3a5d81e852f..5a5b197daa7b 100644 --- a/stdlib/@python2/cgi.pyi +++ b/stdlib/@python2/cgi.pyi @@ -1,6 +1,6 @@ from _typeshed import SupportsGetItem, SupportsItemAccess from builtins import type as _type -from typing import IO, Any, AnyStr, Iterable, Iterator, List, Mapping, Optional, Protocol, TypeVar, Union +from typing import IO, Any, AnyStr, Iterable, Iterator, List, Mapping, Protocol, TypeVar, Union from UserDict import UserDict _T = TypeVar("_T", bound=FieldStorage) diff --git a/stdlib/@python2/cgitb.pyi b/stdlib/@python2/cgitb.pyi index ed6b3c041408..966e6cfb0b8e 100644 --- a/stdlib/@python2/cgitb.pyi +++ b/stdlib/@python2/cgitb.pyi @@ -1,5 +1,5 @@ from types import FrameType, TracebackType -from typing import IO, Any, Callable, Dict, List, Optional, Text, Tuple, Type +from typing import IO, Any, Callable, Dict, List, Text, Tuple, Type _ExcInfo = Tuple[Type[BaseException] | None, BaseException | None, TracebackType | None] diff --git a/stdlib/@python2/compileall.pyi b/stdlib/@python2/compileall.pyi index e9458e935e48..cd69bcdcb3a7 100644 --- a/stdlib/@python2/compileall.pyi +++ b/stdlib/@python2/compileall.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Pattern, Text +from typing import Any, Pattern, Text # rx can be any object with a 'search' method; once we have Protocols we can change the type def compile_dir( diff --git a/stdlib/@python2/contextlib.pyi b/stdlib/@python2/contextlib.pyi index 3b748e6c71b4..813399cc4112 100644 --- a/stdlib/@python2/contextlib.pyi +++ b/stdlib/@python2/contextlib.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import IO, Any, Callable, ContextManager, Iterable, Iterator, Optional, Type, TypeVar +from typing import IO, Any, Callable, ContextManager, Iterable, Iterator, Type, TypeVar from typing_extensions import Protocol _T = TypeVar("_T") diff --git a/stdlib/@python2/cookielib.pyi b/stdlib/@python2/cookielib.pyi index d58e669c3dba..0f813c128cc4 100644 --- a/stdlib/@python2/cookielib.pyi +++ b/stdlib/@python2/cookielib.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class Cookie: version: Any diff --git a/stdlib/@python2/copy.pyi b/stdlib/@python2/copy.pyi index 180e58756ead..c88f92846ddf 100644 --- a/stdlib/@python2/copy.pyi +++ b/stdlib/@python2/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/@python2/datetime.pyi b/stdlib/@python2/datetime.pyi index a5d8e1a1b994..5d2b0e0983ac 100644 --- a/stdlib/@python2/datetime.pyi +++ b/stdlib/@python2/datetime.pyi @@ -1,5 +1,5 @@ from time import struct_time -from typing import AnyStr, ClassVar, Optional, SupportsAbs, Tuple, Type, TypeVar, Union, overload +from typing import AnyStr, ClassVar, SupportsAbs, Tuple, Type, TypeVar, Union, overload _S = TypeVar("_S") diff --git a/stdlib/@python2/dbm/__init__.pyi b/stdlib/@python2/dbm/__init__.pyi index 2c1a16fdb7d8..8768d768d309 100644 --- a/stdlib/@python2/dbm/__init__.pyi +++ b/stdlib/@python2/dbm/__init__.pyi @@ -1,5 +1,5 @@ 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 = str | bytes diff --git a/stdlib/@python2/dbm/dumb.pyi b/stdlib/@python2/dbm/dumb.pyi index f0bd7aa59f8a..5c5c54450528 100644 --- a/stdlib/@python2/dbm/dumb.pyi +++ b/stdlib/@python2/dbm/dumb.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Iterator, MutableMapping, Optional, Type, Union +from typing import Iterator, MutableMapping, Type, Union _KeyType = str | bytes _ValueType = str | bytes diff --git a/stdlib/@python2/dbm/gnu.pyi b/stdlib/@python2/dbm/gnu.pyi index 3a0a3544dc20..225f0f8ee2dd 100644 --- a/stdlib/@python2/dbm/gnu.pyi +++ b/stdlib/@python2/dbm/gnu.pyi @@ -1,5 +1,5 @@ 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 = str | bytes diff --git a/stdlib/@python2/dbm/ndbm.pyi b/stdlib/@python2/dbm/ndbm.pyi index 94e14365081f..27951992473b 100644 --- a/stdlib/@python2/dbm/ndbm.pyi +++ b/stdlib/@python2/dbm/ndbm.pyi @@ -1,5 +1,5 @@ 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 = str | bytes diff --git a/stdlib/@python2/decimal.pyi b/stdlib/@python2/decimal.pyi index 63f54da62979..6f0a31fe6920 100644 --- a/stdlib/@python2/decimal.pyi +++ b/stdlib/@python2/decimal.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Any, Container, Dict, List, NamedTuple, Optional, Sequence, Text, Tuple, Type, TypeVar, Union +from typing import Any, Container, Dict, List, NamedTuple, Sequence, Text, Tuple, Type, TypeVar, Union _Decimal = Decimal | int _DecimalNew = Union[Decimal, float, Text, Tuple[int, Sequence[int], int]] diff --git a/stdlib/@python2/distutils/ccompiler.pyi b/stdlib/@python2/distutils/ccompiler.pyi index dfed71592d54..15fc46222339 100644 --- a/stdlib/@python2/distutils/ccompiler.pyi +++ b/stdlib/@python2/distutils/ccompiler.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, List, Optional, Tuple, Union +from typing import Any, Callable, List, Tuple, Union _Macro = Union[Tuple[str], Tuple[str, str | None]] diff --git a/stdlib/@python2/distutils/command/config.pyi b/stdlib/@python2/distutils/command/config.pyi index f95d8c5e41ce..89a316324acc 100644 --- a/stdlib/@python2/distutils/command/config.pyi +++ b/stdlib/@python2/distutils/command/config.pyi @@ -3,7 +3,7 @@ from distutils.ccompiler import CCompiler from distutils.core import Command as Command from distutils.errors import DistutilsExecError as DistutilsExecError from distutils.sysconfig import customize_compiler as customize_compiler -from typing import Dict, List, Optional, Pattern, Sequence, Tuple, Union +from typing import Dict, List, Pattern, Sequence, Tuple, Union LANG_EXT: Dict[str, str] diff --git a/stdlib/@python2/distutils/command/install_egg_info.pyi b/stdlib/@python2/distutils/command/install_egg_info.pyi index 40ce626e09a3..bf3d0737f244 100644 --- a/stdlib/@python2/distutils/command/install_egg_info.pyi +++ b/stdlib/@python2/distutils/command/install_egg_info.pyi @@ -1,5 +1,5 @@ from distutils.cmd import Command -from typing import ClassVar, List, Optional, Tuple +from typing import ClassVar, List, Tuple class install_egg_info(Command): description: ClassVar[str] diff --git a/stdlib/@python2/distutils/command/upload.pyi b/stdlib/@python2/distutils/command/upload.pyi index c49a4e5b4937..3835d9fd6ec6 100644 --- a/stdlib/@python2/distutils/command/upload.pyi +++ b/stdlib/@python2/distutils/command/upload.pyi @@ -1,5 +1,5 @@ from distutils.config import PyPIRCCommand -from typing import ClassVar, List, Optional, Tuple +from typing import ClassVar, List, Tuple class upload(PyPIRCCommand): description: ClassVar[str] diff --git a/stdlib/@python2/distutils/config.pyi b/stdlib/@python2/distutils/config.pyi index 29524d497acb..bcd626c81d48 100644 --- a/stdlib/@python2/distutils/config.pyi +++ b/stdlib/@python2/distutils/config.pyi @@ -1,6 +1,6 @@ from abc import abstractmethod from distutils.cmd import Command -from typing import ClassVar, List, Optional, Tuple +from typing import ClassVar, List, Tuple DEFAULT_PYPIRC: str diff --git a/stdlib/@python2/distutils/core.pyi b/stdlib/@python2/distutils/core.pyi index 997134596087..b56719ab69ee 100644 --- a/stdlib/@python2/distutils/core.pyi +++ b/stdlib/@python2/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, Union def setup( *, diff --git a/stdlib/@python2/distutils/dist.pyi b/stdlib/@python2/distutils/dist.pyi index 4403ca609576..adba8f093569 100644 --- a/stdlib/@python2/distutils/dist.pyi +++ b/stdlib/@python2/distutils/dist.pyi @@ -1,5 +1,5 @@ from distutils.cmd import Command -from typing import Any, Dict, Iterable, Mapping, Optional, Text, Tuple, Type +from typing import Any, Dict, Iterable, Mapping, Text, Tuple, Type class Distribution: cmdclass: Dict[str, Type[Command]] diff --git a/stdlib/@python2/distutils/extension.pyi b/stdlib/@python2/distutils/extension.pyi index 74b362699918..9335fad86418 100644 --- a/stdlib/@python2/distutils/extension.pyi +++ b/stdlib/@python2/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/@python2/distutils/fancy_getopt.pyi b/stdlib/@python2/distutils/fancy_getopt.pyi index 9965c6333b33..3eafcd98d8d2 100644 --- a/stdlib/@python2/distutils/fancy_getopt.pyi +++ b/stdlib/@python2/distutils/fancy_getopt.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Mapping, Optional, Tuple, Union, overload +from typing import Any, List, Mapping, Tuple, Union, overload _Option = Tuple[str, str | None, str] _GR = Tuple[List[str], OptionDummy] diff --git a/stdlib/@python2/distutils/spawn.pyi b/stdlib/@python2/distutils/spawn.pyi index 6e51effd858d..0fffc5402c62 100644 --- a/stdlib/@python2/distutils/spawn.pyi +++ b/stdlib/@python2/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/@python2/distutils/sysconfig.pyi b/stdlib/@python2/distutils/sysconfig.pyi index 42d46ec6ac75..ff307df63d4d 100644 --- a/stdlib/@python2/distutils/sysconfig.pyi +++ b/stdlib/@python2/distutils/sysconfig.pyi @@ -1,5 +1,5 @@ from distutils.ccompiler import CCompiler -from typing import Mapping, Optional, Union +from typing import Mapping, Union PREFIX: str EXEC_PREFIX: str diff --git a/stdlib/@python2/distutils/text_file.pyi b/stdlib/@python2/distutils/text_file.pyi index f9c2d4fa33fb..70c1a422fe85 100644 --- a/stdlib/@python2/distutils/text_file.pyi +++ b/stdlib/@python2/distutils/text_file.pyi @@ -1,4 +1,4 @@ -from typing import IO, List, Optional, Tuple, Union +from typing import IO, List, Tuple, Union class TextFile: def __init__( diff --git a/stdlib/@python2/distutils/util.pyi b/stdlib/@python2/distutils/util.pyi index ddf06c033fbb..c0882d1dd1cb 100644 --- a/stdlib/@python2/distutils/util.pyi +++ b/stdlib/@python2/distutils/util.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, List, Mapping, Optional, Tuple +from typing import Any, Callable, List, Mapping, Tuple def get_platform() -> str: ... def convert_path(pathname: str) -> str: ... diff --git a/stdlib/@python2/dummy_thread.pyi b/stdlib/@python2/dummy_thread.pyi index d27af55b1125..0a28b3aaeeb9 100644 --- a/stdlib/@python2/dummy_thread.pyi +++ b/stdlib/@python2/dummy_thread.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, NoReturn, Optional, Tuple +from typing import Any, Callable, Dict, NoReturn, Tuple class error(Exception): def __init__(self, *args: Any) -> None: ... diff --git a/stdlib/@python2/email/_parseaddr.pyi b/stdlib/@python2/email/_parseaddr.pyi index 3a23a743b162..74ea3a6e4a69 100644 --- a/stdlib/@python2/email/_parseaddr.pyi +++ b/stdlib/@python2/email/_parseaddr.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any def parsedate_tz(data): ... def parsedate(data): ... diff --git a/stdlib/@python2/email/mime/application.pyi b/stdlib/@python2/email/mime/application.pyi index 6f0f58687fd8..331af21f684b 100644 --- a/stdlib/@python2/email/mime/application.pyi +++ b/stdlib/@python2/email/mime/application.pyi @@ -1,5 +1,5 @@ from email.mime.nonmultipart import MIMENonMultipart -from typing import Callable, Optional, Tuple, Union +from typing import Callable, Tuple, Union _ParamsType = Union[str, None, Tuple[str, str | None, str]] diff --git a/stdlib/@python2/email/utils.pyi b/stdlib/@python2/email/utils.pyi index e0737b6fc1b8..0d185134c9d7 100644 --- a/stdlib/@python2/email/utils.pyi +++ b/stdlib/@python2/email/utils.pyi @@ -5,7 +5,7 @@ from email._parseaddr import ( parsedate_tz as _parsedate_tz, ) from quopri import decodestring as _qdecode -from typing import Any, Optional +from typing import Any def formataddr(pair): ... def getaddresses(fieldvalues): ... diff --git a/stdlib/@python2/filecmp.pyi b/stdlib/@python2/filecmp.pyi index b79cd50e12d6..1b86866b4474 100644 --- a/stdlib/@python2/filecmp.pyi +++ b/stdlib/@python2/filecmp.pyi @@ -1,4 +1,4 @@ -from typing import AnyStr, Callable, Dict, Generic, Iterable, List, Optional, Sequence, Text, Tuple, Union +from typing import AnyStr, Callable, Dict, Generic, Iterable, List, Sequence, Text, Tuple, Union DEFAULT_IGNORES: List[str] diff --git a/stdlib/@python2/formatter.pyi b/stdlib/@python2/formatter.pyi index f57d86c1022b..da165f2d55e3 100644 --- a/stdlib/@python2/formatter.pyi +++ b/stdlib/@python2/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/@python2/gettext.pyi b/stdlib/@python2/gettext.pyi index c8ecde4f4a8c..9ecf387e7a4c 100644 --- a/stdlib/@python2/gettext.pyi +++ b/stdlib/@python2/gettext.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Container, Dict, List, Optional, Sequence, Type, Union +from typing import IO, Any, Container, Dict, List, Sequence, Type, Union def bindtextdomain(domain: str, localedir: str = ...) -> str: ... def bind_textdomain_codeset(domain: str, codeset: str = ...) -> str: ... diff --git a/stdlib/@python2/grp.pyi b/stdlib/@python2/grp.pyi index 63b7145d0350..63898b26bf17 100644 --- a/stdlib/@python2/grp.pyi +++ b/stdlib/@python2/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/@python2/hmac.pyi b/stdlib/@python2/hmac.pyi index d8a10741999b..cc39d8c65c8f 100644 --- a/stdlib/@python2/hmac.pyi +++ b/stdlib/@python2/hmac.pyi @@ -1,6 +1,6 @@ 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/@python2/httplib.pyi b/stdlib/@python2/httplib.pyi index 321f19c4398e..f2163818fae4 100644 --- a/stdlib/@python2/httplib.pyi +++ b/stdlib/@python2/httplib.pyi @@ -1,5 +1,5 @@ import mimetools -from typing import Any, Dict, Optional, Protocol +from typing import Any, Dict, Protocol class HTTPMessage(mimetools.Message): def addcontinue(self, key: str, more: str) -> None: ... diff --git a/stdlib/@python2/imaplib.pyi b/stdlib/@python2/imaplib.pyi index e893457c050b..c24480356152 100644 --- a/stdlib/@python2/imaplib.pyi +++ b/stdlib/@python2/imaplib.pyi @@ -2,7 +2,7 @@ import subprocess import time from socket import socket as _socket from ssl import SSLSocket -from typing import IO, Any, Callable, Dict, List, Optional, Pattern, Text, Tuple, Type, Union +from typing import IO, Any, Callable, Dict, List, Pattern, Text, Tuple, Type, Union from typing_extensions import Literal # TODO: Commands should use their actual return types, not this type alias. diff --git a/stdlib/@python2/imghdr.pyi b/stdlib/@python2/imghdr.pyi index afddb98e2d43..f66157423c77 100644 --- a/stdlib/@python2/imghdr.pyi +++ b/stdlib/@python2/imghdr.pyi @@ -1,4 +1,4 @@ -from typing import Any, BinaryIO, Callable, List, Optional, Protocol, Text, Union, overload +from typing import Any, BinaryIO, Callable, List, Protocol, Text, Union, overload class _ReadableBinary(Protocol): def tell(self) -> int: ... diff --git a/stdlib/@python2/lib2to3/pgen2/driver.pyi b/stdlib/@python2/lib2to3/pgen2/driver.pyi index 7268c6c6daa8..f36e3dd0a10c 100644 --- a/stdlib/@python2/lib2to3/pgen2/driver.pyi +++ b/stdlib/@python2/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, Text +from typing import IO, Any, Iterable, Text class Driver: grammar: Grammar diff --git a/stdlib/@python2/lib2to3/pgen2/grammar.pyi b/stdlib/@python2/lib2to3/pgen2/grammar.pyi index db1821868a4d..f58bfd6d1253 100644 --- a/stdlib/@python2/lib2to3/pgen2/grammar.pyi +++ b/stdlib/@python2/lib2to3/pgen2/grammar.pyi @@ -1,5 +1,5 @@ from _typeshed import StrPath -from typing import Dict, List, Optional, Text, Tuple, TypeVar +from typing import Dict, List, Text, Tuple, TypeVar _P = TypeVar("_P") _Label = Tuple[int, Text | None] diff --git a/stdlib/@python2/lib2to3/pgen2/parse.pyi b/stdlib/@python2/lib2to3/pgen2/parse.pyi index 2c8f2b793035..eed165db551c 100644 --- a/stdlib/@python2/lib2to3/pgen2/parse.pyi +++ b/stdlib/@python2/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, Text, Tuple +from typing import Any, List, Sequence, Set, Text, Tuple _Context = Sequence[Any] diff --git a/stdlib/@python2/lib2to3/pgen2/pgen.pyi b/stdlib/@python2/lib2to3/pgen2/pgen.pyi index afe44deeacb1..67dbbccdd4a6 100644 --- a/stdlib/@python2/lib2to3/pgen2/pgen.pyi +++ b/stdlib/@python2/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, Text, Tuple +from typing import IO, Any, Dict, Iterable, Iterator, List, NoReturn, Text, Tuple class PgenGrammar(grammar.Grammar): ... diff --git a/stdlib/@python2/lib2to3/pytree.pyi b/stdlib/@python2/lib2to3/pytree.pyi index 4e5badd58e8b..e18837f5c937 100644 --- a/stdlib/@python2/lib2to3/pytree.pyi +++ b/stdlib/@python2/lib2to3/pytree.pyi @@ -1,5 +1,5 @@ from lib2to3.pgen2.grammar import Grammar -from typing import Any, Callable, Dict, Iterator, List, Optional, Text, Tuple, TypeVar, Union +from typing import Any, Callable, Dict, Iterator, List, Text, Tuple, TypeVar, Union _P = TypeVar("_P") _NL = Node | Leaf diff --git a/stdlib/@python2/linecache.pyi b/stdlib/@python2/linecache.pyi index f262ff545d82..8628a0c58adc 100644 --- a/stdlib/@python2/linecache.pyi +++ b/stdlib/@python2/linecache.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Text +from typing import Any, Dict, List, Text _ModuleGlobals = Dict[str, Any] diff --git a/stdlib/@python2/locale.pyi b/stdlib/@python2/locale.pyi index 4a828fa1ecab..f04adcbac0a0 100644 --- a/stdlib/@python2/locale.pyi +++ b/stdlib/@python2/locale.pyi @@ -1,7 +1,7 @@ # workaround for mypy#2010 from __builtin__ 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, Union CODESET: int D_T_FMT: int diff --git a/stdlib/@python2/logging/__init__.pyi b/stdlib/@python2/logging/__init__.pyi index 3c3b1d7430bc..a3a60ec3f7b4 100644 --- a/stdlib/@python2/logging/__init__.pyi +++ b/stdlib/@python2/logging/__init__.pyi @@ -2,7 +2,7 @@ import threading from _typeshed import StrPath from time import struct_time from types import FrameType, TracebackType -from typing import IO, Any, Callable, Dict, List, Mapping, MutableMapping, Optional, Sequence, Text, Tuple, Union, overload +from typing import IO, Any, Callable, Dict, List, Mapping, MutableMapping, Sequence, Text, Tuple, Union, overload _SysExcInfoType = Union[Tuple[type, BaseException, TracebackType | None], Tuple[None, None, None]] _ExcInfoType = None | bool | _SysExcInfoType diff --git a/stdlib/@python2/logging/config.pyi b/stdlib/@python2/logging/config.pyi index 5f1f5e4bb218..f734828ddb7e 100644 --- a/stdlib/@python2/logging/config.pyi +++ b/stdlib/@python2/logging/config.pyi @@ -1,6 +1,6 @@ from _typeshed import StrPath from threading import Thread -from typing import IO, Any, Dict, Optional, Union +from typing import IO, Any, Dict, Union _Path = StrPath diff --git a/stdlib/@python2/logging/handlers.pyi b/stdlib/@python2/logging/handlers.pyi index f979b54d36f8..7ba6b421aab5 100644 --- a/stdlib/@python2/logging/handlers.pyi +++ b/stdlib/@python2/logging/handlers.pyi @@ -1,7 +1,7 @@ from _typeshed import StrPath from logging import FileHandler, Handler, LogRecord from socket import SocketKind, SocketType -from typing import Any, ClassVar, Dict, List, Optional, Tuple, Union +from typing import Any, ClassVar, Dict, List, Tuple, Union DEFAULT_TCP_LOGGING_PORT: int DEFAULT_UDP_LOGGING_PORT: int diff --git a/stdlib/@python2/macpath.pyi b/stdlib/@python2/macpath.pyi index b3836d0f12cc..bcb882e23eef 100644 --- a/stdlib/@python2/macpath.pyi +++ b/stdlib/@python2/macpath.pyi @@ -27,7 +27,7 @@ from posixpath import ( splitext as splitext, supports_unicode_filenames as supports_unicode_filenames, ) -from typing import AnyStr, Optional, Text, Tuple, overload +from typing import AnyStr, Text, Tuple, overload altsep: str | None diff --git a/stdlib/@python2/mailcap.pyi b/stdlib/@python2/mailcap.pyi index 34a863f04477..b0c538c6bbcd 100644 --- a/stdlib/@python2/mailcap.pyi +++ b/stdlib/@python2/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, str | int] diff --git a/stdlib/@python2/mimetypes.pyi b/stdlib/@python2/mimetypes.pyi index 85e720738aae..a9661dab56ad 100644 --- a/stdlib/@python2/mimetypes.pyi +++ b/stdlib/@python2/mimetypes.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Dict, List, Optional, Sequence, Text, Tuple +from typing import IO, Dict, List, Sequence, Text, Tuple def guess_type(url: Text, strict: bool = ...) -> Tuple[str | None, str | None]: ... def guess_all_extensions(type: str, strict: bool = ...) -> List[str]: ... diff --git a/stdlib/@python2/mmap.pyi b/stdlib/@python2/mmap.pyi index a41dae68accc..9decd440add3 100644 --- a/stdlib/@python2/mmap.pyi +++ b/stdlib/@python2/mmap.pyi @@ -1,5 +1,5 @@ import sys -from typing import AnyStr, Generic, Optional, Sequence, Union +from typing import AnyStr, Generic, Sequence, Union ACCESS_DEFAULT: int ACCESS_READ: int diff --git a/stdlib/@python2/modulefinder.pyi b/stdlib/@python2/modulefinder.pyi index 6331d5cf5080..76fd014daf6e 100644 --- a/stdlib/@python2/modulefinder.pyi +++ b/stdlib/@python2/modulefinder.pyi @@ -1,5 +1,5 @@ from types import CodeType -from typing import IO, Any, Container, Dict, Iterable, List, Optional, Sequence, Tuple +from typing import IO, Any, Container, Dict, Iterable, List, Sequence, Tuple LOAD_CONST: int # undocumented IMPORT_NAME: int # undocumented diff --git a/stdlib/@python2/msilib/__init__.pyi b/stdlib/@python2/msilib/__init__.pyi index 802f7f2f9358..1f69351360aa 100644 --- a/stdlib/@python2/msilib/__init__.pyi +++ b/stdlib/@python2/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, Union from typing_extensions import Literal if sys.platform == "win32": diff --git a/stdlib/@python2/msilib/schema.pyi b/stdlib/@python2/msilib/schema.pyi index f7f71edff390..90dcd04d06f2 100644 --- a/stdlib/@python2/msilib/schema.pyi +++ b/stdlib/@python2/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/@python2/msilib/sequence.pyi b/stdlib/@python2/msilib/sequence.pyi index 25ec9aa71a87..48d1a0beed85 100644 --- a/stdlib/@python2/msilib/sequence.pyi +++ b/stdlib/@python2/msilib/sequence.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/@python2/msilib/text.pyi b/stdlib/@python2/msilib/text.pyi index 79e166eed550..4ae8ee68184b 100644 --- a/stdlib/@python2/msilib/text.pyi +++ b/stdlib/@python2/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/@python2/multiprocessing/__init__.pyi b/stdlib/@python2/multiprocessing/__init__.pyi index 7f178bf85a94..e22e09000de1 100644 --- a/stdlib/@python2/multiprocessing/__init__.pyi +++ b/stdlib/@python2/multiprocessing/__init__.pyi @@ -2,7 +2,7 @@ from multiprocessing import pool from multiprocessing.process import Process as Process, active_children as active_children, current_process as current_process from multiprocessing.util import SUBDEBUG as SUBDEBUG, SUBWARNING as SUBWARNING from Queue import Queue as _BaseQueue -from typing import Any, Callable, Iterable, Optional, TypeVar +from typing import Any, Callable, Iterable, TypeVar class ProcessError(Exception): ... class BufferTooShort(ProcessError): ... diff --git a/stdlib/@python2/multiprocessing/dummy/__init__.pyi b/stdlib/@python2/multiprocessing/dummy/__init__.pyi index b6ee38e359c3..80a1456d1be8 100644 --- a/stdlib/@python2/multiprocessing/dummy/__init__.pyi +++ b/stdlib/@python2/multiprocessing/dummy/__init__.pyi @@ -2,7 +2,7 @@ import array import threading import weakref from Queue import Queue -from typing import Any, List, Optional +from typing import Any, List class DummyProcess(threading.Thread): _children: weakref.WeakKeyDictionary[Any, Any] diff --git a/stdlib/@python2/multiprocessing/dummy/connection.pyi b/stdlib/@python2/multiprocessing/dummy/connection.pyi index 141ef3e3d85d..ae5e05e9ccdd 100644 --- a/stdlib/@python2/multiprocessing/dummy/connection.pyi +++ b/stdlib/@python2/multiprocessing/dummy/connection.pyi @@ -1,5 +1,5 @@ from Queue import Queue -from typing import Any, List, Optional, Tuple +from typing import Any, List, Tuple families: List[None] diff --git a/stdlib/@python2/multiprocessing/pool.pyi b/stdlib/@python2/multiprocessing/pool.pyi index d454a3308b5d..be9747e89c2f 100644 --- a/stdlib/@python2/multiprocessing/pool.pyi +++ b/stdlib/@python2/multiprocessing/pool.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, TypeVar +from typing import Any, Callable, Dict, Iterable, Iterator, List, TypeVar _T = TypeVar("_T", bound=Pool) diff --git a/stdlib/@python2/multiprocessing/process.pyi b/stdlib/@python2/multiprocessing/process.pyi index 263070e5c1c4..3c381f7ac232 100644 --- a/stdlib/@python2/multiprocessing/process.pyi +++ b/stdlib/@python2/multiprocessing/process.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any def current_process(): ... def active_children(): ... diff --git a/stdlib/@python2/multiprocessing/util.pyi b/stdlib/@python2/multiprocessing/util.pyi index 4bccc6e6ab46..6976bc3e6cf4 100644 --- a/stdlib/@python2/multiprocessing/util.pyi +++ b/stdlib/@python2/multiprocessing/util.pyi @@ -1,5 +1,5 @@ import threading -from typing import Any, Optional +from typing import Any SUBDEBUG: Any SUBWARNING: Any diff --git a/stdlib/@python2/netrc.pyi b/stdlib/@python2/netrc.pyi index 06a8520f1c51..c8d14e1e753f 100644 --- a/stdlib/@python2/netrc.pyi +++ b/stdlib/@python2/netrc.pyi @@ -1,4 +1,4 @@ -from typing import Dict, List, Optional, Text, Tuple +from typing import Dict, List, Text, Tuple class NetrcParseError(Exception): filename: str | None diff --git a/stdlib/@python2/nntplib.pyi b/stdlib/@python2/nntplib.pyi index bd7524dd8bbf..9cc482b5a2e3 100644 --- a/stdlib/@python2/nntplib.pyi +++ b/stdlib/@python2/nntplib.pyi @@ -1,7 +1,7 @@ import datetime import socket import ssl -from typing import IO, Any, Dict, Iterable, List, NamedTuple, Optional, Tuple, TypeVar, Union +from typing import IO, Any, Dict, Iterable, List, NamedTuple, Tuple, TypeVar, Union _SelfT = TypeVar("_SelfT", bound=_NNTPBase) _File = Union[IO[bytes], bytes, str, None] diff --git a/stdlib/@python2/ntpath.pyi b/stdlib/@python2/ntpath.pyi index e957604a6aff..514db760886f 100644 --- a/stdlib/@python2/ntpath.pyi +++ b/stdlib/@python2/ntpath.pyi @@ -1,7 +1,7 @@ import os import sys from genericpath import exists as exists -from typing import Any, AnyStr, Callable, List, Optional, Sequence, Text, Tuple, TypeVar, overload +from typing import Any, AnyStr, Callable, List, Sequence, Text, Tuple, TypeVar, overload _T = TypeVar("_T") diff --git a/stdlib/@python2/numbers.pyi b/stdlib/@python2/numbers.pyi index 8d14aec08295..fb88e076d446 100644 --- a/stdlib/@python2/numbers.pyi +++ b/stdlib/@python2/numbers.pyi @@ -2,7 +2,7 @@ # signatures are currently omitted. from abc import ABCMeta, abstractmethod -from typing import Any, Optional, SupportsFloat +from typing import Any, SupportsFloat class Number(metaclass=ABCMeta): @abstractmethod diff --git a/stdlib/@python2/os/path.pyi b/stdlib/@python2/os/path.pyi index fce71b521ce7..2ce2f592f0e2 100644 --- a/stdlib/@python2/os/path.pyi +++ b/stdlib/@python2/os/path.pyi @@ -1,6 +1,6 @@ import os import sys -from typing import Any, AnyStr, Callable, List, Optional, Sequence, Text, Tuple, TypeVar, overload +from typing import Any, AnyStr, Callable, List, Sequence, Text, Tuple, TypeVar, overload _T = TypeVar("_T") diff --git a/stdlib/@python2/os2emxpath.pyi b/stdlib/@python2/os2emxpath.pyi index e957604a6aff..514db760886f 100644 --- a/stdlib/@python2/os2emxpath.pyi +++ b/stdlib/@python2/os2emxpath.pyi @@ -1,7 +1,7 @@ import os import sys from genericpath import exists as exists -from typing import Any, AnyStr, Callable, List, Optional, Sequence, Text, Tuple, TypeVar, overload +from typing import Any, AnyStr, Callable, List, Sequence, Text, Tuple, TypeVar, overload _T = TypeVar("_T") diff --git a/stdlib/@python2/pdb.pyi b/stdlib/@python2/pdb.pyi index 78955452f2ae..238290c2a84c 100644 --- a/stdlib/@python2/pdb.pyi +++ b/stdlib/@python2/pdb.pyi @@ -1,7 +1,7 @@ from bdb import Bdb from cmd import Cmd from types import FrameType, TracebackType -from typing import IO, Any, Callable, ClassVar, Dict, Iterable, List, Mapping, Optional, Tuple, TypeVar, Union +from typing import IO, Any, Callable, ClassVar, Dict, Iterable, List, Mapping, Tuple, TypeVar, Union _T = TypeVar("_T") diff --git a/stdlib/@python2/pickle.pyi b/stdlib/@python2/pickle.pyi index 4e3740ccc363..9df31547ae2f 100644 --- a/stdlib/@python2/pickle.pyi +++ b/stdlib/@python2/pickle.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, Iterator, Optional, Tuple, Type, Union +from typing import IO, Any, Callable, Iterator, Tuple, Type, Union HIGHEST_PROTOCOL: int bytes_types: Tuple[Type[Any], ...] # undocumented diff --git a/stdlib/@python2/pickletools.pyi b/stdlib/@python2/pickletools.pyi index e6163e574202..4f6d8f36a4c2 100644 --- a/stdlib/@python2/pickletools.pyi +++ b/stdlib/@python2/pickletools.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, Iterator, List, MutableMapping, Optional, Text, Tuple, Type, Union +from typing import IO, Any, Callable, Iterator, List, MutableMapping, Text, Tuple, Type, Union _Reader = Callable[[IO[bytes]], Any] diff --git a/stdlib/@python2/platform.pyi b/stdlib/@python2/platform.pyi index ab3ff734f3a6..b984a2b2d3d5 100644 --- a/stdlib/@python2/platform.pyi +++ b/stdlib/@python2/platform.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Tuple +from typing import Any, Tuple __copyright__: Any DEV_NULL: Any diff --git a/stdlib/@python2/popen2.pyi b/stdlib/@python2/popen2.pyi index 9dc92e7072b0..80ebf7a6c0f0 100644 --- a/stdlib/@python2/popen2.pyi +++ b/stdlib/@python2/popen2.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Optional, TextIO, Tuple, TypeVar, Union +from typing import Any, Iterable, TextIO, Tuple, TypeVar, Union _T = TypeVar("_T") diff --git a/stdlib/@python2/poplib.pyi b/stdlib/@python2/poplib.pyi index 2cb08c864310..7a71f9850dfe 100644 --- a/stdlib/@python2/poplib.pyi +++ b/stdlib/@python2/poplib.pyi @@ -1,5 +1,5 @@ import socket -from typing import Any, BinaryIO, List, Optional, Pattern, Text, Tuple, overload +from typing import Any, BinaryIO, List, Pattern, Text, Tuple, overload _LongResp = Tuple[bytes, List[bytes], int] diff --git a/stdlib/@python2/posix.pyi b/stdlib/@python2/posix.pyi index c6637a5d72bb..a8e104f9bca2 100644 --- a/stdlib/@python2/posix.pyi +++ b/stdlib/@python2/posix.pyi @@ -1,5 +1,5 @@ from _typeshed import FileDescriptorLike -from typing import IO, AnyStr, Dict, List, Mapping, NamedTuple, Optional, Sequence, Tuple, TypeVar, Union +from typing import IO, AnyStr, Dict, List, Mapping, NamedTuple, Sequence, Tuple, TypeVar, Union error = OSError diff --git a/stdlib/@python2/posixpath.pyi b/stdlib/@python2/posixpath.pyi index e957604a6aff..514db760886f 100644 --- a/stdlib/@python2/posixpath.pyi +++ b/stdlib/@python2/posixpath.pyi @@ -1,7 +1,7 @@ import os import sys from genericpath import exists as exists -from typing import Any, AnyStr, Callable, List, Optional, Sequence, Text, Tuple, TypeVar, overload +from typing import Any, AnyStr, Callable, List, Sequence, Text, Tuple, TypeVar, overload _T = TypeVar("_T") diff --git a/stdlib/@python2/pprint.pyi b/stdlib/@python2/pprint.pyi index 8d1f795709e7..16fdc9efe0aa 100644 --- a/stdlib/@python2/pprint.pyi +++ b/stdlib/@python2/pprint.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Dict, Optional, Tuple +from typing import IO, Any, Dict, Tuple def pformat(object: object, indent: int = ..., width: int = ..., depth: int | None = ...) -> str: ... def pprint( diff --git a/stdlib/@python2/pstats.pyi b/stdlib/@python2/pstats.pyi index adea69a4603a..03a24f4bc817 100644 --- a/stdlib/@python2/pstats.pyi +++ b/stdlib/@python2/pstats.pyi @@ -1,6 +1,6 @@ from cProfile import Profile as _cProfile from profile import Profile -from typing import IO, Any, Dict, Iterable, List, Optional, Text, Tuple, TypeVar, Union, overload +from typing import IO, Any, Dict, Iterable, List, Text, Tuple, TypeVar, Union, overload _Selector = str | float | int _T = TypeVar("_T", bound=Stats) diff --git a/stdlib/@python2/py_compile.pyi b/stdlib/@python2/py_compile.pyi index c08e98833356..b8371968afd0 100644 --- a/stdlib/@python2/py_compile.pyi +++ b/stdlib/@python2/py_compile.pyi @@ -1,4 +1,4 @@ -from typing import List, Optional, Text, Type, Union +from typing import List, Text, Type, Union _EitherStr = bytes | Text diff --git a/stdlib/@python2/pyclbr.pyi b/stdlib/@python2/pyclbr.pyi index 097a113d041e..416a3af46607 100644 --- a/stdlib/@python2/pyclbr.pyi +++ b/stdlib/@python2/pyclbr.pyi @@ -1,4 +1,4 @@ -from typing import Dict, List, Optional, Sequence, Union +from typing import Dict, List, Sequence, Union class Class: module: str diff --git a/stdlib/@python2/re.pyi b/stdlib/@python2/re.pyi index 8ed31dd028ac..16bbcee658ae 100644 --- a/stdlib/@python2/re.pyi +++ b/stdlib/@python2/re.pyi @@ -1,4 +1,4 @@ -from typing import Any, AnyStr, Callable, Iterator, List, Match, Optional, Pattern, Tuple, Union, overload +from typing import Any, AnyStr, Callable, Iterator, List, Match, Pattern, Tuple, Union, overload # ----- re variables and constants ----- DEBUG: int diff --git a/stdlib/@python2/rfc822.pyi b/stdlib/@python2/rfc822.pyi index c61bacfd8e6d..d6ae0031ffdf 100644 --- a/stdlib/@python2/rfc822.pyi +++ b/stdlib/@python2/rfc822.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class Message: fp: Any diff --git a/stdlib/@python2/rlcompleter.pyi b/stdlib/@python2/rlcompleter.pyi index 1aea1d267087..4821be2a91bc 100644 --- a/stdlib/@python2/rlcompleter.pyi +++ b/stdlib/@python2/rlcompleter.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Union +from typing import Any, Dict, Union _Text = str | unicode diff --git a/stdlib/@python2/runpy.pyi b/stdlib/@python2/runpy.pyi index 8a6b38a1324d..3d5f0500f2e0 100644 --- a/stdlib/@python2/runpy.pyi +++ b/stdlib/@python2/runpy.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any class _TempModule: mod_name: Any diff --git a/stdlib/@python2/select.pyi b/stdlib/@python2/select.pyi index d07aec390d0b..b960fd4e24b5 100644 --- a/stdlib/@python2/select.pyi +++ b/stdlib/@python2/select.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import FileDescriptorLike -from typing import Any, Iterable, List, Optional, Tuple +from typing import Any, Iterable, List, Tuple if sys.platform != "win32": PIPE_BUF: int diff --git a/stdlib/@python2/sets.pyi b/stdlib/@python2/sets.pyi index 19e09d9f316b..4f0cc1b9dcc3 100644 --- a/stdlib/@python2/sets.pyi +++ b/stdlib/@python2/sets.pyi @@ -1,4 +1,4 @@ -from typing import Any, Hashable, Iterable, Iterator, MutableMapping, Optional, TypeVar, Union +from typing import Any, Hashable, Iterable, Iterator, MutableMapping, TypeVar, Union _T = TypeVar("_T") _Setlike = BaseSet[_T] | Iterable[_T] diff --git a/stdlib/@python2/shelve.pyi b/stdlib/@python2/shelve.pyi index d69a5e46be88..d9b1a00e58df 100644 --- a/stdlib/@python2/shelve.pyi +++ b/stdlib/@python2/shelve.pyi @@ -1,5 +1,5 @@ import collections -from typing import Any, Dict, Iterator, List, Optional, Tuple +from typing import Any, Dict, Iterator, List, Tuple class Shelf(collections.MutableMapping[Any, Any]): def __init__( diff --git a/stdlib/@python2/shlex.pyi b/stdlib/@python2/shlex.pyi index 5e9f71f9b6ee..049c4f65e716 100644 --- a/stdlib/@python2/shlex.pyi +++ b/stdlib/@python2/shlex.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, List, Optional, Text, TypeVar, Union +from typing import IO, Any, List, Text, TypeVar, Union def split(s: str | None, comments: bool = ..., posix: bool = ...) -> List[str]: ... diff --git a/stdlib/@python2/site.pyi b/stdlib/@python2/site.pyi index d9f8da8a7e2d..c77c9397f612 100644 --- a/stdlib/@python2/site.pyi +++ b/stdlib/@python2/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/@python2/smtpd.pyi b/stdlib/@python2/smtpd.pyi index c935571d0d95..cc59cd5d09ad 100644 --- a/stdlib/@python2/smtpd.pyi +++ b/stdlib/@python2/smtpd.pyi @@ -1,7 +1,7 @@ import asynchat import asyncore import socket -from typing import Any, List, Optional, Text, Tuple, Type, Union +from typing import Any, List, Text, Tuple, Type, Union _Address = Tuple[str, int] # (host, port) diff --git a/stdlib/@python2/socket.pyi b/stdlib/@python2/socket.pyi index e981fe43eacc..c1ba43b7b757 100644 --- a/stdlib/@python2/socket.pyi +++ b/stdlib/@python2/socket.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, BinaryIO, Iterable, List, Optional, Text, Tuple, TypeVar, Union, overload +from typing import Any, BinaryIO, Iterable, List, Text, Tuple, TypeVar, Union, overload # ----- Constants ----- # Some socket families are listed in the "Socket families" section of the docs, diff --git a/stdlib/@python2/sqlite3/dbapi2.pyi b/stdlib/@python2/sqlite3/dbapi2.pyi index 423c91678a47..8c997ef7109c 100644 --- a/stdlib/@python2/sqlite3/dbapi2.pyi +++ b/stdlib/@python2/sqlite3/dbapi2.pyi @@ -1,5 +1,5 @@ from datetime import date, datetime, time -from typing import Any, Callable, Generator, Iterable, Iterator, List, Optional, Protocol, Text, Tuple, Type, TypeVar, Union +from typing import Any, Callable, Generator, Iterable, Iterator, List, Protocol, Text, Tuple, Type, TypeVar, Union _T = TypeVar("_T") diff --git a/stdlib/@python2/sre_parse.pyi b/stdlib/@python2/sre_parse.pyi index d02af97122f0..ce16a45d6dfd 100644 --- a/stdlib/@python2/sre_parse.pyi +++ b/stdlib/@python2/sre_parse.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, List, Match, Optional, Pattern as _Pattern, Set, Tuple, Union +from typing import Any, Dict, Iterable, List, Match, Pattern as _Pattern, Set, Tuple, Union SPECIAL_CHARS: str REPEAT_CHARS: str diff --git a/stdlib/@python2/ssl.pyi b/stdlib/@python2/ssl.pyi index 5fb9864c59ca..6c2f8971d7ff 100644 --- a/stdlib/@python2/ssl.pyi +++ b/stdlib/@python2/ssl.pyi @@ -1,7 +1,7 @@ import socket import sys from _typeshed import StrPath -from typing import Any, Callable, ClassVar, Dict, Iterable, List, NamedTuple, Optional, Set, Text, Tuple, Union, overload +from typing import Any, Callable, ClassVar, Dict, Iterable, List, NamedTuple, Set, Text, Tuple, Union, overload from typing_extensions import Literal _PCTRTT = Tuple[Tuple[str, str], ...] diff --git a/stdlib/@python2/stringold.pyi b/stdlib/@python2/stringold.pyi index adb09eb2b789..d221547f1c07 100644 --- a/stdlib/@python2/stringold.pyi +++ b/stdlib/@python2/stringold.pyi @@ -1,4 +1,4 @@ -from typing import AnyStr, Iterable, List, Optional +from typing import AnyStr, Iterable, List whitespace: str lowercase: str diff --git a/stdlib/@python2/sunau.pyi b/stdlib/@python2/sunau.pyi index 24034b0183e9..eaeeceff05a3 100644 --- a/stdlib/@python2/sunau.pyi +++ b/stdlib/@python2/sunau.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, NoReturn, Optional, Text, Tuple, Union +from typing import IO, Any, NoReturn, Text, Tuple, Union _File = Text | IO[bytes] diff --git a/stdlib/@python2/symtable.pyi b/stdlib/@python2/symtable.pyi index 96a56b727902..bd3f25c7cb63 100644 --- a/stdlib/@python2/symtable.pyi +++ b/stdlib/@python2/symtable.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Sequence, Text, Tuple +from typing import Any, List, Sequence, Text, Tuple def symtable(code: Text, filename: Text, compile_type: Text) -> SymbolTable: ... diff --git a/stdlib/@python2/sys.pyi b/stdlib/@python2/sys.pyi index 93170da49388..493a9d58acc1 100644 --- a/stdlib/@python2/sys.pyi +++ b/stdlib/@python2/sys.pyi @@ -1,5 +1,5 @@ from types import ClassType, FrameType, TracebackType -from typing import IO, Any, Callable, Dict, List, NoReturn, Optional, Text, Tuple, Type, Union +from typing import IO, Any, Callable, Dict, List, NoReturn, Text, Tuple, Type, Union # The following type alias are stub-only and do not exist during runtime _ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType] diff --git a/stdlib/@python2/sysconfig.pyi b/stdlib/@python2/sysconfig.pyi index dcecf4ffd80e..9b7951e2348b 100644 --- a/stdlib/@python2/sysconfig.pyi +++ b/stdlib/@python2/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/@python2/tempfile.pyi b/stdlib/@python2/tempfile.pyi index 40774d904d67..7d1e6093b208 100644 --- a/stdlib/@python2/tempfile.pyi +++ b/stdlib/@python2/tempfile.pyi @@ -1,6 +1,6 @@ from random import Random from thread import LockType -from typing import IO, Any, AnyStr, Iterable, Iterator, List, Optional, Text, Tuple, Union, overload +from typing import IO, Any, AnyStr, Iterable, Iterator, List, Text, Tuple, Union, overload TMP_MAX: int tempdir: str diff --git a/stdlib/@python2/threading.pyi b/stdlib/@python2/threading.pyi index ab062bf200cc..6823a8d477fa 100644 --- a/stdlib/@python2/threading.pyi +++ b/stdlib/@python2/threading.pyi @@ -1,5 +1,5 @@ from types import FrameType, TracebackType -from typing import Any, Callable, Iterable, List, Mapping, Optional, Text, Type, TypeVar, Union +from typing import Any, Callable, Iterable, List, Mapping, Text, Type, TypeVar, Union # TODO recursive type _TF = Callable[[FrameType, str, Any], Callable[..., Any] | None] diff --git a/stdlib/@python2/time.pyi b/stdlib/@python2/time.pyi index 7563a9bb63d7..6de890db19a3 100644 --- a/stdlib/@python2/time.pyi +++ b/stdlib/@python2/time.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, NamedTuple, Optional, Tuple, Union +from typing import Any, NamedTuple, Tuple, Union _TimeTuple = Tuple[int, int, int, int, int, int, int, int, int] diff --git a/stdlib/@python2/traceback.pyi b/stdlib/@python2/traceback.pyi index 55c1f953c884..557b66915154 100644 --- a/stdlib/@python2/traceback.pyi +++ b/stdlib/@python2/traceback.pyi @@ -1,5 +1,5 @@ from types import FrameType, TracebackType -from typing import IO, List, Optional, Tuple, Type +from typing import IO, List, Tuple, Type _PT = Tuple[str, int, str, str | None] diff --git a/stdlib/@python2/turtle.pyi b/stdlib/@python2/turtle.pyi index 5e9e7444355a..b13e70c3ac9d 100644 --- a/stdlib/@python2/turtle.pyi +++ b/stdlib/@python2/turtle.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, List, Optional, Sequence, Text, Tuple, TypeVar, Union, overload +from typing import Any, Callable, Dict, List, Sequence, Text, Tuple, TypeVar, Union, overload # TODO: Replace these aliases once we have Python 2 stubs for the Tkinter module. Canvas = Any diff --git a/stdlib/@python2/types.pyi b/stdlib/@python2/types.pyi index b1a48e63479b..1bee9e2f5715 100644 --- a/stdlib/@python2/types.pyi +++ b/stdlib/@python2/types.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, Iterable, Iterator, List, Tuple, Type, TypeVar, Union, overload _T = TypeVar("_T") diff --git a/stdlib/@python2/urllib2.pyi b/stdlib/@python2/urllib2.pyi index 8822d4512e5b..baf8b5528765 100644 --- a/stdlib/@python2/urllib2.pyi +++ b/stdlib/@python2/urllib2.pyi @@ -1,6 +1,6 @@ import ssl from httplib import HTTPConnectionProtocol, HTTPResponse -from typing import Any, AnyStr, Callable, Dict, List, Mapping, Optional, Sequence, Text, Tuple, Type, Union +from typing import Any, AnyStr, Callable, Dict, List, Mapping, Sequence, Text, Tuple, Type, Union from urllib import addinfourl _string = str | unicode diff --git a/stdlib/@python2/urlparse.pyi b/stdlib/@python2/urlparse.pyi index 17f79e17183b..ae85c4a3d4b9 100644 --- a/stdlib/@python2/urlparse.pyi +++ b/stdlib/@python2/urlparse.pyi @@ -1,4 +1,4 @@ -from typing import AnyStr, Dict, List, NamedTuple, Optional, Sequence, Tuple, Union, overload +from typing import AnyStr, Dict, List, NamedTuple, Sequence, Tuple, Union, overload _String = str | unicode diff --git a/stdlib/@python2/uu.pyi b/stdlib/@python2/uu.pyi index 06c6e0a9943f..061375b4fa87 100644 --- a/stdlib/@python2/uu.pyi +++ b/stdlib/@python2/uu.pyi @@ -1,4 +1,4 @@ -from typing import BinaryIO, Optional, Text, Union +from typing import BinaryIO, Text, Union _File = Text | BinaryIO diff --git a/stdlib/@python2/uuid.pyi b/stdlib/@python2/uuid.pyi index 91477e4266f3..2c8a9fb1c097 100644 --- a/stdlib/@python2/uuid.pyi +++ b/stdlib/@python2/uuid.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional, Text, Tuple +from typing import Any, Text, Tuple # Because UUID has properties called int and bytes we need to rename these temporarily. _Int = int diff --git a/stdlib/@python2/warnings.pyi b/stdlib/@python2/warnings.pyi index 37ce72c50726..405d563fed0d 100644 --- a/stdlib/@python2/warnings.pyi +++ b/stdlib/@python2/warnings.pyi @@ -1,5 +1,5 @@ from types import ModuleType, TracebackType -from typing import List, Optional, TextIO, Type, Union, overload +from typing import List, TextIO, Type, Union, overload from typing_extensions import Literal from _warnings import warn as warn, warn_explicit as warn_explicit diff --git a/stdlib/@python2/wave.pyi b/stdlib/@python2/wave.pyi index 1660458012db..e9cbc529f8ba 100644 --- a/stdlib/@python2/wave.pyi +++ b/stdlib/@python2/wave.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, BinaryIO, NoReturn, Optional, Text, Tuple, Union +from typing import IO, Any, BinaryIO, NoReturn, Text, Tuple, Union _File = Text | IO[bytes] diff --git a/stdlib/@python2/wsgiref/handlers.pyi b/stdlib/@python2/wsgiref/handlers.pyi index 6791624103df..763472c4ad8b 100644 --- a/stdlib/@python2/wsgiref/handlers.pyi +++ b/stdlib/@python2/wsgiref/handlers.pyi @@ -1,6 +1,6 @@ from abc import abstractmethod from types import TracebackType -from typing import IO, Callable, List, MutableMapping, Optional, Text, Tuple, Type +from typing import IO, Callable, List, MutableMapping, Text, Tuple, Type from .headers import Headers from .types import ErrorStream, InputStream, StartResponse, WSGIApplication, WSGIEnvironment diff --git a/stdlib/@python2/wsgiref/headers.pyi b/stdlib/@python2/wsgiref/headers.pyi index f9382c4c4e2d..08061fee7664 100644 --- a/stdlib/@python2/wsgiref/headers.pyi +++ b/stdlib/@python2/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/@python2/wsgiref/simple_server.pyi b/stdlib/@python2/wsgiref/simple_server.pyi index 3eb240042bb8..a74a26fed935 100644 --- a/stdlib/@python2/wsgiref/simple_server.pyi +++ b/stdlib/@python2/wsgiref/simple_server.pyi @@ -1,5 +1,5 @@ from BaseHTTPServer 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/@python2/wsgiref/util.pyi b/stdlib/@python2/wsgiref/util.pyi index aa2e8dbb3c51..c8e045a8cb8e 100644 --- a/stdlib/@python2/wsgiref/util.pyi +++ b/stdlib/@python2/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/@python2/wsgiref/validate.pyi b/stdlib/@python2/wsgiref/validate.pyi index 1d2c4b2869a5..b3e629b02d71 100644 --- a/stdlib/@python2/wsgiref/validate.pyi +++ b/stdlib/@python2/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/@python2/xml/dom/domreg.pyi b/stdlib/@python2/xml/dom/domreg.pyi index 2bd58e5e3d2a..bc96f51c887d 100644 --- a/stdlib/@python2/xml/dom/domreg.pyi +++ b/stdlib/@python2/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, Union well_known_implementations: Dict[str, str] registered: Dict[str, Callable[[], DOMImplementation]] diff --git a/stdlib/@python2/xml/dom/minicompat.pyi b/stdlib/@python2/xml/dom/minicompat.pyi index 3dcfe095ea93..e9b0395ab50d 100644 --- a/stdlib/@python2/xml/dom/minicompat.pyi +++ b/stdlib/@python2/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/@python2/xml/dom/minidom.pyi b/stdlib/@python2/xml/dom/minidom.pyi index 91881f587336..8ecce2ae578a 100644 --- a/stdlib/@python2/xml/dom/minidom.pyi +++ b/stdlib/@python2/xml/dom/minidom.pyi @@ -1,5 +1,5 @@ import xml.dom -from typing import IO, Any, Optional, Text as _Text, TypeVar, Union +from typing import IO, Any, Text as _Text, TypeVar, Union from xml.dom.xmlbuilder import DocumentLS, DOMImplementationLS from xml.sax.xmlreader import XMLReader diff --git a/stdlib/@python2/xml/etree/ElementInclude.pyi b/stdlib/@python2/xml/etree/ElementInclude.pyi index 0956b978c47e..5e4aeda72b4c 100644 --- a/stdlib/@python2/xml/etree/ElementInclude.pyi +++ b/stdlib/@python2/xml/etree/ElementInclude.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Optional, Union +from typing import Callable, Union from xml.etree.ElementTree import Element XINCLUDE: str diff --git a/stdlib/@python2/xml/etree/ElementPath.pyi b/stdlib/@python2/xml/etree/ElementPath.pyi index 076cb867be70..66e1139ee161 100644 --- a/stdlib/@python2/xml/etree/ElementPath.pyi +++ b/stdlib/@python2/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, Union from xml.etree.ElementTree import Element xpath_tokenizer_re: Pattern[str] diff --git a/stdlib/@python2/xml/sax/__init__.pyi b/stdlib/@python2/xml/sax/__init__.pyi index c5284f0c9054..9ad78389f292 100644 --- a/stdlib/@python2/xml/sax/__init__.pyi +++ b/stdlib/@python2/xml/sax/__init__.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, List, NoReturn, Optional, Text, Union +from typing import IO, Any, List, NoReturn, Text, Union from xml.sax.handler import ContentHandler, ErrorHandler from xml.sax.xmlreader import Locator, XMLReader diff --git a/stdlib/@python2/xml/sax/xmlreader.pyi b/stdlib/@python2/xml/sax/xmlreader.pyi index 1cba860017a5..8afc566b16a1 100644 --- a/stdlib/@python2/xml/sax/xmlreader.pyi +++ b/stdlib/@python2/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/_ast.pyi b/stdlib/_ast.pyi index eb6dfa061539..21b7e3a862f8 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 PyCF_ONLY_AST: int if sys.version_info >= (3, 8): diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index 1fb3e5fb6add..0c66d6927822 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/_csv.pyi b/stdlib/_csv.pyi index 0bd901c2e912..0a1c2b3257a8 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 6db5a5d35faf..dc335c8fe479 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 = 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/_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..159ce1523e0a 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, Union if sys.platform == "win32": diff --git a/stdlib/_osx_support.pyi b/stdlib/_osx_support.pyi index 0362ebef3a2f..b6d1b9687b25 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, Union _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 9483413bdbf5..c45efb89b715 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/_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/_weakrefset.pyi b/stdlib/_weakrefset.pyi index 82cae5660de5..5be2191f5a09 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, Union if sys.version_info >= (3, 9): from types import GenericAlias diff --git a/stdlib/_winapi.pyi b/stdlib/_winapi.pyi index d6351ca2ebb2..e650eb58e008 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, Union, overload from typing_extensions import Literal CREATE_NEW_CONSOLE: int diff --git a/stdlib/aifc.pyi b/stdlib/aifc.pyi index 475d9058e087..e8f882cdd9e0 100644 --- a/stdlib/aifc.pyi +++ b/stdlib/aifc.pyi @@ -1,6 +1,6 @@ import sys 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/ast.pyi b/stdlib/ast.pyi index 0f4e79db7ca7..6867f05262c5 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, Union, overload from typing_extensions import Literal from _ast import * # type: ignore diff --git a/stdlib/asyncio/base_subprocess.pyi b/stdlib/asyncio/base_subprocess.pyi index a731601de7be..7c0db4a40fa0 100644 --- a/stdlib/asyncio/base_subprocess.pyi +++ b/stdlib/asyncio/base_subprocess.pyi @@ -1,5 +1,5 @@ import subprocess -from typing import IO, Any, Callable, Deque, Dict, List, Optional, Sequence, Tuple, Union +from typing import IO, Any, Callable, Deque, Dict, List, Sequence, Tuple, Union from . import events, futures, protocols, transports 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/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..c007cbd6ecc6 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, Union from .events import AbstractEventLoop diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index af605f9a93e6..6e75702dc48b 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, Union 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/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/staggered.pyi b/stdlib/asyncio/staggered.pyi index 3a70fbf88b46..ecf1c670b3ce 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 a6384f7ae80a..ecc51759c45f 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, Tuple, Union from . import events, protocols, transports diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index 4dbab184b876..86f36460aed4 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -2,7 +2,7 @@ import concurrent.futures import sys from collections.abc import Awaitable, Generator, Iterable, Iterator from types import FrameType -from typing import Any, Generic, List, Optional, Set, TextIO, Tuple, TypeVar, Union, overload +from typing import Any, Generic, List, Set, TextIO, Tuple, TypeVar, Union, overload from typing_extensions import Literal from .events import AbstractEventLoop 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 2f2f4c249690..07159262952d 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 7cbbfa286e86..1ec04d94ada8 100644 --- a/stdlib/asyncio/unix_events.pyi +++ b/stdlib/asyncio/unix_events.pyi @@ -1,7 +1,7 @@ import sys import types from socket import socket -from typing import Any, Callable, Optional, Type, TypeVar +from typing import Any, Callable, Type, TypeVar from .events import AbstractEventLoop, AbstractServer, BaseDefaultEventLoopPolicy, _ProtocolFactory, _SSLContext from .selector_events import BaseSelectorEventLoop 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 044b3ab2e57d..f81ec678d7dd 100644 --- a/stdlib/asyncio/windows_utils.pyi +++ b/stdlib/asyncio/windows_utils.pyi @@ -1,6 +1,6 @@ import sys 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..291c47dea855 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, Union, overload # cyclic dependence with asynchat _maptype = Dict[int, Any] diff --git a/stdlib/base64.pyi b/stdlib/base64.pyi index 0e2dda19756e..d9777497932e 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, Union 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 bf8f3c583260..c43b27b09f95 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, Union _T = TypeVar("_T") _TraceDispatch = Callable[[FrameType, str, Any], Any] # TODO: Recursive type diff --git a/stdlib/bz2.pyi b/stdlib/bz2.pyi index d93500f2c510..21180a02d5f6 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, 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, Union, 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 45cb98eec1c1..fcc6c20f2fa1 100644 --- a/stdlib/cProfile.pyi +++ b/stdlib/cProfile.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import StrOrBytesPath from types import CodeType -from typing import Any, Callable, Dict, Optional, Tuple, TypeVar, Union +from typing import Any, Callable, Dict, Tuple, TypeVar, Union def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index adaeddd3a007..3276c9cc48c4 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, Sequence, Tuple, Union _LocaleType = Tuple[str | None, str | None] diff --git a/stdlib/cgi.pyi b/stdlib/cgi.pyi index 778cf632e1f0..20fa28eff7d8 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, Union _T = TypeVar("_T", bound=FieldStorage) diff --git a/stdlib/cgitb.pyi b/stdlib/cgitb.pyi index 3d4e6f654995..f9f0de7bbaf5 100644 --- a/stdlib/cgitb.pyi +++ b/stdlib/cgitb.pyi @@ -1,6 +1,6 @@ from _typeshed import StrOrBytesPath from types import FrameType, TracebackType -from typing import IO, Any, Callable, Dict, List, Optional, Tuple, Type +from typing import IO, Any, Callable, Dict, List, Tuple, Type _ExcInfo = Tuple[Type[BaseException] | None, BaseException | None, TracebackType | None] 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/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/contextvars.pyi b/stdlib/contextvars.pyi index 41c8bdbbe82c..ce06bfaca3c6 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, Union, 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..16483fb7d388 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, Union 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/dataclasses.pyi b/stdlib/dataclasses.pyi index bddf5c3744b8..b3e1be2868e0 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, Union, overload if sys.version_info >= (3, 9): from types import GenericAlias 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 24ffec6a9a9f..bf6d728a4067 100644 --- a/stdlib/dbm/__init__.pyi +++ b/stdlib/dbm/__init__.pyi @@ -1,5 +1,5 @@ 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 = str | bytes diff --git a/stdlib/dbm/dumb.pyi b/stdlib/dbm/dumb.pyi index f0bd7aa59f8a..5c5c54450528 100644 --- a/stdlib/dbm/dumb.pyi +++ b/stdlib/dbm/dumb.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Iterator, MutableMapping, Optional, Type, Union +from typing import Iterator, MutableMapping, Type, Union _KeyType = str | bytes _ValueType = str | bytes diff --git a/stdlib/dbm/gnu.pyi b/stdlib/dbm/gnu.pyi index 308d1513cf2c..70497457460f 100644 --- a/stdlib/dbm/gnu.pyi +++ b/stdlib/dbm/gnu.pyi @@ -1,5 +1,5 @@ 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 = str | bytes diff --git a/stdlib/dbm/ndbm.pyi b/stdlib/dbm/ndbm.pyi index 94e14365081f..27951992473b 100644 --- a/stdlib/dbm/ndbm.pyi +++ b/stdlib/dbm/ndbm.pyi @@ -1,5 +1,5 @@ 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 = str | bytes diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index 78e64004f2c7..cb7e78cf4e94 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 = Decimal | int _DecimalNew = Union[Decimal, float, str, Tuple[int, Sequence[int], int]] diff --git a/stdlib/dis.pyi b/stdlib/dis.pyi index 8d4b0566b74a..d87a8372b0a2 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/ccompiler.pyi b/stdlib/distutils/ccompiler.pyi index dfed71592d54..15fc46222339 100644 --- a/stdlib/distutils/ccompiler.pyi +++ b/stdlib/distutils/ccompiler.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, List, Optional, Tuple, Union +from typing import Any, Callable, List, Tuple, Union _Macro = Union[Tuple[str], Tuple[str, str | None]] diff --git a/stdlib/distutils/command/config.pyi b/stdlib/distutils/command/config.pyi index f95d8c5e41ce..89a316324acc 100644 --- a/stdlib/distutils/command/config.pyi +++ b/stdlib/distutils/command/config.pyi @@ -3,7 +3,7 @@ from distutils.ccompiler import CCompiler from distutils.core import Command as Command from distutils.errors import DistutilsExecError as DistutilsExecError from distutils.sysconfig import customize_compiler as customize_compiler -from typing import Dict, List, Optional, Pattern, Sequence, Tuple, Union +from typing import Dict, List, Pattern, Sequence, Tuple, Union LANG_EXT: Dict[str, str] diff --git a/stdlib/distutils/command/install_egg_info.pyi b/stdlib/distutils/command/install_egg_info.pyi index 40ce626e09a3..bf3d0737f244 100644 --- a/stdlib/distutils/command/install_egg_info.pyi +++ b/stdlib/distutils/command/install_egg_info.pyi @@ -1,5 +1,5 @@ from distutils.cmd import Command -from typing import ClassVar, List, Optional, Tuple +from typing import ClassVar, List, Tuple class install_egg_info(Command): description: ClassVar[str] diff --git a/stdlib/distutils/config.pyi b/stdlib/distutils/config.pyi index 29524d497acb..bcd626c81d48 100644 --- a/stdlib/distutils/config.pyi +++ b/stdlib/distutils/config.pyi @@ -1,6 +1,6 @@ from abc import abstractmethod from distutils.cmd import Command -from typing import ClassVar, List, Optional, Tuple +from typing import ClassVar, List, Tuple DEFAULT_PYPIRC: str diff --git a/stdlib/distutils/core.pyi b/stdlib/distutils/core.pyi index 997134596087..b56719ab69ee 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, Union def setup( *, diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index c8811ed7e4c1..d64a5d634c21 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, Union class DistributionMetadata: def __init__(self, path: int | StrOrBytesPath | None = ...) -> None: ... diff --git a/stdlib/distutils/fancy_getopt.pyi b/stdlib/distutils/fancy_getopt.pyi index a6b92503ecd1..879cb1aa8941 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, Tuple, Union, overload _Option = Tuple[str, str | None, str] _GR = Tuple[List[str], OptionDummy] diff --git a/stdlib/distutils/filelist.pyi b/stdlib/distutils/filelist.pyi index 24f990691896..64c13f08c38c 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, Union, 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..6343f768f019 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, Union PREFIX: str EXEC_PREFIX: str diff --git a/stdlib/distutils/util.pyi b/stdlib/distutils/util.pyi index ddf06c033fbb..c0882d1dd1cb 100644 --- a/stdlib/distutils/util.pyi +++ b/stdlib/distutils/util.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, List, Mapping, Optional, Tuple +from typing import Any, Callable, List, Mapping, Tuple def get_platform() -> str: ... def convert_path(pathname: str) -> str: ... diff --git a/stdlib/email/_header_value_parser.pyi b/stdlib/email/_header_value_parser.pyi index 28427c25d1eb..c9c8663f7925 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, Union 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/generator.pyi b/stdlib/email/generator.pyi index cd0b2285a954..e36274c75f38 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..a5efb114876c 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, Union class Header: def __init__( diff --git a/stdlib/email/headerregistry.pyi b/stdlib/email/headerregistry.pyi index 3f4804a61d5f..7a7f94f91baf 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, Union 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/message.pyi b/stdlib/email/message.pyi index d58c25a5c387..1bf855f5e44d 100644 --- a/stdlib/email/message.pyi +++ b/stdlib/email/message.pyi @@ -2,7 +2,7 @@ from email.charset import Charset from email.contentmanager import ContentManager from email.errors import MessageDefect from email.policy import Policy -from typing import Any, Generator, Iterator, List, Optional, Sequence, Tuple, TypeVar, Union +from typing import Any, Generator, Iterator, List, Sequence, Tuple, TypeVar, Union _T = TypeVar("_T") diff --git a/stdlib/email/mime/application.pyi b/stdlib/email/mime/application.pyi index 6cb08fa18c95..ab08a1ae146c 100644 --- a/stdlib/email/mime/application.pyi +++ b/stdlib/email/mime/application.pyi @@ -1,6 +1,6 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Callable, Optional, Tuple, Union +from typing import Callable, Tuple, Union _ParamsType = Union[str, None, Tuple[str, str | None, str]] diff --git a/stdlib/email/mime/audio.pyi b/stdlib/email/mime/audio.pyi index a8a5c3a04388..b8f3adf3488a 100644 --- a/stdlib/email/mime/audio.pyi +++ b/stdlib/email/mime/audio.pyi @@ -1,6 +1,6 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Callable, Optional, Tuple, Union +from typing import Callable, Tuple, Union _ParamsType = Union[str, None, Tuple[str, str | None, str]] diff --git a/stdlib/email/mime/image.pyi b/stdlib/email/mime/image.pyi index 4e3595ed9fbe..546b24168b84 100644 --- a/stdlib/email/mime/image.pyi +++ b/stdlib/email/mime/image.pyi @@ -1,6 +1,6 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Callable, Optional, Tuple, Union +from typing import Callable, Tuple, Union _ParamsType = Union[str, None, Tuple[str, str | None, str]] diff --git a/stdlib/email/policy.pyi b/stdlib/email/policy.pyi index d6284e919fd6..350383615fb4 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, Union class Policy: max_line_length: int | None diff --git a/stdlib/email/utils.pyi b/stdlib/email/utils.pyi index b5b35f914da4..d2afa0ea6005 100644 --- a/stdlib/email/utils.pyi +++ b/stdlib/email/utils.pyi @@ -1,7 +1,7 @@ import datetime import sys from email.charset import Charset -from typing import List, Optional, Tuple, Union, overload +from typing import List, Tuple, Union, overload _ParamType = Union[str, Tuple[str | None, str | None, str]] _PDTZ = Tuple[int, int, int, int, int, int, int, int, int, int | None] diff --git a/stdlib/encodings/__init__.pyi b/stdlib/encodings/__init__.pyi index dd3cf28e2772..bc62e75d98f9 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, Union class CodecRegistryError(LookupError, SystemError): ... diff --git a/stdlib/filecmp.pyi b/stdlib/filecmp.pyi index 5438d0d5e47d..2a4ad5f80908 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, Union 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/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/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..668fa29147f2 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, Union def glob0(dirname: AnyStr, pattern: AnyStr) -> List[AnyStr]: ... def glob1(dirname: AnyStr, pattern: AnyStr) -> List[AnyStr]: ... 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..eee5ebedd976 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, Union, 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/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/cookiejar.pyi b/stdlib/http/cookiejar.pyi index 35c270e6ff97..635306509ba5 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 Dict, Iterable, Iterator, Optional, Sequence, Tuple, TypeVar, Union, overload +from typing import Dict, Iterable, Iterator, Sequence, Tuple, TypeVar, Union, overload from urllib.request import Request _T = TypeVar("_T") diff --git a/stdlib/http/cookies.pyi b/stdlib/http/cookies.pyi index 89d656b0d0de..d338447e484c 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 _DataType = Union[str, Mapping[str, str | Morsel[Any]]] _T = TypeVar("_T") diff --git a/stdlib/http/server.pyi b/stdlib/http/server.pyi index 82be655eaa3e..9be344c43cbb 100644 --- a/stdlib/http/server.pyi +++ b/stdlib/http/server.pyi @@ -2,7 +2,7 @@ import email.message import socketserver import sys from _typeshed import StrPath -from typing import Any, ClassVar, Dict, List, Mapping, Optional, Sequence, Tuple, Union +from typing import Any, ClassVar, Dict, List, Mapping, Sequence, Tuple, Union class HTTPServer(socketserver.TCPServer): server_name: str diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index 83cd5194085a..e957f6db316c 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -4,7 +4,7 @@ import time 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..93ecceea9cb6 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, Union, overload class _ReadableBinary(Protocol): def tell(self) -> int: ... diff --git a/stdlib/imp.pyi b/stdlib/imp.pyi index 232502d00abd..30b10b53d3ad 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, Union 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 1371f2d669d0..8537a0782a90 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 = bytes | str diff --git a/stdlib/importlib/machinery.pyi b/stdlib/importlib/machinery.pyi index af54a7bb2bc5..14cac8f9e1b4 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, Union # 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 7bcceb81d4e6..94310f718be7 100644 --- a/stdlib/importlib/metadata.pyi +++ b/stdlib/importlib/metadata.pyi @@ -6,7 +6,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, 8): class PackageNotFoundError(ModuleNotFoundError): ... diff --git a/stdlib/importlib/util.pyi b/stdlib/importlib/util.pyi index 57254f6a004e..1774333a89e5 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/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/json/encoder.pyi b/stdlib/json/encoder.pyi index dbc366238c0f..337b3483868b 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 class JSONEncoder: item_separator: str 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/grammar.pyi b/stdlib/lib2to3/pgen2/grammar.pyi index bc96a8565aec..3ac4e5321987 100644 --- a/stdlib/lib2to3/pgen2/grammar.pyi +++ b/stdlib/lib2to3/pgen2/grammar.pyi @@ -1,5 +1,5 @@ from _typeshed import StrPath -from typing import Dict, List, Optional, Tuple, TypeVar +from typing import Dict, List, Tuple, TypeVar _P = TypeVar("_P") _Label = Tuple[int, str | None] 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/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index 68e8ff54304e..8fb6e809daf4 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -1,5 +1,5 @@ from lib2to3.pgen2.grammar import Grammar -from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, TypeVar, Union +from typing import Any, Callable, Dict, Iterator, List, Tuple, TypeVar, Union _P = TypeVar("_P") _NL = Node | Leaf diff --git a/stdlib/linecache.pyi b/stdlib/linecache.pyi index 67cf17f73c65..f11a23155730 100644 --- a/stdlib/linecache.pyi +++ b/stdlib/linecache.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional +from typing import Any, Dict, List _ModuleGlobals = Dict[str, Any] diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index b21ccf17c9c6..e5b81b3a91a9 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, Union CODESET: int D_T_FMT: int diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 35000264e1ff..bd3f353b92b0 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -5,7 +5,7 @@ from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequenc from string import Template from time import struct_time from types import FrameType, TracebackType -from typing import IO, Any, ClassVar, Optional, Pattern, Tuple, Type, Union +from typing import IO, Any, ClassVar, Pattern, Tuple, Type, Union _SysExcInfoType = Union[Tuple[Type[BaseException], BaseException, TracebackType | None], Tuple[None, None, None]] _ExcInfoType = None | bool | _SysExcInfoType | BaseException diff --git a/stdlib/lzma.pyi b/stdlib/lzma.pyi index 5158f03e50c2..c56f0c9146bf 100644 --- a/stdlib/lzma.pyi +++ b/stdlib/lzma.pyi @@ -1,6 +1,6 @@ import io from _typeshed import ReadableBuffer, StrOrBytesPath -from typing import IO, Any, Mapping, Optional, Sequence, TextIO, TypeVar, Union, overload +from typing import IO, Any, Mapping, Sequence, TextIO, TypeVar, 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/mailcap.pyi b/stdlib/mailcap.pyi index 34a863f04477..b0c538c6bbcd 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, 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 a8d512ffc195..ebb2681eb344 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import ReadableBuffer -from typing import AnyStr, ContextManager, Generic, Iterable, Iterator, Optional, Sized, Union, overload +from typing import AnyStr, ContextManager, Generic, Iterable, Iterator, Sized, Union, overload ACCESS_DEFAULT: int ACCESS_READ: int diff --git a/stdlib/msilib/__init__.pyi b/stdlib/msilib/__init__.pyi index 1b25db5b5ca9..20fc8cb19e86 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, Union from typing_extensions import Literal if sys.platform == "win32": diff --git a/stdlib/msilib/schema.pyi b/stdlib/msilib/schema.pyi index f7f71edff390..90dcd04d06f2 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/sequence.pyi b/stdlib/msilib/sequence.pyi index 25ec9aa71a87..48d1a0beed85 100644 --- a/stdlib/msilib/sequence.pyi +++ b/stdlib/msilib/sequence.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/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 8133bff63fa9..8c976a9eae4a 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 8b99181d2e50..fb8b5e87c956 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -1,7 +1,7 @@ import socket import sys import types -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 5245df301d44..fc686481f024 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 = synchronize.Lock | synchronize.RLock diff --git a/stdlib/multiprocessing/dummy/__init__.pyi b/stdlib/multiprocessing/dummy/__init__.pyi index 55fda28bf776..0fd21d4f0d29 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 0be98fc479e4..6a8a250cee41 100644 --- a/stdlib/multiprocessing/dummy/connection.pyi +++ b/stdlib/multiprocessing/dummy/connection.pyi @@ -1,6 +1,6 @@ from queue import Queue from types import TracebackType -from typing import Any, List, Optional, Tuple, Type, TypeVar, Union +from typing import Any, List, Tuple, Type, TypeVar, Union families: List[None] 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 ecc52c42a8d1..c0c1731804f2 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 4b02927be3f7..9b968d6e3d7d 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, Union, 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 b1ace8874c70..6ce8c5f6e9de 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 = Lock | RLock diff --git a/stdlib/netrc.pyi b/stdlib/netrc.pyi index b0f26e69e8c3..d6ee6bb35472 100644 --- a/stdlib/netrc.pyi +++ b/stdlib/netrc.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import Dict, List, Optional, Tuple +from typing import Dict, List, Tuple class NetrcParseError(Exception): filename: str | None diff --git a/stdlib/nntplib.pyi b/stdlib/nntplib.pyi index ba13cba1294b..b52277b961a3 100644 --- a/stdlib/nntplib.pyi +++ b/stdlib/nntplib.pyi @@ -2,7 +2,7 @@ import datetime import socket import ssl import sys -from typing import IO, Any, Dict, Iterable, List, NamedTuple, Optional, Tuple, TypeVar, Union +from typing import IO, Any, Dict, Iterable, List, NamedTuple, Tuple, TypeVar, Union _SelfT = TypeVar("_SelfT", bound=_NNTPBase) _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/pathlib.pyi b/stdlib/pathlib.pyi index 8be0db8f484d..f466e79a9d29 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -3,7 +3,7 @@ from _typeshed import OpenBinaryMode, OpenBinaryModeReading, OpenBinaryModeUpdat 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, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 9): diff --git a/stdlib/pdb.pyi b/stdlib/pdb.pyi index ae4383f361d5..bb1b5c890787 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, Union _T = TypeVar("_T") diff --git a/stdlib/pickletools.pyi b/stdlib/pickletools.pyi index f9eaa67daa73..d82e9f809889 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, Union _Reader = Callable[[IO[bytes]], Any] bytes_types: Tuple[Type[Any], ...] diff --git a/stdlib/platform.pyi b/stdlib/platform.pyi index 0f75cf82c8a0..b1f3d86aadb4 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( diff --git a/stdlib/plistlib.pyi b/stdlib/plistlib.pyi index 6551577b6d92..b69c8456bc57 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, Union 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 bb6ddbb2fb45..4179acfda730 100644 --- a/stdlib/posix.pyi +++ b/stdlib/posix.pyi @@ -1,6 +1,6 @@ import sys from os import PathLike, stat_result as stat_result -from typing import Dict, List, NamedTuple, Optional, overload +from typing import Dict, List, NamedTuple, 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 f32b58427e37..fc77ef6a216e 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/pstats.pyi b/stdlib/pstats.pyi index 012fddc7493a..4e033d367d31 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 = str | float | int _T = TypeVar("_T", bound=Stats) 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 77a342edb861..7fa94d2d5a2f 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, Union class Class: module: str 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/re.pyi b/stdlib/re.pyi index 588be2338292..de6bd5574ddb 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 dff93402437a..3e0cf66a8d8c 100644 --- a/stdlib/runpy.pyi +++ b/stdlib/runpy.pyi @@ -1,5 +1,5 @@ from types import ModuleType -from typing import Any, Dict, Optional, TypeVar +from typing import Any, Dict, TypeVar _T = TypeVar("_T") 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/select.pyi b/stdlib/select.pyi index 88891f4feb84..40bfc2107cdc 100644 --- a/stdlib/select.pyi +++ b/stdlib/select.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import FileDescriptorLike 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 68601669aae7..712648410747 100644 --- a/stdlib/selectors.pyi +++ b/stdlib/selectors.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import FileDescriptor, FileDescriptorLike 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 2ff4ae62d6ef..7e55c75ddf6e 100644 --- a/stdlib/shelve.pyi +++ b/stdlib/shelve.pyi @@ -1,5 +1,5 @@ import collections.abc -from typing import Any, Dict, Iterator, Optional, Tuple +from typing import Any, Dict, Iterator, Tuple class Shelf(collections.abc.MutableMapping[Any, Any]): def __init__( diff --git a/stdlib/shlex.pyi b/stdlib/shlex.pyi index f74e8de78276..a0e611d3e764 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, Union def split(s: str, comments: bool = ..., posix: bool = ...) -> List[str]: ... diff --git a/stdlib/signal.pyi b/stdlib/signal.pyi index fb1bafa93d64..e743d4c1875a 100644 --- a/stdlib/signal.pyi +++ b/stdlib/signal.pyi @@ -1,7 +1,7 @@ import sys from enum import IntEnum from types import FrameType -from typing import Any, Callable, Iterable, Optional, Set, Tuple, Union +from typing import Any, Callable, Iterable, Set, Tuple, Union if sys.platform != "win32": class ItimerError(IOError): ... 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..aefe08d5f071 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, Union _Address = Tuple[str, int] # (host, port) diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index 9f93b7ced373..a47d92caa249 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -2,7 +2,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..69779d7db06a 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, Union class SndHeaders(NamedTuple): filetype: str diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index 65a33f4efd00..6b28577cfd78 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -3,7 +3,7 @@ from _typeshed import ReadableBuffer, 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, Union, 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 98190fdb30ad..a4fa37265617 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -1,7 +1,7 @@ import sys import types 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 = _socket | Tuple[bytes, _socket] diff --git a/stdlib/sre_constants.pyi b/stdlib/sre_constants.pyi index 0de1dca8c16e..626312a428ec 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, Union MAGIC: int diff --git a/stdlib/sre_parse.pyi b/stdlib/sre_parse.pyi index c46bd74af87f..c3dc45c166ff 100644 --- a/stdlib/sre_parse.pyi +++ b/stdlib/sre_parse.pyi @@ -1,6 +1,6 @@ import sys from sre_constants import _NamedIntConstant as _NIC, error as _Error -from typing import Any, Dict, FrozenSet, Iterable, List, Match, Optional, Pattern as _Pattern, Tuple, Union, overload +from typing import Any, Dict, FrozenSet, Iterable, List, Match, Pattern as _Pattern, Tuple, Union, overload SPECIAL_CHARS: str REPEAT_CHARS: str diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index 407fd58df4bd..2d5a292d5b53 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..30c72244cdcc 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, Union ascii_letters: str ascii_lowercase: str diff --git a/stdlib/sunau.pyi b/stdlib/sunau.pyi index 45307f1f8e1d..d7f379f66790 100644 --- a/stdlib/sunau.pyi +++ b/stdlib/sunau.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Any, NamedTuple, NoReturn, Optional, Union +from typing import IO, Any, NamedTuple, NoReturn, Union _File = 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 dcecf4ffd80e..9b7951e2348b 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/tempfile.pyi b/stdlib/tempfile.pyi index 32db744b5d12..fb953c5248a2 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -1,7 +1,7 @@ import os import sys from types import TracebackType -from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, List, Optional, Tuple, Type, TypeVar, Union, overload +from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, List, Tuple, Type, TypeVar, Union, overload from typing_extensions import Literal if sys.version_info >= (3, 9): diff --git a/stdlib/time.pyi b/stdlib/time.pyi index cd07196e137e..367cc527df4f 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, Union _TimeTuple = Tuple[int, int, int, int, int, int, int, int, int] diff --git a/stdlib/tkinter/colorchooser.pyi b/stdlib/tkinter/colorchooser.pyi index e8050170b96d..651bed412158 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, Union 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 ab152b069248..a14fa39f32f1 100644 --- a/stdlib/tkinter/dnd.pyi +++ b/stdlib/tkinter/dnd.pyi @@ -1,6 +1,6 @@ from _typeshed.tkinter import DndSource from tkinter import Event, Misc, Tk -from typing import ClassVar, Optional +from typing import ClassVar class DndHandler: root: ClassVar[Tk | None] diff --git a/stdlib/tkinter/filedialog.pyi b/stdlib/tkinter/filedialog.pyi index e84cc88f679b..feda0746952e 100644 --- a/stdlib/tkinter/filedialog.pyi +++ b/stdlib/tkinter/filedialog.pyi @@ -1,5 +1,5 @@ from tkinter import Button, Entry, Frame, Listbox, Scrollbar, Toplevel, commondialog -from typing import Any, ClassVar, Dict, Optional, Tuple +from typing import Any, ClassVar, Dict, Tuple dialogstates: Dict[Any, Tuple[Any, Any]] diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index de84eca54e3b..8c18e24a9c1c 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -1,6 +1,6 @@ import sys import tkinter -from typing import Any, List, Optional, Tuple, TypeVar, Union, overload +from typing import Any, List, Tuple, TypeVar, 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 87aa82eff0b2..7e675b05c11a 100644 --- a/stdlib/tkinter/scrolledtext.pyi +++ b/stdlib/tkinter/scrolledtext.pyi @@ -1,5 +1,5 @@ from tkinter import Frame, Grid, Misc, Pack, Place, 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 d5d8e987a07f..36c860cda6a4 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/traceback.pyi b/stdlib/traceback.pyi index 09818a03513b..2fd1c266d185 100644 --- a/stdlib/traceback.pyi +++ b/stdlib/traceback.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import SupportsWrite from types import FrameType, TracebackType -from typing import IO, Any, Dict, Generator, Iterable, Iterator, List, Mapping, Optional, Set, Tuple, Type +from typing import IO, Any, Dict, Generator, Iterable, Iterator, List, Mapping, Set, Tuple, Type _PT = Tuple[str, int, str, str | None] diff --git a/stdlib/tracemalloc.pyi b/stdlib/tracemalloc.pyi index 53cb4b52984b..35af91048960 100644 --- a/stdlib/tracemalloc.pyi +++ b/stdlib/tracemalloc.pyi @@ -1,5 +1,5 @@ import sys -from typing import List, Optional, Sequence, Tuple, Union, overload +from typing import List, Sequence, Tuple, Union, overload from _tracemalloc import * diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index 805bb424a064..d63a84f62bd7 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/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..57fb7557a5a8 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, Union 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 ee57f4a18a55..2f9a78d6e56b 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, Union, overload _F = TypeVar("_F", bound=Callable[..., Any]) _T = TypeVar("_T") diff --git a/stdlib/unittest/result.pyi b/stdlib/unittest/result.pyi index c55fc6fd969d..bc4959f0304d 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..4ad97c0ba58a 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, Union _ResultClassType = Callable[[TextIO, bool, int], unittest.result.TestResult] diff --git a/stdlib/urllib/error.pyi b/stdlib/urllib/error.pyi index 88a8cd781843..deefebb352e1 100644 --- a/stdlib/urllib/error.pyi +++ b/stdlib/urllib/error.pyi @@ -1,5 +1,5 @@ from email.message import Message -from typing import IO, Mapping, Optional, Tuple, Union +from typing import IO, Mapping, Tuple, Union from urllib.response import addinfourl # Stubs for urllib.error diff --git a/stdlib/urllib/parse.pyi b/stdlib/urllib/parse.pyi index 2a095ba35511..4b306359d92f 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/response.pyi b/stdlib/urllib/response.pyi index 7c5314b808fd..ea4b9c6b319c 100644 --- a/stdlib/urllib/response.pyi +++ b/stdlib/urllib/response.pyi @@ -1,6 +1,6 @@ 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 58f285f3d27c..fd7e83dc0f6a 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 = 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/warnings.pyi b/stdlib/warnings.pyi index e40a17746b45..d55db01ec559 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, Union, 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 c25d5de00718..645d28331054 100644 --- a/stdlib/wave.pyi +++ b/stdlib/wave.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Any, BinaryIO, NamedTuple, NoReturn, Optional, Union +from typing import IO, Any, BinaryIO, NamedTuple, NoReturn, Union _File = str | IO[bytes] diff --git a/stdlib/winreg.pyi b/stdlib/winreg.pyi index c0a750cdbf78..5e7f63c9d101 100644 --- a/stdlib/winreg.pyi +++ b/stdlib/winreg.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Any, Optional, Tuple, Type, Union +from typing import Any, Tuple, Type, Union _KeyType = HKEYType | int diff --git a/stdlib/wsgiref/handlers.pyi b/stdlib/wsgiref/handlers.pyi index df77a0642ce2..3c3ee6798675 100644 --- a/stdlib/wsgiref/handlers.pyi +++ b/stdlib/wsgiref/handlers.pyi @@ -1,6 +1,6 @@ from abc import abstractmethod from types import TracebackType -from typing import IO, Callable, Dict, List, MutableMapping, Optional, Tuple, Type +from typing import IO, Callable, Dict, List, MutableMapping, Tuple, Type from .headers import Headers from .types import ErrorStream, InputStream, StartResponse, WSGIApplication, WSGIEnvironment 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 2bd58e5e3d2a..bc96f51c887d 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, Union 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 7fa026f65535..138ed6369e1d 100644 --- a/stdlib/xml/dom/minidom.pyi +++ b/stdlib/xml/dom/minidom.pyi @@ -1,6 +1,6 @@ import sys import xml.dom -from typing import IO, Any, Optional, TypeVar, Union +from typing import IO, Any, TypeVar, Union from xml.dom.xmlbuilder import DocumentLS, DOMImplementationLS from xml.sax.xmlreader import XMLReader diff --git a/stdlib/xml/etree/ElementInclude.pyi b/stdlib/xml/etree/ElementInclude.pyi index 02bb217ecead..20cec64556ae 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, Union from xml.etree.ElementTree import Element XINCLUDE: str diff --git a/stdlib/xml/etree/ElementPath.pyi b/stdlib/xml/etree/ElementPath.pyi index 076cb867be70..66e1139ee161 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, Union from xml.etree.ElementTree import Element xpath_tokenizer_re: Pattern[str] diff --git a/stdlib/xml/sax/__init__.pyi b/stdlib/xml/sax/__init__.pyi index e778f309bb37..d8b83df8dd9e 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, Union from xml.sax.handler import ContentHandler, ErrorHandler from xml.sax.xmlreader import Locator, XMLReader 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 c807fdaab768..22854d97f60d 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -6,7 +6,7 @@ from _typeshed import 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/zipimport.pyi b/stdlib/zipimport.pyi index 323f23476dc1..593d2b047f3a 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, Union if sys.version_info >= (3, 7): from importlib.abc import ResourceReader diff --git a/stdlib/zlib.pyi b/stdlib/zlib.pyi index 57f8f06412f6..052537b8f7a1 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, Union 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") From 7ae0a9e02af5d8671443979dcac87558bd6345af Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:42:25 -0700 Subject: [PATCH 12/16] for x in $(rg '\bUnion\b' -c | grep stdlib | pyp 'x.split(":")[0] if x.endswith(":1") else None'); do fastmod -g $x --accept-all '\s*from typing import Union$' ''; done --- stdlib/@python2/macurl2path.pyi | 2 +- stdlib/@python2/zipimport.pyi | 1 - stdlib/asynchat.pyi | 1 - stdlib/binascii.pyi | 1 - stdlib/macurl2path.pyi | 2 +- 5 files changed, 2 insertions(+), 5 deletions(-) diff --git a/stdlib/@python2/macurl2path.pyi b/stdlib/@python2/macurl2path.pyi index 532d464d81ab..053ea4f7541e 100644 --- a/stdlib/@python2/macurl2path.pyi +++ b/stdlib/@python2/macurl2path.pyi @@ -1,4 +1,4 @@ -from typing import Union + def url2pathname(pathname: str) -> str: ... def pathname2url(pathname: str) -> str: ... diff --git a/stdlib/@python2/zipimport.pyi b/stdlib/@python2/zipimport.pyi index 04f06b07ea6b..bcefd6859059 100644 --- a/stdlib/@python2/zipimport.pyi +++ b/stdlib/@python2/zipimport.pyi @@ -1,5 +1,4 @@ from types import CodeType, ModuleType -from typing import Union class ZipImportError(ImportError): ... diff --git a/stdlib/asynchat.pyi b/stdlib/asynchat.pyi index 3d383a85d04d..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 Union class simple_producer: def __init__(self, data: bytes, buffer_size: int = ...) -> None: ... 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/macurl2path.pyi b/stdlib/macurl2path.pyi index 532d464d81ab..053ea4f7541e 100644 --- a/stdlib/macurl2path.pyi +++ b/stdlib/macurl2path.pyi @@ -1,4 +1,4 @@ -from typing import Union + def url2pathname(pathname: str) -> str: ... def pathname2url(pathname: str) -> str: ... From 67f8d44946f93ad4d68df93f021c6f363907e56e Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:42:29 -0700 Subject: [PATCH 13/16] for x in $(rg '\bUnion\b' -c | grep stdlib | pyp 'x.split(":")[0] if x.endswith(":1") else None'); do fastmod -g $x --accept-all '^\s+Union,$' ''; done --- stdlib/@python2/UserDict.pyi | 2 +- stdlib/@python2/typing_extensions.pyi | 2 +- stdlib/@python2/xml/etree/ElementTree.pyi | 2 +- stdlib/configparser.pyi | 2 +- stdlib/functools.pyi | 2 +- stdlib/multiprocessing/managers.pyi | 2 +- stdlib/sys.pyi | 2 +- stdlib/tokenize.pyi | 2 +- stdlib/typing_extensions.pyi | 2 +- stdlib/xml/etree/ElementTree.pyi | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/stdlib/@python2/UserDict.pyi b/stdlib/@python2/UserDict.pyi index 435f23728f92..fea2d391bb82 100644 --- a/stdlib/@python2/UserDict.pyi +++ b/stdlib/@python2/UserDict.pyi @@ -11,7 +11,7 @@ from typing import ( Sized, Tuple, TypeVar, - Union, + overload, ) diff --git a/stdlib/@python2/typing_extensions.pyi b/stdlib/@python2/typing_extensions.pyi index b0593368a192..12f5cbd8f3c4 100644 --- a/stdlib/@python2/typing_extensions.pyi +++ b/stdlib/@python2/typing_extensions.pyi @@ -19,7 +19,7 @@ from typing import ( Tuple, Type as Type, TypeVar, - Union, + ValuesView, _Alias, overload as overload, diff --git a/stdlib/@python2/xml/etree/ElementTree.pyi b/stdlib/@python2/xml/etree/ElementTree.pyi index be97f52059c5..a13775b29d39 100644 --- a/stdlib/@python2/xml/etree/ElementTree.pyi +++ b/stdlib/@python2/xml/etree/ElementTree.pyi @@ -16,7 +16,7 @@ from typing import ( Text, Tuple, TypeVar, - Union, + overload, ) diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index a94a1ab09272..6e0ecb50a1c5 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -17,7 +17,7 @@ from typing import ( Tuple, Type, TypeVar, - Union, + overload, ) from typing_extensions import Literal diff --git a/stdlib/functools.pyi b/stdlib/functools.pyi index 141c31965c52..30e60ab14b38 100644 --- a/stdlib/functools.pyi +++ b/stdlib/functools.pyi @@ -16,7 +16,7 @@ from typing import ( Tuple, Type, TypeVar, - Union, + overload, ) diff --git a/stdlib/multiprocessing/managers.pyi b/stdlib/multiprocessing/managers.pyi index b66ef2c17ccd..e27caac71415 100644 --- a/stdlib/multiprocessing/managers.pyi +++ b/stdlib/multiprocessing/managers.pyi @@ -17,7 +17,7 @@ from typing import ( Sequence, Tuple, TypeVar, - Union, + ) from .connection import Connection diff --git a/stdlib/sys.pyi b/stdlib/sys.pyi index 7e9f64fdcb2e..fcff953b9fe5 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -18,7 +18,7 @@ from typing import ( Tuple, Type, TypeVar, - Union, + overload, ) diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index ee6c23870844..739f31d4ae13 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -16,7 +16,7 @@ from typing import ( Set, TextIO, Tuple, - Union, + ) if sys.version_info < (3, 7): diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index f43f6b362656..e37f33b6c147 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -27,7 +27,7 @@ from typing import ( Tuple, Type as Type, TypeVar, - Union, + ValuesView, _Alias, overload as overload, diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index 1aeb229f4dd4..26d50b6aca07 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -16,7 +16,7 @@ from typing import ( Sequence, Tuple, TypeVar, - Union, + overload, ) from typing_extensions import Literal From 5a904119ff670a313912bbfd9eec51f24cd95c5e Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:42:33 -0700 Subject: [PATCH 14/16] for x in $(rg '\bUnion\b' -c | grep stdlib | pyp 'x.split(":")[0] if x.endswith(":1") else None'); do fastmod -g $x --accept-all '(from typing import )Union, (.*)' '$1$2'; done --- stdlib/@python2/winsound.pyi | 2 +- stdlib/winsound.pyi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/@python2/winsound.pyi b/stdlib/@python2/winsound.pyi index 78a0b643d6db..3d79f3b043f2 100644 --- a/stdlib/@python2/winsound.pyi +++ b/stdlib/@python2/winsound.pyi @@ -1,5 +1,5 @@ import sys -from typing import Union, overload +from typing import overload from typing_extensions import Literal if sys.platform == "win32": diff --git a/stdlib/winsound.pyi b/stdlib/winsound.pyi index 78a0b643d6db..3d79f3b043f2 100644 --- a/stdlib/winsound.pyi +++ b/stdlib/winsound.pyi @@ -1,5 +1,5 @@ import sys -from typing import Union, overload +from typing import overload from typing_extensions import Literal if sys.platform == "win32": From 7c43083cd9757889c12f579fbc18e1f7dc6b179a Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:42:38 -0700 Subject: [PATCH 15/16] for x in $(rg '\bUnion\b' -c | grep stdlib | pyp 'x.split(":")[0] if x.endswith(":1") else None'); do fastmod -g $x --accept-all '(from typing import.*), Union' '$1'; done --- stdlib/@python2/BaseHTTPServer.pyi | 2 +- stdlib/@python2/ConfigParser.pyi | 2 +- stdlib/@python2/SimpleHTTPServer.pyi | 2 +- stdlib/@python2/SocketServer.pyi | 2 +- stdlib/@python2/UserList.pyi | 2 +- stdlib/@python2/UserString.pyi | 2 +- stdlib/@python2/_codecs.pyi | 2 +- stdlib/@python2/_collections.pyi | 2 +- stdlib/@python2/_csv.pyi | 2 +- stdlib/@python2/_curses.pyi | 2 +- stdlib/@python2/_dummy_threading.pyi | 2 +- stdlib/@python2/_io.pyi | 2 +- stdlib/@python2/_msi.pyi | 2 +- stdlib/@python2/_osx_support.pyi | 2 +- stdlib/@python2/_socket.pyi | 2 +- stdlib/@python2/_sre.pyi | 2 +- stdlib/@python2/_weakrefset.pyi | 2 +- stdlib/@python2/_winreg.pyi | 2 +- stdlib/@python2/aifc.pyi | 2 +- stdlib/@python2/array.pyi | 2 +- stdlib/@python2/ast.pyi | 2 +- stdlib/@python2/asynchat.pyi | 2 +- stdlib/@python2/asyncore.pyi | 2 +- stdlib/@python2/base64.pyi | 2 +- stdlib/@python2/bdb.pyi | 2 +- stdlib/@python2/binhex.pyi | 2 +- stdlib/@python2/bz2.pyi | 2 +- stdlib/@python2/cProfile.pyi | 2 +- stdlib/@python2/cStringIO.pyi | 2 +- stdlib/@python2/calendar.pyi | 2 +- stdlib/@python2/cgi.pyi | 2 +- stdlib/@python2/cmath.pyi | 2 +- stdlib/@python2/curses/ascii.pyi | 2 +- stdlib/@python2/curses/textpad.pyi | 2 +- stdlib/@python2/datetime.pyi | 2 +- stdlib/@python2/dbm/__init__.pyi | 2 +- stdlib/@python2/dbm/dumb.pyi | 2 +- stdlib/@python2/dbm/gnu.pyi | 2 +- stdlib/@python2/dbm/ndbm.pyi | 2 +- stdlib/@python2/dircache.pyi | 2 +- stdlib/@python2/distutils/cmd.pyi | 2 +- stdlib/@python2/distutils/command/config.pyi | 2 +- stdlib/@python2/distutils/core.pyi | 2 +- stdlib/@python2/distutils/fancy_getopt.pyi | 2 +- stdlib/@python2/distutils/sysconfig.pyi | 2 +- stdlib/@python2/distutils/text_file.pyi | 2 +- stdlib/@python2/distutils/version.pyi | 2 +- stdlib/@python2/doctest.pyi | 2 +- stdlib/@python2/fcntl.pyi | 2 +- stdlib/@python2/filecmp.pyi | 2 +- stdlib/@python2/fileinput.pyi | 2 +- stdlib/@python2/fnmatch.pyi | 2 +- stdlib/@python2/fractions.pyi | 2 +- stdlib/@python2/genericpath.pyi | 2 +- stdlib/@python2/gettext.pyi | 2 +- stdlib/@python2/glob.pyi | 2 +- stdlib/@python2/imghdr.pyi | 2 +- stdlib/@python2/io.pyi | 2 +- stdlib/@python2/json.pyi | 2 +- stdlib/@python2/lib2to3/pytree.pyi | 2 +- stdlib/@python2/locale.pyi | 2 +- stdlib/@python2/logging/config.pyi | 2 +- stdlib/@python2/logging/handlers.pyi | 2 +- stdlib/@python2/mailcap.pyi | 2 +- stdlib/@python2/mmap.pyi | 2 +- stdlib/@python2/msilib/__init__.pyi | 2 +- stdlib/@python2/optparse.pyi | 2 +- stdlib/@python2/pdb.pyi | 2 +- stdlib/@python2/pkgutil.pyi | 2 +- stdlib/@python2/plistlib.pyi | 2 +- stdlib/@python2/popen2.pyi | 2 +- stdlib/@python2/posix.pyi | 2 +- stdlib/@python2/profile.pyi | 2 +- stdlib/@python2/pty.pyi | 2 +- stdlib/@python2/py_compile.pyi | 2 +- stdlib/@python2/pyclbr.pyi | 2 +- stdlib/@python2/re.pyi | 2 +- stdlib/@python2/rlcompleter.pyi | 2 +- stdlib/@python2/sets.pyi | 2 +- stdlib/@python2/shlex.pyi | 2 +- stdlib/@python2/smtpd.pyi | 2 +- stdlib/@python2/sndhdr.pyi | 2 +- stdlib/@python2/socket.pyi | 2 +- stdlib/@python2/sqlite3/dbapi2.pyi | 2 +- stdlib/@python2/sre_compile.pyi | 2 +- stdlib/@python2/string.pyi | 2 +- stdlib/@python2/subprocess.pyi | 2 +- stdlib/@python2/sunau.pyi | 2 +- stdlib/@python2/sys.pyi | 2 +- stdlib/@python2/telnetlib.pyi | 2 +- stdlib/@python2/tempfile.pyi | 2 +- stdlib/@python2/termios.pyi | 2 +- stdlib/@python2/threading.pyi | 2 +- stdlib/@python2/time.pyi | 2 +- stdlib/@python2/trace.pyi | 2 +- stdlib/@python2/tty.pyi | 2 +- stdlib/@python2/types.pyi | 2 +- stdlib/@python2/unicodedata.pyi | 2 +- stdlib/@python2/urllib2.pyi | 2 +- stdlib/@python2/urlparse.pyi | 2 +- stdlib/@python2/uu.pyi | 2 +- stdlib/@python2/warnings.pyi | 2 +- stdlib/@python2/wave.pyi | 2 +- stdlib/@python2/webbrowser.pyi | 2 +- stdlib/@python2/xml/dom/minidom.pyi | 2 +- stdlib/@python2/xml/etree/ElementInclude.pyi | 2 +- stdlib/@python2/xml/etree/ElementPath.pyi | 2 +- stdlib/@python2/xml/sax/__init__.pyi | 2 +- stdlib/@python2/zipfile.pyi | 2 +- stdlib/@python2/zlib.pyi | 2 +- stdlib/_codecs.pyi | 2 +- stdlib/_csv.pyi | 2 +- stdlib/_curses.pyi | 2 +- stdlib/_dummy_threading.pyi | 2 +- stdlib/_msi.pyi | 2 +- stdlib/_osx_support.pyi | 2 +- stdlib/_socket.pyi | 2 +- stdlib/_weakrefset.pyi | 2 +- stdlib/_winapi.pyi | 2 +- stdlib/aifc.pyi | 2 +- stdlib/array.pyi | 2 +- stdlib/ast.pyi | 2 +- stdlib/asyncio/base_events.pyi | 2 +- stdlib/asyncio/base_subprocess.pyi | 2 +- stdlib/asyncio/events.pyi | 2 +- stdlib/asyncio/futures.pyi | 2 +- stdlib/asyncio/locks.pyi | 2 +- stdlib/asyncio/streams.pyi | 2 +- stdlib/asyncio/subprocess.pyi | 2 +- stdlib/asyncio/tasks.pyi | 2 +- stdlib/asyncio/trsock.pyi | 2 +- stdlib/asyncore.pyi | 2 +- stdlib/base64.pyi | 2 +- stdlib/bdb.pyi | 2 +- stdlib/binhex.pyi | 2 +- stdlib/bz2.pyi | 2 +- stdlib/cProfile.pyi | 2 +- stdlib/calendar.pyi | 2 +- stdlib/cgi.pyi | 2 +- stdlib/cmath.pyi | 2 +- stdlib/contextvars.pyi | 2 +- stdlib/crypt.pyi | 2 +- stdlib/curses/ascii.pyi | 2 +- stdlib/curses/textpad.pyi | 2 +- stdlib/dbm/__init__.pyi | 2 +- stdlib/dbm/dumb.pyi | 2 +- stdlib/dbm/gnu.pyi | 2 +- stdlib/dbm/ndbm.pyi | 2 +- stdlib/distutils/cmd.pyi | 2 +- stdlib/distutils/command/config.pyi | 2 +- stdlib/distutils/core.pyi | 2 +- stdlib/distutils/dist.pyi | 2 +- stdlib/distutils/fancy_getopt.pyi | 2 +- stdlib/distutils/filelist.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/header.pyi | 2 +- stdlib/email/headerregistry.pyi | 2 +- stdlib/email/policy.pyi | 2 +- stdlib/encodings/__init__.pyi | 2 +- stdlib/enum.pyi | 2 +- stdlib/fcntl.pyi | 2 +- stdlib/filecmp.pyi | 2 +- stdlib/fileinput.pyi | 2 +- stdlib/fractions.pyi | 2 +- stdlib/genericpath.pyi | 2 +- stdlib/glob.pyi | 2 +- stdlib/gzip.pyi | 2 +- stdlib/http/cookiejar.pyi | 2 +- stdlib/http/server.pyi | 2 +- stdlib/imghdr.pyi | 2 +- stdlib/importlib/abc.pyi | 2 +- stdlib/importlib/machinery.pyi | 2 +- stdlib/importlib/resources.pyi | 2 +- stdlib/io.pyi | 2 +- stdlib/json/__init__.pyi | 2 +- stdlib/lib2to3/pytree.pyi | 2 +- stdlib/locale.pyi | 2 +- stdlib/logging/config.pyi | 2 +- stdlib/lzma.pyi | 2 +- stdlib/mailcap.pyi | 2 +- stdlib/mmap.pyi | 2 +- stdlib/msilib/__init__.pyi | 2 +- stdlib/multiprocessing/__init__.pyi | 2 +- stdlib/multiprocessing/connection.pyi | 2 +- stdlib/multiprocessing/context.pyi | 2 +- stdlib/multiprocessing/dummy/connection.pyi | 2 +- stdlib/multiprocessing/sharedctypes.pyi | 2 +- stdlib/multiprocessing/synchronize.pyi | 2 +- stdlib/pathlib.pyi | 2 +- stdlib/pdb.pyi | 2 +- stdlib/pkgutil.pyi | 2 +- stdlib/plistlib.pyi | 2 +- stdlib/profile.pyi | 2 +- stdlib/pty.pyi | 2 +- stdlib/pyclbr.pyi | 2 +- stdlib/random.pyi | 2 +- stdlib/re.pyi | 2 +- stdlib/shlex.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 | 2 +- stdlib/sunau.pyi | 2 +- stdlib/telnetlib.pyi | 2 +- stdlib/tempfile.pyi | 2 +- stdlib/termios.pyi | 2 +- stdlib/threading.pyi | 2 +- stdlib/tkinter/font.pyi | 2 +- stdlib/trace.pyi | 2 +- stdlib/tty.pyi | 2 +- stdlib/unicodedata.pyi | 2 +- stdlib/unittest/main.pyi | 2 +- stdlib/unittest/runner.pyi | 2 +- stdlib/unittest/suite.pyi | 2 +- stdlib/urllib/error.pyi | 2 +- stdlib/uu.pyi | 2 +- stdlib/warnings.pyi | 2 +- stdlib/wave.pyi | 2 +- stdlib/webbrowser.pyi | 2 +- stdlib/winreg.pyi | 2 +- stdlib/xml/dom/minidom.pyi | 2 +- stdlib/xml/etree/ElementInclude.pyi | 2 +- stdlib/xml/etree/ElementPath.pyi | 2 +- stdlib/xml/sax/__init__.pyi | 2 +- stdlib/zipapp.pyi | 2 +- stdlib/zipfile.pyi | 2 +- stdlib/zipimport.pyi | 2 +- stdlib/zlib.pyi | 2 +- 240 files changed, 240 insertions(+), 240 deletions(-) diff --git a/stdlib/@python2/BaseHTTPServer.pyi b/stdlib/@python2/BaseHTTPServer.pyi index d2683e863922..46946aa37c46 100644 --- a/stdlib/@python2/BaseHTTPServer.pyi +++ b/stdlib/@python2/BaseHTTPServer.pyi @@ -1,6 +1,6 @@ import mimetools import SocketServer -from typing import Any, BinaryIO, Callable, Mapping, Tuple, Union +from typing import Any, BinaryIO, Callable, Mapping, Tuple class HTTPServer(SocketServer.TCPServer): server_name: str diff --git a/stdlib/@python2/ConfigParser.pyi b/stdlib/@python2/ConfigParser.pyi index 804cc9a05e68..89167b3e7ec8 100644 --- a/stdlib/@python2/ConfigParser.pyi +++ b/stdlib/@python2/ConfigParser.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsNoArgReadline -from typing import IO, Any, Dict, List, Sequence, Tuple, Union +from typing import IO, Any, Dict, List, Sequence, Tuple DEFAULTSECT: str MAX_INTERPOLATION_DEPTH: int diff --git a/stdlib/@python2/SimpleHTTPServer.pyi b/stdlib/@python2/SimpleHTTPServer.pyi index 8d9a3e4e4444..758d5bd6d515 100644 --- a/stdlib/@python2/SimpleHTTPServer.pyi +++ b/stdlib/@python2/SimpleHTTPServer.pyi @@ -1,6 +1,6 @@ import BaseHTTPServer from StringIO import StringIO -from typing import IO, Any, AnyStr, Mapping, Union +from typing import IO, Any, AnyStr, Mapping class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): server_version: str diff --git a/stdlib/@python2/SocketServer.pyi b/stdlib/@python2/SocketServer.pyi index 63dae77f21b4..094fe3a228fa 100644 --- a/stdlib/@python2/SocketServer.pyi +++ b/stdlib/@python2/SocketServer.pyi @@ -1,6 +1,6 @@ import sys from socket import SocketType -from typing import Any, BinaryIO, Callable, ClassVar, List, Text, Tuple, Union +from typing import Any, BinaryIO, Callable, ClassVar, List, Text, Tuple class BaseServer: address_family: int diff --git a/stdlib/@python2/UserList.pyi b/stdlib/@python2/UserList.pyi index 91365373c7d6..be4ebce5a815 100644 --- a/stdlib/@python2/UserList.pyi +++ b/stdlib/@python2/UserList.pyi @@ -1,4 +1,4 @@ -from typing import Iterable, List, MutableSequence, TypeVar, Union, overload +from typing import Iterable, List, MutableSequence, TypeVar, overload _T = TypeVar("_T") _S = TypeVar("_S") diff --git a/stdlib/@python2/UserString.pyi b/stdlib/@python2/UserString.pyi index 4ce76550b96d..f60dbe18f9b1 100644 --- a/stdlib/@python2/UserString.pyi +++ b/stdlib/@python2/UserString.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, List, MutableSequence, Sequence, Text, Tuple, TypeVar, Union, overload +from typing import Any, Iterable, List, MutableSequence, Sequence, Text, Tuple, TypeVar, overload _UST = TypeVar("_UST", bound=UserString) _MST = TypeVar("_MST", bound=MutableString) diff --git a/stdlib/@python2/_codecs.pyi b/stdlib/@python2/_codecs.pyi index 10ac3a3cfb96..740c4e8817d7 100644 --- a/stdlib/@python2/_codecs.pyi +++ b/stdlib/@python2/_codecs.pyi @@ -1,6 +1,6 @@ import codecs import sys -from typing import Any, Callable, Dict, Text, Tuple, Union +from typing import Any, Callable, Dict, Text, Tuple # For convenience: _Handler = Callable[[Exception], Tuple[Text, int]] diff --git a/stdlib/@python2/_collections.pyi b/stdlib/@python2/_collections.pyi index a56a209dcc45..22ada07d0f24 100644 --- a/stdlib/@python2/_collections.pyi +++ b/stdlib/@python2/_collections.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Generic, Iterator, TypeVar, Union +from typing import Any, Callable, Dict, Generic, Iterator, TypeVar _K = TypeVar("_K") _V = TypeVar("_V") diff --git a/stdlib/@python2/_csv.pyi b/stdlib/@python2/_csv.pyi index 8fdb31def5a3..2c2c80d36e26 100644 --- a/stdlib/@python2/_csv.pyi +++ b/stdlib/@python2/_csv.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Iterator, List, Protocol, Sequence, Text, Type, Union +from typing import Any, Iterable, Iterator, List, Protocol, Sequence, Text, Type QUOTE_ALL: int QUOTE_MINIMAL: int diff --git a/stdlib/@python2/_curses.pyi b/stdlib/@python2/_curses.pyi index ccd01181e047..83bdef44a11d 100644 --- a/stdlib/@python2/_curses.pyi +++ b/stdlib/@python2/_curses.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, BinaryIO, Tuple, Union, overload +from typing import IO, Any, BinaryIO, Tuple, overload _chtype = str | bytes | int diff --git a/stdlib/@python2/_dummy_threading.pyi b/stdlib/@python2/_dummy_threading.pyi index 6823a8d477fa..baf26f1a981e 100644 --- a/stdlib/@python2/_dummy_threading.pyi +++ b/stdlib/@python2/_dummy_threading.pyi @@ -1,5 +1,5 @@ from types import FrameType, TracebackType -from typing import Any, Callable, Iterable, List, Mapping, Text, Type, TypeVar, Union +from typing import Any, Callable, Iterable, List, Mapping, Text, Type, TypeVar # TODO recursive type _TF = Callable[[FrameType, str, Any], Callable[..., Any] | None] diff --git a/stdlib/@python2/_io.pyi b/stdlib/@python2/_io.pyi index 3e62b942ddcd..d8ba56ebbc8c 100644 --- a/stdlib/@python2/_io.pyi +++ b/stdlib/@python2/_io.pyi @@ -1,5 +1,5 @@ from mmap import mmap -from typing import IO, Any, BinaryIO, Iterable, List, Text, TextIO, Tuple, Type, TypeVar, Union +from typing import IO, Any, BinaryIO, Iterable, List, Text, TextIO, Tuple, Type, TypeVar _bytearray_like = bytearray | mmap diff --git a/stdlib/@python2/_msi.pyi b/stdlib/@python2/_msi.pyi index 159ce1523e0a..a1030a66160f 100644 --- a/stdlib/@python2/_msi.pyi +++ b/stdlib/@python2/_msi.pyi @@ -1,5 +1,5 @@ import sys -from typing import List, Union +from typing import List if sys.platform == "win32": diff --git a/stdlib/@python2/_osx_support.pyi b/stdlib/@python2/_osx_support.pyi index b6d1b9687b25..1b890d8d8a0a 100644 --- a/stdlib/@python2/_osx_support.pyi +++ b/stdlib/@python2/_osx_support.pyi @@ -1,4 +1,4 @@ -from typing import Dict, Iterable, List, Sequence, Tuple, TypeVar, Union +from typing import Dict, Iterable, List, Sequence, Tuple, TypeVar _T = TypeVar("_T") _K = TypeVar("_K") diff --git a/stdlib/@python2/_socket.pyi b/stdlib/@python2/_socket.pyi index 6cbba020c639..c505384c5226 100644 --- a/stdlib/@python2/_socket.pyi +++ b/stdlib/@python2/_socket.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Tuple, Union, overload +from typing import IO, Any, Tuple, overload AF_APPLETALK: int AF_ASH: int diff --git a/stdlib/@python2/_sre.pyi b/stdlib/@python2/_sre.pyi index 3aed5cd89471..3bacc097451e 100644 --- a/stdlib/@python2/_sre.pyi +++ b/stdlib/@python2/_sre.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, List, Mapping, Sequence, Tuple, Union, overload +from typing import Any, Dict, Iterable, List, Mapping, Sequence, Tuple, overload CODESIZE: int MAGIC: int diff --git a/stdlib/@python2/_weakrefset.pyi b/stdlib/@python2/_weakrefset.pyi index cc2d1c66139a..f2cde7d67e52 100644 --- a/stdlib/@python2/_weakrefset.pyi +++ b/stdlib/@python2/_weakrefset.pyi @@ -1,4 +1,4 @@ -from typing import Any, Generic, Iterable, Iterator, MutableSet, TypeVar, Union +from typing import Any, Generic, Iterable, Iterator, MutableSet, TypeVar _S = TypeVar("_S") _T = TypeVar("_T") diff --git a/stdlib/@python2/_winreg.pyi b/stdlib/@python2/_winreg.pyi index 8bf9859bbe31..4968a6488d3a 100644 --- a/stdlib/@python2/_winreg.pyi +++ b/stdlib/@python2/_winreg.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Any, Tuple, Type, Union +from typing import Any, Tuple, Type _KeyType = HKEYType | int diff --git a/stdlib/@python2/aifc.pyi b/stdlib/@python2/aifc.pyi index 8ba7521bc24b..e9d7bd1b2f4f 100644 --- a/stdlib/@python2/aifc.pyi +++ b/stdlib/@python2/aifc.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, List, NamedTuple, Text, Tuple, Union, overload +from typing import IO, Any, List, NamedTuple, Text, Tuple, overload from typing_extensions import Literal class Error(Exception): ... diff --git a/stdlib/@python2/array.pyi b/stdlib/@python2/array.pyi index 727abf04d3ef..72ae36d9a9f0 100644 --- a/stdlib/@python2/array.pyi +++ b/stdlib/@python2/array.pyi @@ -1,4 +1,4 @@ -from typing import Any, BinaryIO, Generic, Iterable, List, MutableSequence, Text, Tuple, TypeVar, Union, overload +from typing import Any, BinaryIO, Generic, Iterable, List, MutableSequence, Text, Tuple, TypeVar, overload from typing_extensions import Literal _IntTypeCode = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"] diff --git a/stdlib/@python2/ast.pyi b/stdlib/@python2/ast.pyi index 103c84b98b8b..ec370e1a6c08 100644 --- a/stdlib/@python2/ast.pyi +++ b/stdlib/@python2/ast.pyi @@ -4,7 +4,7 @@ # from _ast below when loaded in an unorthodox way by the Dropbox # internal Bazel integration. import typing as _typing -from typing import Any, Iterator, Union +from typing import Any, Iterator from _ast import * from _ast import AST, Module diff --git a/stdlib/@python2/asynchat.pyi b/stdlib/@python2/asynchat.pyi index c45eb4917c4d..0f5526d71b1d 100644 --- a/stdlib/@python2/asynchat.pyi +++ b/stdlib/@python2/asynchat.pyi @@ -1,7 +1,7 @@ import asyncore import socket from abc import abstractmethod -from typing import Sequence, Tuple, Union +from typing import Sequence, Tuple class simple_producer: def __init__(self, data: bytes, buffer_size: int = ...) -> None: ... diff --git a/stdlib/@python2/asyncore.pyi b/stdlib/@python2/asyncore.pyi index d50dddd481cd..2bed33ecd140 100644 --- a/stdlib/@python2/asyncore.pyi +++ b/stdlib/@python2/asyncore.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import FileDescriptorLike from socket import SocketType -from typing import Any, Dict, Tuple, Union, overload +from typing import Any, Dict, Tuple, overload # cyclic dependence with asynchat _maptype = Dict[int, Any] diff --git a/stdlib/@python2/base64.pyi b/stdlib/@python2/base64.pyi index b2d437190d87..4a32006ea98b 100644 --- a/stdlib/@python2/base64.pyi +++ b/stdlib/@python2/base64.pyi @@ -1,4 +1,4 @@ -from typing import IO, Union +from typing import IO _encodable = bytes | unicode _decodable = bytes | unicode diff --git a/stdlib/@python2/bdb.pyi b/stdlib/@python2/bdb.pyi index c43b27b09f95..4816d183b44d 100644 --- a/stdlib/@python2/bdb.pyi +++ b/stdlib/@python2/bdb.pyi @@ -1,5 +1,5 @@ from types import CodeType, FrameType, TracebackType -from typing import IO, Any, Callable, Dict, Iterable, List, Mapping, 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/@python2/binhex.pyi b/stdlib/@python2/binhex.pyi index a8280b819539..8383a028a6cd 100644 --- a/stdlib/@python2/binhex.pyi +++ b/stdlib/@python2/binhex.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Tuple, Union +from typing import IO, Any, Tuple class Error(Exception): ... diff --git a/stdlib/@python2/bz2.pyi b/stdlib/@python2/bz2.pyi index 453ed7d452d8..792da2cbf31b 100644 --- a/stdlib/@python2/bz2.pyi +++ b/stdlib/@python2/bz2.pyi @@ -1,6 +1,6 @@ import io from _typeshed import ReadableBuffer, WriteableBuffer -from typing import IO, Any, Iterable, List, Text, TypeVar, Union +from typing import IO, Any, Iterable, List, Text, TypeVar from typing_extensions import SupportsIndex _PathOrFile = Text | IO[bytes] diff --git a/stdlib/@python2/cProfile.pyi b/stdlib/@python2/cProfile.pyi index 8e6506ddcae5..1257b0cc92eb 100644 --- a/stdlib/@python2/cProfile.pyi +++ b/stdlib/@python2/cProfile.pyi @@ -1,5 +1,5 @@ from types import CodeType -from typing import Any, Callable, Dict, Text, Tuple, TypeVar, Union +from typing import Any, Callable, Dict, Text, Tuple, TypeVar def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( diff --git a/stdlib/@python2/cStringIO.pyi b/stdlib/@python2/cStringIO.pyi index 6ced2d48e3f3..7703e030c332 100644 --- a/stdlib/@python2/cStringIO.pyi +++ b/stdlib/@python2/cStringIO.pyi @@ -1,5 +1,5 @@ from abc import ABCMeta -from typing import IO, Iterable, Iterator, List, Union, overload +from typing import IO, Iterable, Iterator, List, overload # This class isn't actually abstract, but you can't instantiate it # directly, so we might as well treat it as abstract in the stub. diff --git a/stdlib/@python2/calendar.pyi b/stdlib/@python2/calendar.pyi index 3ea4fd1edb0e..d6138fb77966 100644 --- a/stdlib/@python2/calendar.pyi +++ b/stdlib/@python2/calendar.pyi @@ -1,6 +1,6 @@ import datetime from time import struct_time -from typing import Any, Iterable, List, Sequence, Tuple, Union +from typing import Any, Iterable, List, Sequence, Tuple _LocaleType = Tuple[str | None, str | None] diff --git a/stdlib/@python2/cgi.pyi b/stdlib/@python2/cgi.pyi index 5a5b197daa7b..674748242ebb 100644 --- a/stdlib/@python2/cgi.pyi +++ b/stdlib/@python2/cgi.pyi @@ -1,6 +1,6 @@ from _typeshed import SupportsGetItem, SupportsItemAccess from builtins import type as _type -from typing import IO, Any, AnyStr, Iterable, Iterator, List, Mapping, Protocol, TypeVar, Union +from typing import IO, Any, AnyStr, Iterable, Iterator, List, Mapping, Protocol, TypeVar from UserDict import UserDict _T = TypeVar("_T", bound=FieldStorage) diff --git a/stdlib/@python2/cmath.pyi b/stdlib/@python2/cmath.pyi index 9f2bf4a66347..275eab3b01b8 100644 --- a/stdlib/@python2/cmath.pyi +++ b/stdlib/@python2/cmath.pyi @@ -1,4 +1,4 @@ -from typing import SupportsComplex, SupportsFloat, Tuple, Union +from typing import SupportsComplex, SupportsFloat, Tuple e: float pi: float diff --git a/stdlib/@python2/curses/ascii.pyi b/stdlib/@python2/curses/ascii.pyi index 1baff6e81a11..05efb326687a 100644 --- a/stdlib/@python2/curses/ascii.pyi +++ b/stdlib/@python2/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/@python2/curses/textpad.pyi b/stdlib/@python2/curses/textpad.pyi index 679741937fba..8b9098fa64d5 100644 --- a/stdlib/@python2/curses/textpad.pyi +++ b/stdlib/@python2/curses/textpad.pyi @@ -1,5 +1,5 @@ from _curses import _CursesWindow -from typing import Callable, Optional, Union +from typing import Callable, Optional def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> None: ... diff --git a/stdlib/@python2/datetime.pyi b/stdlib/@python2/datetime.pyi index 5d2b0e0983ac..2da3f9a7d207 100644 --- a/stdlib/@python2/datetime.pyi +++ b/stdlib/@python2/datetime.pyi @@ -1,5 +1,5 @@ from time import struct_time -from typing import AnyStr, ClassVar, SupportsAbs, Tuple, Type, TypeVar, Union, overload +from typing import AnyStr, ClassVar, SupportsAbs, Tuple, Type, TypeVar, overload _S = TypeVar("_S") diff --git a/stdlib/@python2/dbm/__init__.pyi b/stdlib/@python2/dbm/__init__.pyi index 8768d768d309..945b56882fa7 100644 --- a/stdlib/@python2/dbm/__init__.pyi +++ b/stdlib/@python2/dbm/__init__.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Iterator, MutableMapping, Tuple, Type, Union +from typing import Iterator, MutableMapping, Tuple, Type from typing_extensions import Literal _KeyType = str | bytes diff --git a/stdlib/@python2/dbm/dumb.pyi b/stdlib/@python2/dbm/dumb.pyi index 5c5c54450528..cedd8974790c 100644 --- a/stdlib/@python2/dbm/dumb.pyi +++ b/stdlib/@python2/dbm/dumb.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Iterator, MutableMapping, Type, Union +from typing import Iterator, MutableMapping, Type _KeyType = str | bytes _ValueType = str | bytes diff --git a/stdlib/@python2/dbm/gnu.pyi b/stdlib/@python2/dbm/gnu.pyi index 225f0f8ee2dd..a30bd34dca56 100644 --- a/stdlib/@python2/dbm/gnu.pyi +++ b/stdlib/@python2/dbm/gnu.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import List, Type, TypeVar, Union, overload +from typing import List, Type, TypeVar, overload _T = TypeVar("_T") _KeyType = str | bytes diff --git a/stdlib/@python2/dbm/ndbm.pyi b/stdlib/@python2/dbm/ndbm.pyi index 27951992473b..84d0338ebce8 100644 --- a/stdlib/@python2/dbm/ndbm.pyi +++ b/stdlib/@python2/dbm/ndbm.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import List, Type, TypeVar, Union, overload +from typing import List, Type, TypeVar, overload _T = TypeVar("_T") _KeyType = str | bytes diff --git a/stdlib/@python2/dircache.pyi b/stdlib/@python2/dircache.pyi index 5d68b9b03995..366909d87133 100644 --- a/stdlib/@python2/dircache.pyi +++ b/stdlib/@python2/dircache.pyi @@ -1,4 +1,4 @@ -from typing import List, MutableSequence, Text, Union +from typing import List, MutableSequence, Text def reset() -> None: ... def listdir(path: Text) -> List[str]: ... diff --git a/stdlib/@python2/distutils/cmd.pyi b/stdlib/@python2/distutils/cmd.pyi index fca99941d8b5..9a8464410496 100644 --- a/stdlib/@python2/distutils/cmd.pyi +++ b/stdlib/@python2/distutils/cmd.pyi @@ -1,6 +1,6 @@ from abc import abstractmethod from distutils.dist import Distribution -from typing import Any, Callable, Iterable, List, Optional, Text, Tuple, Union +from typing import Any, Callable, Iterable, List, Optional, Text, Tuple class Command: sub_commands: List[Tuple[str, Optional[Callable[[Command], bool]]]] diff --git a/stdlib/@python2/distutils/command/config.pyi b/stdlib/@python2/distutils/command/config.pyi index 89a316324acc..5b1363f49310 100644 --- a/stdlib/@python2/distutils/command/config.pyi +++ b/stdlib/@python2/distutils/command/config.pyi @@ -3,7 +3,7 @@ from distutils.ccompiler import CCompiler from distutils.core import Command as Command from distutils.errors import DistutilsExecError as DistutilsExecError from distutils.sysconfig import customize_compiler as customize_compiler -from typing import Dict, List, Pattern, Sequence, Tuple, Union +from typing import Dict, List, Pattern, Sequence, Tuple LANG_EXT: Dict[str, str] diff --git a/stdlib/@python2/distutils/core.pyi b/stdlib/@python2/distutils/core.pyi index b56719ab69ee..48bd7b5018bc 100644 --- a/stdlib/@python2/distutils/core.pyi +++ b/stdlib/@python2/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, Tuple, Type, Union +from typing import Any, List, Mapping, Tuple, Type def setup( *, diff --git a/stdlib/@python2/distutils/fancy_getopt.pyi b/stdlib/@python2/distutils/fancy_getopt.pyi index 3eafcd98d8d2..9d7601b1a259 100644 --- a/stdlib/@python2/distutils/fancy_getopt.pyi +++ b/stdlib/@python2/distutils/fancy_getopt.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Mapping, Tuple, Union, overload +from typing import Any, List, Mapping, Tuple, overload _Option = Tuple[str, str | None, str] _GR = Tuple[List[str], OptionDummy] diff --git a/stdlib/@python2/distutils/sysconfig.pyi b/stdlib/@python2/distutils/sysconfig.pyi index ff307df63d4d..7d9fe7d34de3 100644 --- a/stdlib/@python2/distutils/sysconfig.pyi +++ b/stdlib/@python2/distutils/sysconfig.pyi @@ -1,5 +1,5 @@ from distutils.ccompiler import CCompiler -from typing import Mapping, Union +from typing import Mapping PREFIX: str EXEC_PREFIX: str diff --git a/stdlib/@python2/distutils/text_file.pyi b/stdlib/@python2/distutils/text_file.pyi index 70c1a422fe85..26ba5a6fabb6 100644 --- a/stdlib/@python2/distutils/text_file.pyi +++ b/stdlib/@python2/distutils/text_file.pyi @@ -1,4 +1,4 @@ -from typing import IO, List, Tuple, Union +from typing import IO, List, Tuple class TextFile: def __init__( diff --git a/stdlib/@python2/distutils/version.pyi b/stdlib/@python2/distutils/version.pyi index 467066b7312a..dd0969b8635f 100644 --- a/stdlib/@python2/distutils/version.pyi +++ b/stdlib/@python2/distutils/version.pyi @@ -1,5 +1,5 @@ from abc import abstractmethod -from typing import Pattern, Text, Tuple, TypeVar, Union +from typing import Pattern, Text, Tuple, TypeVar _T = TypeVar("_T", bound=Version) diff --git a/stdlib/@python2/doctest.pyi b/stdlib/@python2/doctest.pyi index 6fc0b038ebe4..25db739aaa9d 100644 --- a/stdlib/@python2/doctest.pyi +++ b/stdlib/@python2/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, Optional, Tuple, Type class TestResults(NamedTuple): failed: int diff --git a/stdlib/@python2/fcntl.pyi b/stdlib/@python2/fcntl.pyi index 4c69e5ac10b3..b3730270f1cc 100644 --- a/stdlib/@python2/fcntl.pyi +++ b/stdlib/@python2/fcntl.pyi @@ -1,5 +1,5 @@ from _typeshed import FileDescriptorLike -from typing import Any, Union +from typing import Any FASYNC: int FD_CLOEXEC: int diff --git a/stdlib/@python2/filecmp.pyi b/stdlib/@python2/filecmp.pyi index 1b86866b4474..0be5596c2bdb 100644 --- a/stdlib/@python2/filecmp.pyi +++ b/stdlib/@python2/filecmp.pyi @@ -1,4 +1,4 @@ -from typing import AnyStr, Callable, Dict, Generic, Iterable, List, Sequence, Text, Tuple, Union +from typing import AnyStr, Callable, Dict, Generic, Iterable, List, Sequence, Text, Tuple DEFAULT_IGNORES: List[str] diff --git a/stdlib/@python2/fileinput.pyi b/stdlib/@python2/fileinput.pyi index 72e5b5aa833b..316643fcf15f 100644 --- a/stdlib/@python2/fileinput.pyi +++ b/stdlib/@python2/fileinput.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Text, Union +from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Text def input( files: Text | Iterable[Text] | None = ..., diff --git a/stdlib/@python2/fnmatch.pyi b/stdlib/@python2/fnmatch.pyi index 5d060a7a2eaf..f3c16532a659 100644 --- a/stdlib/@python2/fnmatch.pyi +++ b/stdlib/@python2/fnmatch.pyi @@ -1,4 +1,4 @@ -from typing import AnyStr, Iterable, List, Union +from typing import AnyStr, Iterable, List _EitherStr = str | unicode diff --git a/stdlib/@python2/fractions.pyi b/stdlib/@python2/fractions.pyi index dac9639946f2..20dc8254d7d5 100644 --- a/stdlib/@python2/fractions.pyi +++ b/stdlib/@python2/fractions.pyi @@ -1,6 +1,6 @@ from decimal import Decimal from numbers import Integral, Rational, Real -from typing import Tuple, Type, TypeVar, Union, overload +from typing import Tuple, Type, TypeVar, overload from typing_extensions import Literal _ComparableNum = int | float | Decimal | Real diff --git a/stdlib/@python2/genericpath.pyi b/stdlib/@python2/genericpath.pyi index 2ab01e8d99f4..49e1f086e342 100644 --- a/stdlib/@python2/genericpath.pyi +++ b/stdlib/@python2/genericpath.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsLessThanT -from typing import List, Sequence, Text, Tuple, Union, overload +from typing import List, Sequence, Text, Tuple, overload from typing_extensions import Literal # All overloads can return empty string. Ideally, Literal[""] would be a valid diff --git a/stdlib/@python2/gettext.pyi b/stdlib/@python2/gettext.pyi index 9ecf387e7a4c..a91234f6b2d3 100644 --- a/stdlib/@python2/gettext.pyi +++ b/stdlib/@python2/gettext.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Container, Dict, List, Sequence, Type, Union +from typing import IO, Any, Container, Dict, List, Sequence, Type def bindtextdomain(domain: str, localedir: str = ...) -> str: ... def bind_textdomain_codeset(domain: str, codeset: str = ...) -> str: ... diff --git a/stdlib/@python2/glob.pyi b/stdlib/@python2/glob.pyi index 149eaed059a5..f5a389a0ddfa 100644 --- a/stdlib/@python2/glob.pyi +++ b/stdlib/@python2/glob.pyi @@ -1,4 +1,4 @@ -from typing import AnyStr, Iterator, List, Union +from typing import AnyStr, Iterator, List def glob(pathname: AnyStr) -> List[AnyStr]: ... def iglob(pathname: AnyStr) -> Iterator[AnyStr]: ... diff --git a/stdlib/@python2/imghdr.pyi b/stdlib/@python2/imghdr.pyi index f66157423c77..07efa196db6c 100644 --- a/stdlib/@python2/imghdr.pyi +++ b/stdlib/@python2/imghdr.pyi @@ -1,4 +1,4 @@ -from typing import Any, BinaryIO, Callable, List, Protocol, Text, Union, overload +from typing import Any, BinaryIO, Callable, List, Protocol, Text, overload class _ReadableBinary(Protocol): def tell(self) -> int: ... diff --git a/stdlib/@python2/io.pyi b/stdlib/@python2/io.pyi index 04b6da2a2cc4..f36138edd598 100644 --- a/stdlib/@python2/io.pyi +++ b/stdlib/@python2/io.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Union +from typing import IO, Any import _io from _io import ( diff --git a/stdlib/@python2/json.pyi b/stdlib/@python2/json.pyi index 1e0927ab7b37..d84c66072368 100644 --- a/stdlib/@python2/json.pyi +++ b/stdlib/@python2/json.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsRead -from typing import IO, Any, Callable, Dict, List, Optional, Text, Tuple, Type, Union +from typing import IO, Any, Callable, Dict, List, Optional, Text, Tuple, Type def dumps( obj: Any, diff --git a/stdlib/@python2/lib2to3/pytree.pyi b/stdlib/@python2/lib2to3/pytree.pyi index e18837f5c937..05399f3763c4 100644 --- a/stdlib/@python2/lib2to3/pytree.pyi +++ b/stdlib/@python2/lib2to3/pytree.pyi @@ -1,5 +1,5 @@ from lib2to3.pgen2.grammar import Grammar -from typing import Any, Callable, Dict, Iterator, List, Text, Tuple, TypeVar, Union +from typing import Any, Callable, Dict, Iterator, List, Text, Tuple, TypeVar _P = TypeVar("_P") _NL = Node | Leaf diff --git a/stdlib/@python2/locale.pyi b/stdlib/@python2/locale.pyi index f04adcbac0a0..21a7da166e29 100644 --- a/stdlib/@python2/locale.pyi +++ b/stdlib/@python2/locale.pyi @@ -1,7 +1,7 @@ # workaround for mypy#2010 from __builtin__ import str as _str from decimal import Decimal -from typing import Any, Callable, Dict, Iterable, List, Mapping, Sequence, Tuple, Union +from typing import Any, Callable, Dict, Iterable, List, Mapping, Sequence, Tuple CODESET: int D_T_FMT: int diff --git a/stdlib/@python2/logging/config.pyi b/stdlib/@python2/logging/config.pyi index f734828ddb7e..d6e71a36618e 100644 --- a/stdlib/@python2/logging/config.pyi +++ b/stdlib/@python2/logging/config.pyi @@ -1,6 +1,6 @@ from _typeshed import StrPath from threading import Thread -from typing import IO, Any, Dict, Union +from typing import IO, Any, Dict _Path = StrPath diff --git a/stdlib/@python2/logging/handlers.pyi b/stdlib/@python2/logging/handlers.pyi index 7ba6b421aab5..38cdcc0a8307 100644 --- a/stdlib/@python2/logging/handlers.pyi +++ b/stdlib/@python2/logging/handlers.pyi @@ -1,7 +1,7 @@ from _typeshed import StrPath from logging import FileHandler, Handler, LogRecord from socket import SocketKind, SocketType -from typing import Any, ClassVar, Dict, List, Tuple, Union +from typing import Any, ClassVar, Dict, List, Tuple DEFAULT_TCP_LOGGING_PORT: int DEFAULT_UDP_LOGGING_PORT: int diff --git a/stdlib/@python2/mailcap.pyi b/stdlib/@python2/mailcap.pyi index b0c538c6bbcd..83624bce39e0 100644 --- a/stdlib/@python2/mailcap.pyi +++ b/stdlib/@python2/mailcap.pyi @@ -1,4 +1,4 @@ -from typing import Dict, List, Mapping, Sequence, Tuple, Union +from typing import Dict, List, Mapping, Sequence, Tuple _Cap = Dict[str, str | int] diff --git a/stdlib/@python2/mmap.pyi b/stdlib/@python2/mmap.pyi index 9decd440add3..a0fe88703350 100644 --- a/stdlib/@python2/mmap.pyi +++ b/stdlib/@python2/mmap.pyi @@ -1,5 +1,5 @@ import sys -from typing import AnyStr, Generic, Sequence, Union +from typing import AnyStr, Generic, Sequence ACCESS_DEFAULT: int ACCESS_READ: int diff --git a/stdlib/@python2/msilib/__init__.pyi b/stdlib/@python2/msilib/__init__.pyi index 1f69351360aa..b78299e90188 100644 --- a/stdlib/@python2/msilib/__init__.pyi +++ b/stdlib/@python2/msilib/__init__.pyi @@ -1,6 +1,6 @@ import sys from types import ModuleType -from typing import Any, Container, Dict, Iterable, List, 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/@python2/optparse.pyi b/stdlib/@python2/optparse.pyi index 72ffd28e86a2..e380816a0626 100644 --- a/stdlib/@python2/optparse.pyi +++ b/stdlib/@python2/optparse.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, AnyStr, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Type, Union, overload +from typing import IO, Any, AnyStr, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Type, overload # See https://groups.google.com/forum/#!topic/python-ideas/gA1gdj3RZ5g _Text = str | unicode diff --git a/stdlib/@python2/pdb.pyi b/stdlib/@python2/pdb.pyi index 238290c2a84c..9931422af598 100644 --- a/stdlib/@python2/pdb.pyi +++ b/stdlib/@python2/pdb.pyi @@ -1,7 +1,7 @@ from bdb import Bdb from cmd import Cmd from types import FrameType, TracebackType -from typing import IO, Any, Callable, ClassVar, Dict, Iterable, List, Mapping, Tuple, TypeVar, Union +from typing import IO, Any, Callable, ClassVar, Dict, Iterable, List, Mapping, Tuple, TypeVar _T = TypeVar("_T") diff --git a/stdlib/@python2/pkgutil.pyi b/stdlib/@python2/pkgutil.pyi index 9ff53ad6272d..3c10d7803d50 100644 --- a/stdlib/@python2/pkgutil.pyi +++ b/stdlib/@python2/pkgutil.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsRead -from typing import IO, Any, Callable, Iterable, Iterator, List, Optional, Tuple, Union +from typing import IO, Any, Callable, Iterable, Iterator, List, Optional, Tuple Loader = Any MetaPathFinder = Any diff --git a/stdlib/@python2/plistlib.pyi b/stdlib/@python2/plistlib.pyi index 25db8b3d9895..50c0636c954d 100644 --- a/stdlib/@python2/plistlib.pyi +++ b/stdlib/@python2/plistlib.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Dict as DictT, Mapping, Text, Union +from typing import IO, Any, Dict as DictT, Mapping, Text _Path = str | Text diff --git a/stdlib/@python2/popen2.pyi b/stdlib/@python2/popen2.pyi index 80ebf7a6c0f0..0efee4e6d271 100644 --- a/stdlib/@python2/popen2.pyi +++ b/stdlib/@python2/popen2.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, TextIO, Tuple, TypeVar, Union +from typing import Any, Iterable, TextIO, Tuple, TypeVar _T = TypeVar("_T") diff --git a/stdlib/@python2/posix.pyi b/stdlib/@python2/posix.pyi index a8e104f9bca2..c39ce325289b 100644 --- a/stdlib/@python2/posix.pyi +++ b/stdlib/@python2/posix.pyi @@ -1,5 +1,5 @@ from _typeshed import FileDescriptorLike -from typing import IO, AnyStr, Dict, List, Mapping, NamedTuple, Sequence, Tuple, TypeVar, Union +from typing import IO, AnyStr, Dict, List, Mapping, NamedTuple, Sequence, Tuple, TypeVar error = OSError diff --git a/stdlib/@python2/profile.pyi b/stdlib/@python2/profile.pyi index 38d5af235434..7904a77c519a 100644 --- a/stdlib/@python2/profile.pyi +++ b/stdlib/@python2/profile.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Optional, Text, Tuple, TypeVar, Union +from typing import Any, Callable, Dict, Optional, Text, Tuple, TypeVar def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( diff --git a/stdlib/@python2/pty.pyi b/stdlib/@python2/pty.pyi index 50c137a61c83..e8afa2df5166 100644 --- a/stdlib/@python2/pty.pyi +++ b/stdlib/@python2/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/@python2/py_compile.pyi b/stdlib/@python2/py_compile.pyi index b8371968afd0..583cda40ef89 100644 --- a/stdlib/@python2/py_compile.pyi +++ b/stdlib/@python2/py_compile.pyi @@ -1,4 +1,4 @@ -from typing import List, Text, Type, Union +from typing import List, Text, Type _EitherStr = bytes | Text diff --git a/stdlib/@python2/pyclbr.pyi b/stdlib/@python2/pyclbr.pyi index 416a3af46607..893079901665 100644 --- a/stdlib/@python2/pyclbr.pyi +++ b/stdlib/@python2/pyclbr.pyi @@ -1,4 +1,4 @@ -from typing import Dict, List, Sequence, Union +from typing import Dict, List, Sequence class Class: module: str diff --git a/stdlib/@python2/re.pyi b/stdlib/@python2/re.pyi index 16bbcee658ae..b34e454ffcf9 100644 --- a/stdlib/@python2/re.pyi +++ b/stdlib/@python2/re.pyi @@ -1,4 +1,4 @@ -from typing import Any, AnyStr, Callable, Iterator, List, Match, Pattern, Tuple, Union, overload +from typing import Any, AnyStr, Callable, Iterator, List, Match, Pattern, Tuple, overload # ----- re variables and constants ----- DEBUG: int diff --git a/stdlib/@python2/rlcompleter.pyi b/stdlib/@python2/rlcompleter.pyi index 4821be2a91bc..41a1d23318cc 100644 --- a/stdlib/@python2/rlcompleter.pyi +++ b/stdlib/@python2/rlcompleter.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Union +from typing import Any, Dict _Text = str | unicode diff --git a/stdlib/@python2/sets.pyi b/stdlib/@python2/sets.pyi index 4f0cc1b9dcc3..3156e56cd132 100644 --- a/stdlib/@python2/sets.pyi +++ b/stdlib/@python2/sets.pyi @@ -1,4 +1,4 @@ -from typing import Any, Hashable, Iterable, Iterator, MutableMapping, TypeVar, Union +from typing import Any, Hashable, Iterable, Iterator, MutableMapping, TypeVar _T = TypeVar("_T") _Setlike = BaseSet[_T] | Iterable[_T] diff --git a/stdlib/@python2/shlex.pyi b/stdlib/@python2/shlex.pyi index 049c4f65e716..89c28fc9be7f 100644 --- a/stdlib/@python2/shlex.pyi +++ b/stdlib/@python2/shlex.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, List, Text, TypeVar, Union +from typing import IO, Any, List, Text, TypeVar def split(s: str | None, comments: bool = ..., posix: bool = ...) -> List[str]: ... diff --git a/stdlib/@python2/smtpd.pyi b/stdlib/@python2/smtpd.pyi index cc59cd5d09ad..1c17b82d8ab5 100644 --- a/stdlib/@python2/smtpd.pyi +++ b/stdlib/@python2/smtpd.pyi @@ -1,7 +1,7 @@ import asynchat import asyncore import socket -from typing import Any, List, Text, Tuple, Type, Union +from typing import Any, List, Text, Tuple, Type _Address = Tuple[str, int] # (host, port) diff --git a/stdlib/@python2/sndhdr.pyi b/stdlib/@python2/sndhdr.pyi index 5c434028bc1c..3fc08632c2b2 100644 --- a/stdlib/@python2/sndhdr.pyi +++ b/stdlib/@python2/sndhdr.pyi @@ -1,4 +1,4 @@ -from typing import Text, Tuple, Union +from typing import Text, Tuple _SndHeaders = Tuple[str, int, int, int, int | str] diff --git a/stdlib/@python2/socket.pyi b/stdlib/@python2/socket.pyi index c1ba43b7b757..bb5aef8f92e7 100644 --- a/stdlib/@python2/socket.pyi +++ b/stdlib/@python2/socket.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, BinaryIO, Iterable, List, Text, Tuple, TypeVar, Union, overload +from typing import Any, BinaryIO, Iterable, List, Text, Tuple, TypeVar, overload # ----- Constants ----- # Some socket families are listed in the "Socket families" section of the docs, diff --git a/stdlib/@python2/sqlite3/dbapi2.pyi b/stdlib/@python2/sqlite3/dbapi2.pyi index 8c997ef7109c..fadfcc8f5884 100644 --- a/stdlib/@python2/sqlite3/dbapi2.pyi +++ b/stdlib/@python2/sqlite3/dbapi2.pyi @@ -1,5 +1,5 @@ from datetime import date, datetime, time -from typing import Any, Callable, Generator, Iterable, Iterator, List, Protocol, Text, Tuple, Type, TypeVar, Union +from typing import Any, Callable, Generator, Iterable, Iterator, List, Protocol, Text, Tuple, Type, TypeVar _T = TypeVar("_T") diff --git a/stdlib/@python2/sre_compile.pyi b/stdlib/@python2/sre_compile.pyi index 2d526d039ca8..efc3e568a07c 100644 --- a/stdlib/@python2/sre_compile.pyi +++ b/stdlib/@python2/sre_compile.pyi @@ -12,7 +12,7 @@ from sre_constants import ( SRE_INFO_PREFIX as SRE_INFO_PREFIX, ) from sre_parse import SubPattern -from typing import Any, List, Pattern, Tuple, Type, Union +from typing import Any, List, Pattern, Tuple, Type MAXCODE: int STRING_TYPES: Tuple[Type[str], Type[unicode]] diff --git a/stdlib/@python2/string.pyi b/stdlib/@python2/string.pyi index 939a5dd1611b..fe028dab39bd 100644 --- a/stdlib/@python2/string.pyi +++ b/stdlib/@python2/string.pyi @@ -1,4 +1,4 @@ -from typing import Any, AnyStr, Iterable, List, Mapping, Sequence, Text, Tuple, Union, overload +from typing import Any, AnyStr, Iterable, List, Mapping, Sequence, Text, Tuple, overload ascii_letters: str ascii_lowercase: str diff --git a/stdlib/@python2/subprocess.pyi b/stdlib/@python2/subprocess.pyi index 20cff6a7df32..28770553f51a 100644 --- a/stdlib/@python2/subprocess.pyi +++ b/stdlib/@python2/subprocess.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, Generic, Mapping, Optional, Sequence, Text, Tuple, TypeVar, Union +from typing import IO, Any, Callable, Generic, Mapping, Optional, Sequence, Text, Tuple, TypeVar _FILE = None | int | IO[Any] _TXT = bytes | Text diff --git a/stdlib/@python2/sunau.pyi b/stdlib/@python2/sunau.pyi index eaeeceff05a3..546128de8445 100644 --- a/stdlib/@python2/sunau.pyi +++ b/stdlib/@python2/sunau.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, NoReturn, Text, Tuple, Union +from typing import IO, Any, NoReturn, Text, Tuple _File = Text | IO[bytes] diff --git a/stdlib/@python2/sys.pyi b/stdlib/@python2/sys.pyi index 493a9d58acc1..e98ead1ee8b8 100644 --- a/stdlib/@python2/sys.pyi +++ b/stdlib/@python2/sys.pyi @@ -1,5 +1,5 @@ from types import ClassType, FrameType, TracebackType -from typing import IO, Any, Callable, Dict, List, NoReturn, Text, Tuple, Type, Union +from typing import IO, Any, Callable, Dict, List, NoReturn, Text, Tuple, Type # The following type alias are stub-only and do not exist during runtime _ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType] diff --git a/stdlib/@python2/telnetlib.pyi b/stdlib/@python2/telnetlib.pyi index 7bd7aa9ca6c7..5d5d1adc97cd 100644 --- a/stdlib/@python2/telnetlib.pyi +++ b/stdlib/@python2/telnetlib.pyi @@ -1,5 +1,5 @@ import socket -from typing import Any, Callable, Match, Optional, Pattern, Sequence, Tuple, Union +from typing import Any, Callable, Match, Optional, Pattern, Sequence, Tuple DEBUGLEVEL: int TELNET_PORT: int diff --git a/stdlib/@python2/tempfile.pyi b/stdlib/@python2/tempfile.pyi index 7d1e6093b208..81fc73f0a1da 100644 --- a/stdlib/@python2/tempfile.pyi +++ b/stdlib/@python2/tempfile.pyi @@ -1,6 +1,6 @@ from random import Random from thread import LockType -from typing import IO, Any, AnyStr, Iterable, Iterator, List, Text, Tuple, Union, overload +from typing import IO, Any, AnyStr, Iterable, Iterator, List, Text, Tuple, overload TMP_MAX: int tempdir: str diff --git a/stdlib/@python2/termios.pyi b/stdlib/@python2/termios.pyi index 86da7243817d..a0774e7f1728 100644 --- a/stdlib/@python2/termios.pyi +++ b/stdlib/@python2/termios.pyi @@ -1,5 +1,5 @@ from _typeshed import FileDescriptorLike -from typing import Any, List, Union +from typing import Any, List _Attr = List[int | List[bytes | int]] diff --git a/stdlib/@python2/threading.pyi b/stdlib/@python2/threading.pyi index 6823a8d477fa..baf26f1a981e 100644 --- a/stdlib/@python2/threading.pyi +++ b/stdlib/@python2/threading.pyi @@ -1,5 +1,5 @@ from types import FrameType, TracebackType -from typing import Any, Callable, Iterable, List, Mapping, Text, Type, TypeVar, Union +from typing import Any, Callable, Iterable, List, Mapping, Text, Type, TypeVar # TODO recursive type _TF = Callable[[FrameType, str, Any], Callable[..., Any] | None] diff --git a/stdlib/@python2/time.pyi b/stdlib/@python2/time.pyi index 6de890db19a3..48ae9da9c65e 100644 --- a/stdlib/@python2/time.pyi +++ b/stdlib/@python2/time.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, NamedTuple, Tuple, Union +from typing import Any, NamedTuple, Tuple _TimeTuple = Tuple[int, int, int, int, int, int, int, int, int] diff --git a/stdlib/@python2/trace.pyi b/stdlib/@python2/trace.pyi index b70abc7c2af6..54ac91fb2c02 100644 --- a/stdlib/@python2/trace.pyi +++ b/stdlib/@python2/trace.pyi @@ -1,6 +1,6 @@ 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/@python2/tty.pyi b/stdlib/@python2/tty.pyi index 47132006edeb..c25f22a5a4ff 100644 --- a/stdlib/@python2/tty.pyi +++ b/stdlib/@python2/tty.pyi @@ -1,4 +1,4 @@ -from typing import IO, Union +from typing import IO _FD = int | IO[str] diff --git a/stdlib/@python2/types.pyi b/stdlib/@python2/types.pyi index 1bee9e2f5715..06cce4b2c934 100644 --- a/stdlib/@python2/types.pyi +++ b/stdlib/@python2/types.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Iterable, Iterator, List, Tuple, Type, TypeVar, Union, overload +from typing import Any, Callable, Dict, Iterable, Iterator, List, Tuple, Type, TypeVar, overload _T = TypeVar("_T") diff --git a/stdlib/@python2/unicodedata.pyi b/stdlib/@python2/unicodedata.pyi index 99747db5f31d..f4ca655e5c7e 100644 --- a/stdlib/@python2/unicodedata.pyi +++ b/stdlib/@python2/unicodedata.pyi @@ -1,4 +1,4 @@ -from typing import Any, Text, TypeVar, Union +from typing import Any, Text, TypeVar ucd_3_2_0: UCD ucnhash_CAPI: Any diff --git a/stdlib/@python2/urllib2.pyi b/stdlib/@python2/urllib2.pyi index baf8b5528765..d76e1a717648 100644 --- a/stdlib/@python2/urllib2.pyi +++ b/stdlib/@python2/urllib2.pyi @@ -1,6 +1,6 @@ import ssl from httplib import HTTPConnectionProtocol, HTTPResponse -from typing import Any, AnyStr, Callable, Dict, List, Mapping, Sequence, Text, Tuple, Type, Union +from typing import Any, AnyStr, Callable, Dict, List, Mapping, Sequence, Text, Tuple, Type from urllib import addinfourl _string = str | unicode diff --git a/stdlib/@python2/urlparse.pyi b/stdlib/@python2/urlparse.pyi index ae85c4a3d4b9..e935f281e3b5 100644 --- a/stdlib/@python2/urlparse.pyi +++ b/stdlib/@python2/urlparse.pyi @@ -1,4 +1,4 @@ -from typing import AnyStr, Dict, List, NamedTuple, Sequence, Tuple, Union, overload +from typing import AnyStr, Dict, List, NamedTuple, Sequence, Tuple, overload _String = str | unicode diff --git a/stdlib/@python2/uu.pyi b/stdlib/@python2/uu.pyi index 061375b4fa87..a9585bac60a1 100644 --- a/stdlib/@python2/uu.pyi +++ b/stdlib/@python2/uu.pyi @@ -1,4 +1,4 @@ -from typing import BinaryIO, Text, Union +from typing import BinaryIO, Text _File = Text | BinaryIO diff --git a/stdlib/@python2/warnings.pyi b/stdlib/@python2/warnings.pyi index 405d563fed0d..e432ebae0cde 100644 --- a/stdlib/@python2/warnings.pyi +++ b/stdlib/@python2/warnings.pyi @@ -1,5 +1,5 @@ from types import ModuleType, TracebackType -from typing import List, TextIO, Type, Union, overload +from typing import List, TextIO, Type, overload from typing_extensions import Literal from _warnings import warn as warn, warn_explicit as warn_explicit diff --git a/stdlib/@python2/wave.pyi b/stdlib/@python2/wave.pyi index e9cbc529f8ba..8ab1af0d64a6 100644 --- a/stdlib/@python2/wave.pyi +++ b/stdlib/@python2/wave.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, BinaryIO, NoReturn, Text, Tuple, Union +from typing import IO, Any, BinaryIO, NoReturn, Text, Tuple _File = Text | IO[bytes] diff --git a/stdlib/@python2/webbrowser.pyi b/stdlib/@python2/webbrowser.pyi index a05e46f4d701..ef8ad20181ef 100644 --- a/stdlib/@python2/webbrowser.pyi +++ b/stdlib/@python2/webbrowser.pyi @@ -1,5 +1,5 @@ import sys -from typing import Callable, List, Optional, Sequence, Text, Union +from typing import Callable, List, Optional, Sequence, Text class Error(Exception): ... diff --git a/stdlib/@python2/xml/dom/minidom.pyi b/stdlib/@python2/xml/dom/minidom.pyi index 8ecce2ae578a..05b968e994c9 100644 --- a/stdlib/@python2/xml/dom/minidom.pyi +++ b/stdlib/@python2/xml/dom/minidom.pyi @@ -1,5 +1,5 @@ import xml.dom -from typing import IO, Any, Text as _Text, TypeVar, Union +from typing import IO, Any, Text as _Text, TypeVar from xml.dom.xmlbuilder import DocumentLS, DOMImplementationLS from xml.sax.xmlreader import XMLReader diff --git a/stdlib/@python2/xml/etree/ElementInclude.pyi b/stdlib/@python2/xml/etree/ElementInclude.pyi index 5e4aeda72b4c..b74285d3e9b7 100644 --- a/stdlib/@python2/xml/etree/ElementInclude.pyi +++ b/stdlib/@python2/xml/etree/ElementInclude.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Union +from typing import Callable from xml.etree.ElementTree import Element XINCLUDE: str diff --git a/stdlib/@python2/xml/etree/ElementPath.pyi b/stdlib/@python2/xml/etree/ElementPath.pyi index 66e1139ee161..4e75e924eecc 100644 --- a/stdlib/@python2/xml/etree/ElementPath.pyi +++ b/stdlib/@python2/xml/etree/ElementPath.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Dict, Generator, List, 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/@python2/xml/sax/__init__.pyi b/stdlib/@python2/xml/sax/__init__.pyi index 9ad78389f292..0c6da9a87d13 100644 --- a/stdlib/@python2/xml/sax/__init__.pyi +++ b/stdlib/@python2/xml/sax/__init__.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, List, NoReturn, Text, Union +from typing import IO, Any, List, NoReturn, Text from xml.sax.handler import ContentHandler, ErrorHandler from xml.sax.xmlreader import Locator, XMLReader diff --git a/stdlib/@python2/zipfile.pyi b/stdlib/@python2/zipfile.pyi index dfacc97cec42..bfddecad0d94 100644 --- a/stdlib/@python2/zipfile.pyi +++ b/stdlib/@python2/zipfile.pyi @@ -1,7 +1,7 @@ import io from _typeshed import StrPath from types import TracebackType -from typing import IO, Any, Callable, Dict, Iterable, List, Optional, Pattern, Protocol, Sequence, Text, Tuple, Type, Union +from typing import IO, Any, Callable, Dict, Iterable, List, Optional, Pattern, Protocol, Sequence, Text, Tuple, Type _SZI = Text | ZipInfo _DT = Tuple[int, int, int, int, int, int] diff --git a/stdlib/@python2/zlib.pyi b/stdlib/@python2/zlib.pyi index 8f946924057c..2cee20fc0928 100644 --- a/stdlib/@python2/zlib.pyi +++ b/stdlib/@python2/zlib.pyi @@ -1,5 +1,5 @@ from array import array -from typing import Any, Union +from typing import Any DEFLATED: int DEF_MEM_LEVEL: int diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index 0c66d6927822..25af85974cc5 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -1,6 +1,6 @@ import codecs import sys -from typing import Any, Callable, Dict, Tuple, Union +from typing import Any, Callable, Dict, Tuple # This type is not exposed; it is defined in unicodeobject.c class _EncodingMap: diff --git a/stdlib/_csv.pyi b/stdlib/_csv.pyi index 0a1c2b3257a8..20e6c237cb30 100644 --- a/stdlib/_csv.pyi +++ b/stdlib/_csv.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Iterator, List, Protocol, Type, Union +from typing import Any, Iterable, Iterator, List, Protocol, Type QUOTE_ALL: int QUOTE_MINIMAL: int diff --git a/stdlib/_curses.pyi b/stdlib/_curses.pyi index dc335c8fe479..ba010e85e9c1 100644 --- a/stdlib/_curses.pyi +++ b/stdlib/_curses.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Any, BinaryIO, NamedTuple, Tuple, Union, overload +from typing import IO, Any, BinaryIO, NamedTuple, Tuple, overload _chtype = str | bytes | int diff --git a/stdlib/_dummy_threading.pyi b/stdlib/_dummy_threading.pyi index 686380756c34..b32c2f49a4a7 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], Callable[..., Any] | None] diff --git a/stdlib/_msi.pyi b/stdlib/_msi.pyi index 159ce1523e0a..a1030a66160f 100644 --- a/stdlib/_msi.pyi +++ b/stdlib/_msi.pyi @@ -1,5 +1,5 @@ import sys -from typing import List, Union +from typing import List if sys.platform == "win32": diff --git a/stdlib/_osx_support.pyi b/stdlib/_osx_support.pyi index b6d1b9687b25..1b890d8d8a0a 100644 --- a/stdlib/_osx_support.pyi +++ b/stdlib/_osx_support.pyi @@ -1,4 +1,4 @@ -from typing import Dict, Iterable, List, Sequence, Tuple, TypeVar, Union +from typing import Dict, Iterable, List, Sequence, Tuple, TypeVar _T = TypeVar("_T") _K = TypeVar("_K") diff --git a/stdlib/_socket.pyi b/stdlib/_socket.pyi index c45efb89b715..e5a8a0f361b0 100644 --- a/stdlib/_socket.pyi +++ b/stdlib/_socket.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import ReadableBuffer, WriteableBuffer from collections.abc import Iterable -from typing import Any, SupportsInt, Tuple, Union, overload +from typing import Any, SupportsInt, Tuple, overload if sys.version_info >= (3, 8): from typing import SupportsIndex diff --git a/stdlib/_weakrefset.pyi b/stdlib/_weakrefset.pyi index 5be2191f5a09..1f0132f4c240 100644 --- a/stdlib/_weakrefset.pyi +++ b/stdlib/_weakrefset.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Generic, Iterable, Iterator, MutableSet, 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 e650eb58e008..5e3db51435cd 100644 --- a/stdlib/_winapi.pyi +++ b/stdlib/_winapi.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Dict, NoReturn, 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 e8f882cdd9e0..af49c2386c96 100644 --- a/stdlib/aifc.pyi +++ b/stdlib/aifc.pyi @@ -1,6 +1,6 @@ import sys from types import TracebackType -from typing import IO, Any, List, NamedTuple, Tuple, Type, Union, overload +from typing import IO, Any, List, NamedTuple, Tuple, Type, overload from typing_extensions import Literal class Error(Exception): ... diff --git a/stdlib/array.pyi b/stdlib/array.pyi index 58249f6ab55f..12af38dd739f 100644 --- a/stdlib/array.pyi +++ b/stdlib/array.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, BinaryIO, Generic, Iterable, List, MutableSequence, Tuple, TypeVar, Union, overload +from typing import Any, BinaryIO, Generic, Iterable, List, MutableSequence, Tuple, TypeVar, overload from typing_extensions import Literal _IntTypeCode = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"] diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 6867f05262c5..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, TypeVar, Union, overload +from typing import Any, Iterator, TypeVar, overload from typing_extensions import Literal from _ast import * # type: ignore diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index b0e60d8ca80e..207a188d7ac5 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, Optional, Sequence, Tuple, TypeVar, overload from typing_extensions import Literal if sys.version_info >= (3, 7): diff --git a/stdlib/asyncio/base_subprocess.pyi b/stdlib/asyncio/base_subprocess.pyi index 7c0db4a40fa0..4dcfd4d34bd3 100644 --- a/stdlib/asyncio/base_subprocess.pyi +++ b/stdlib/asyncio/base_subprocess.pyi @@ -1,5 +1,5 @@ import subprocess -from typing import IO, Any, Callable, Deque, Dict, List, Sequence, Tuple, Union +from typing import IO, Any, Callable, Deque, Dict, List, Sequence, Tuple from . import events, futures, protocols, transports diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 3026e11da841..291d5e0ebc5f 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -8,7 +8,7 @@ from asyncio.tasks import Task from asyncio.transports import BaseTransport from asyncio.unix_events import AbstractChildWatcher 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, Optional, Sequence, Tuple, TypeVar, overload from typing_extensions import Literal if sys.version_info >= (3, 7): diff --git a/stdlib/asyncio/futures.pyi b/stdlib/asyncio/futures.pyi index c007cbd6ecc6..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, 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 6e75702dc48b..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, 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/streams.pyi b/stdlib/asyncio/streams.pyi index ecc51759c45f..261ef11df006 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, Tuple, Union +from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Tuple from . import events, protocols, transports diff --git a/stdlib/asyncio/subprocess.pyi b/stdlib/asyncio/subprocess.pyi index 24364025f612..cfadb428f42e 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, Optional, Tuple from typing_extensions import Literal if sys.version_info >= (3, 8): diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index 86f36460aed4..76f38a830a57 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -2,7 +2,7 @@ import concurrent.futures import sys from collections.abc import Awaitable, Generator, Iterable, Iterator from types import FrameType -from typing import Any, Generic, List, Set, TextIO, Tuple, TypeVar, Union, overload +from typing import Any, Generic, List, Set, TextIO, Tuple, TypeVar, overload from typing_extensions import Literal from .events import AbstractEventLoop diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index 07159262952d..4b971028d405 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, Tuple, Type, Union, overload +from typing import Any, BinaryIO, Iterable, List, NoReturn, Tuple, Type, 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/asyncore.pyi b/stdlib/asyncore.pyi index 291c47dea855..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, Tuple, Union, overload +from typing import Any, Dict, Tuple, overload # cyclic dependence with asynchat _maptype = Dict[int, Any] diff --git a/stdlib/base64.pyi b/stdlib/base64.pyi index d9777497932e..4653254dbc29 100644 --- a/stdlib/base64.pyi +++ b/stdlib/base64.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, 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 c43b27b09f95..4816d183b44d 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, 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/binhex.pyi b/stdlib/binhex.pyi index a8280b819539..8383a028a6cd 100644 --- a/stdlib/binhex.pyi +++ b/stdlib/binhex.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Tuple, Union +from typing import IO, Any, Tuple class Error(Exception): ... diff --git a/stdlib/bz2.pyi b/stdlib/bz2.pyi index 21180a02d5f6..f783623edb77 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, StrOrBytesPath, WriteableBuffer -from typing import IO, Any, Iterable, List, 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 fcc6c20f2fa1..46b6fc300744 100644 --- a/stdlib/cProfile.pyi +++ b/stdlib/cProfile.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import StrOrBytesPath from types import CodeType -from typing import Any, Callable, Dict, 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 3276c9cc48c4..b88125c31f08 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, Sequence, Tuple, Union +from typing import Any, Iterable, List, Sequence, Tuple _LocaleType = Tuple[str | None, str | None] diff --git a/stdlib/cgi.pyi b/stdlib/cgi.pyi index 20fa28eff7d8..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, Protocol, TypeVar, Union +from typing import IO, Any, Protocol, TypeVar _T = TypeVar("_T", bound=FieldStorage) diff --git a/stdlib/cmath.pyi b/stdlib/cmath.pyi index 7e6290664aba..6329dd8f1041 100644 --- a/stdlib/cmath.pyi +++ b/stdlib/cmath.pyi @@ -1,4 +1,4 @@ -from typing import SupportsComplex, SupportsFloat, Tuple, Union +from typing import SupportsComplex, SupportsFloat, Tuple e: float pi: float diff --git a/stdlib/contextvars.pyi b/stdlib/contextvars.pyi index ce06bfaca3c6..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, 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/crypt.pyi b/stdlib/crypt.pyi index 16483fb7d388..d453450308fc 100644 --- a/stdlib/crypt.pyi +++ b/stdlib/crypt.pyi @@ -1,5 +1,5 @@ import sys -from typing import List, Union +from typing import List class _Method: ... 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 679741937fba..8b9098fa64d5 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, Optional def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> None: ... diff --git a/stdlib/dbm/__init__.pyi b/stdlib/dbm/__init__.pyi index bf6d728a4067..9a92fbbec16b 100644 --- a/stdlib/dbm/__init__.pyi +++ b/stdlib/dbm/__init__.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Iterator, MutableMapping, Tuple, Type, Union +from typing import Iterator, MutableMapping, Tuple, Type from typing_extensions import Literal _KeyType = str | bytes diff --git a/stdlib/dbm/dumb.pyi b/stdlib/dbm/dumb.pyi index 5c5c54450528..cedd8974790c 100644 --- a/stdlib/dbm/dumb.pyi +++ b/stdlib/dbm/dumb.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Iterator, MutableMapping, Type, Union +from typing import Iterator, MutableMapping, Type _KeyType = str | bytes _ValueType = str | bytes diff --git a/stdlib/dbm/gnu.pyi b/stdlib/dbm/gnu.pyi index 70497457460f..2f1ae651fddd 100644 --- a/stdlib/dbm/gnu.pyi +++ b/stdlib/dbm/gnu.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import List, Type, TypeVar, Union, overload +from typing import List, Type, TypeVar, overload _T = TypeVar("_T") _KeyType = str | bytes diff --git a/stdlib/dbm/ndbm.pyi b/stdlib/dbm/ndbm.pyi index 27951992473b..84d0338ebce8 100644 --- a/stdlib/dbm/ndbm.pyi +++ b/stdlib/dbm/ndbm.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import List, Type, TypeVar, Union, overload +from typing import List, Type, TypeVar, overload _T = TypeVar("_T") _KeyType = str | bytes diff --git a/stdlib/distutils/cmd.pyi b/stdlib/distutils/cmd.pyi index 309a66f1ac59..d899015fa74c 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, Optional, Tuple class Command: sub_commands: List[Tuple[str, Optional[Callable[[Command], bool]]]] diff --git a/stdlib/distutils/command/config.pyi b/stdlib/distutils/command/config.pyi index 89a316324acc..5b1363f49310 100644 --- a/stdlib/distutils/command/config.pyi +++ b/stdlib/distutils/command/config.pyi @@ -3,7 +3,7 @@ from distutils.ccompiler import CCompiler from distutils.core import Command as Command from distutils.errors import DistutilsExecError as DistutilsExecError from distutils.sysconfig import customize_compiler as customize_compiler -from typing import Dict, List, Pattern, Sequence, Tuple, Union +from typing import Dict, List, Pattern, Sequence, Tuple LANG_EXT: Dict[str, str] diff --git a/stdlib/distutils/core.pyi b/stdlib/distutils/core.pyi index b56719ab69ee..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, Tuple, Type, Union +from typing import Any, List, Mapping, Tuple, Type def setup( *, diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index d64a5d634c21..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, 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/fancy_getopt.pyi b/stdlib/distutils/fancy_getopt.pyi index 879cb1aa8941..8260c2193339 100644 --- a/stdlib/distutils/fancy_getopt.pyi +++ b/stdlib/distutils/fancy_getopt.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, List, Mapping, Tuple, Union, overload +from typing import Any, Iterable, List, Mapping, Tuple, overload _Option = Tuple[str, str | None, str] _GR = Tuple[List[str], OptionDummy] diff --git a/stdlib/distutils/filelist.pyi b/stdlib/distutils/filelist.pyi index 64c13f08c38c..787e1bf5c745 100644 --- a/stdlib/distutils/filelist.pyi +++ b/stdlib/distutils/filelist.pyi @@ -1,4 +1,4 @@ -from typing import Iterable, List, Pattern, Union, overload +from typing import Iterable, List, Pattern, overload from typing_extensions import Literal # class is entirely undocumented diff --git a/stdlib/distutils/sysconfig.pyi b/stdlib/distutils/sysconfig.pyi index 6343f768f019..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, 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 826e9e78daa6..07b968f41c29 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, Optional, Tuple class TextFile: def __init__( diff --git a/stdlib/distutils/version.pyi b/stdlib/distutils/version.pyi index d1e8bf5019e8..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, Union +from typing import Pattern, Tuple, TypeVar _T = TypeVar("_T", bound=Version) diff --git a/stdlib/doctest.pyi b/stdlib/doctest.pyi index 0192e7c3eba8..e49750d910ea 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, Optional, Tuple, Type class TestResults(NamedTuple): failed: int diff --git a/stdlib/email/_header_value_parser.pyi b/stdlib/email/_header_value_parser.pyi index c9c8663f7925..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, 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/header.pyi b/stdlib/email/header.pyi index a5efb114876c..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, 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 7a7f94f91baf..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, Tuple, Type, Union +from typing import Any, Dict, Iterable, Mapping, Tuple, Type class BaseHeader(str): @property diff --git a/stdlib/email/policy.pyi b/stdlib/email/policy.pyi index 350383615fb4..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, 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 bc62e75d98f9..d86466762268 100644 --- a/stdlib/encodings/__init__.pyi +++ b/stdlib/encodings/__init__.pyi @@ -1,5 +1,5 @@ from codecs import CodecInfo -from typing import Any, Union +from typing import Any class CodecRegistryError(LookupError, SystemError): ... diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index 75d0e29283b2..d1f2f673178f 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/fcntl.pyi b/stdlib/fcntl.pyi index 4d590a40de28..4c314b4756a9 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import FileDescriptorLike from array import array -from typing import Any, Union, overload +from typing import Any, overload from typing_extensions import Literal FASYNC: int diff --git a/stdlib/filecmp.pyi b/stdlib/filecmp.pyi index 2a4ad5f80908..8b16bf87a986 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, 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 b994e83f4652..7ef45a324c3e 100644 --- a/stdlib/fileinput.pyi +++ b/stdlib/fileinput.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import 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, 10): def input( diff --git a/stdlib/fractions.pyi b/stdlib/fractions.pyi index 37a14bf6ee1b..2ff1fac38c66 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, overload from typing_extensions import Literal _ComparableNum = int | float | Decimal | Real 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/glob.pyi b/stdlib/glob.pyi index 668fa29147f2..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, 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/gzip.pyi b/stdlib/gzip.pyi index eee5ebedd976..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, Protocol, TextIO, Union, overload +from typing import Any, Protocol, TextIO, overload from typing_extensions import Literal _ReadBinaryMode = Literal["r", "rb"] diff --git a/stdlib/http/cookiejar.pyi b/stdlib/http/cookiejar.pyi index 635306509ba5..e9778d06d53e 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 Dict, Iterable, Iterator, Sequence, Tuple, TypeVar, Union, overload +from typing import Dict, Iterable, Iterator, Sequence, Tuple, TypeVar, overload from urllib.request import Request _T = TypeVar("_T") diff --git a/stdlib/http/server.pyi b/stdlib/http/server.pyi index 9be344c43cbb..c7e6ef695943 100644 --- a/stdlib/http/server.pyi +++ b/stdlib/http/server.pyi @@ -2,7 +2,7 @@ import email.message import socketserver import sys from _typeshed import StrPath -from typing import Any, ClassVar, Dict, List, Mapping, Sequence, Tuple, Union +from typing import Any, ClassVar, Dict, List, Mapping, Sequence, Tuple class HTTPServer(socketserver.TCPServer): server_name: str diff --git a/stdlib/imghdr.pyi b/stdlib/imghdr.pyi index 93ecceea9cb6..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, Protocol, Union, overload +from typing import Any, BinaryIO, Callable, List, Protocol, overload class _ReadableBinary(Protocol): def tell(self) -> int: ... diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index 8537a0782a90..8d0984252083 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, Protocol, Sequence, Tuple, Union +from typing import IO, Any, Iterator, Mapping, Protocol, Sequence, Tuple from typing_extensions import Literal, runtime_checkable _Path = bytes | str diff --git a/stdlib/importlib/machinery.pyi b/stdlib/importlib/machinery.pyi index 14cac8f9e1b4..53248791ed8b 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, 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/resources.pyi b/stdlib/importlib/resources.pyi index ab9610afadce..bd7c1af23595 100644 --- a/stdlib/importlib/resources.pyi +++ b/stdlib/importlib/resources.pyi @@ -6,7 +6,7 @@ if sys.version_info >= (3, 7): import os from pathlib import Path from types import ModuleType - from typing import BinaryIO, ContextManager, Iterator, TextIO, Union + from typing import BinaryIO, ContextManager, Iterator, TextIO Package = str | ModuleType Resource = str | os.PathLike[Any] diff --git a/stdlib/io.pyi b/stdlib/io.pyi index 6b46faf05b31..00e291acebb7 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -3,7 +3,7 @@ import codecs import sys from _typeshed import ReadableBuffer, WriteableBuffer from types import TracebackType -from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, List, Optional, TextIO, Tuple, Type, TypeVar, Union +from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, List, Optional, TextIO, Tuple, Type, TypeVar DEFAULT_BUFFER_SIZE: int diff --git a/stdlib/json/__init__.pyi b/stdlib/json/__init__.pyi index b3f86dedb8d7..164febd284e1 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, Optional, Tuple, Type from .decoder import JSONDecodeError as JSONDecodeError, JSONDecoder as JSONDecoder from .encoder import JSONEncoder as JSONEncoder diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index 8fb6e809daf4..1b0574eb2477 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -1,5 +1,5 @@ from lib2to3.pgen2.grammar import Grammar -from typing import Any, Callable, Dict, Iterator, List, Tuple, TypeVar, Union +from typing import Any, Callable, Dict, Iterator, List, Tuple, TypeVar _P = TypeVar("_P") _NL = Node | Leaf diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index e5b81b3a91a9..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, 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 8147f34a13d1..3f0567ac636f 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, Optional, Pattern if sys.version_info >= (3, 8): from typing import Literal diff --git a/stdlib/lzma.pyi b/stdlib/lzma.pyi index c56f0c9146bf..22ea2b5b6337 100644 --- a/stdlib/lzma.pyi +++ b/stdlib/lzma.pyi @@ -1,6 +1,6 @@ import io from _typeshed import ReadableBuffer, StrOrBytesPath -from typing import IO, Any, Mapping, Sequence, TextIO, TypeVar, Union, overload +from typing import IO, Any, Mapping, Sequence, TextIO, TypeVar, overload from typing_extensions import Literal _OpenBinaryWritingMode = Literal["w", "wb", "x", "xb", "a", "ab"] diff --git a/stdlib/mailcap.pyi b/stdlib/mailcap.pyi index b0c538c6bbcd..83624bce39e0 100644 --- a/stdlib/mailcap.pyi +++ b/stdlib/mailcap.pyi @@ -1,4 +1,4 @@ -from typing import Dict, List, Mapping, Sequence, Tuple, Union +from typing import Dict, List, Mapping, Sequence, Tuple _Cap = Dict[str, str | int] diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index ebb2681eb344..52ce63f2b2f7 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -1,6 +1,6 @@ import sys from _typeshed import ReadableBuffer -from typing import AnyStr, ContextManager, Generic, Iterable, Iterator, Sized, Union, overload +from typing import AnyStr, ContextManager, Generic, Iterable, Iterator, Sized, overload ACCESS_DEFAULT: int ACCESS_READ: int diff --git a/stdlib/msilib/__init__.pyi b/stdlib/msilib/__init__.pyi index 20fc8cb19e86..d9998fd265bf 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, 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/multiprocessing/__init__.pyi b/stdlib/multiprocessing/__init__.pyi index 8c976a9eae4a..dfb17878c6e3 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, Union, overload +from typing import Any, 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 fb8b5e87c956..1035598b1f8a 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -1,7 +1,7 @@ import socket import sys import types -from typing import Any, Iterable, List, Tuple, Type, Union +from typing import Any, Iterable, List, Tuple, Type if sys.version_info >= (3, 8): from typing import SupportsIndex diff --git a/stdlib/multiprocessing/context.pyi b/stdlib/multiprocessing/context.pyi index fc686481f024..582c952be93c 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, Type, TypeVar, Union, overload +from typing import Any, Type, TypeVar, overload from typing_extensions import Literal _LockLike = synchronize.Lock | synchronize.RLock diff --git a/stdlib/multiprocessing/dummy/connection.pyi b/stdlib/multiprocessing/dummy/connection.pyi index 6a8a250cee41..79cfb6a405ad 100644 --- a/stdlib/multiprocessing/dummy/connection.pyi +++ b/stdlib/multiprocessing/dummy/connection.pyi @@ -1,6 +1,6 @@ from queue import Queue from types import TracebackType -from typing import Any, List, Tuple, Type, TypeVar, Union +from typing import Any, List, Tuple, Type, TypeVar families: List[None] diff --git a/stdlib/multiprocessing/sharedctypes.pyi b/stdlib/multiprocessing/sharedctypes.pyi index 9b968d6e3d7d..0f1ffd5547ff 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, 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/synchronize.pyi b/stdlib/multiprocessing/synchronize.pyi index 6ce8c5f6e9de..2d82464652f3 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, Union +from typing import Any, Callable, ContextManager _LockLike = Lock | RLock diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index f466e79a9d29..cfbba920b9f8 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -3,7 +3,7 @@ from _typeshed import OpenBinaryMode, OpenBinaryModeReading, OpenBinaryModeUpdat 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, 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 bb1b5c890787..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, 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/pkgutil.pyi b/stdlib/pkgutil.pyi index 105a6fe240e6..2d94feee2a2e 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, Optional, Tuple class ModuleInfo(NamedTuple): module_finder: MetaPathFinder | PathEntryFinder diff --git a/stdlib/plistlib.pyi b/stdlib/plistlib.pyi index b69c8456bc57..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, Type, Union +from typing import IO, Any, Dict as DictT, Mapping, MutableMapping, Type class PlistFormat(Enum): FMT_XML: int diff --git a/stdlib/profile.pyi b/stdlib/profile.pyi index bf3ea56164d5..45c11e010709 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, Optional, Tuple, TypeVar def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( 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/pyclbr.pyi b/stdlib/pyclbr.pyi index 7fa94d2d5a2f..a558495a9abd 100644 --- a/stdlib/pyclbr.pyi +++ b/stdlib/pyclbr.pyi @@ -1,5 +1,5 @@ import sys -from typing import Dict, List, Sequence, Union +from typing import Dict, List, Sequence class Class: module: str diff --git a/stdlib/random.pyi b/stdlib/random.pyi index 9649ded7d55b..d46800eb3460 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -1,7 +1,7 @@ import _random import sys from collections.abc import Callable, Iterable, MutableSequence, Sequence, Set -from typing import Any, NoReturn, Optional, Tuple, TypeVar, Union +from typing import Any, NoReturn, Optional, Tuple, TypeVar _T = TypeVar("_T") diff --git a/stdlib/re.pyi b/stdlib/re.pyi index de6bd5574ddb..cd008f8903dd 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, Tuple, Union, overload +from typing import Any, AnyStr, Callable, Iterator, List, Tuple, overload # ----- re variables and constants ----- if sys.version_info >= (3, 7): diff --git a/stdlib/shlex.pyi b/stdlib/shlex.pyi index a0e611d3e764..ac04f9ae863f 100644 --- a/stdlib/shlex.pyi +++ b/stdlib/shlex.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Iterable, List, 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/smtpd.pyi b/stdlib/smtpd.pyi index aefe08d5f071..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, 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 a47d92caa249..da3d158aa0f7 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -2,7 +2,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, Pattern, Protocol, Sequence, Tuple, Type, Union, overload +from typing import Any, Dict, Pattern, Protocol, Sequence, Tuple, Type, overload _Reply = Tuple[int, bytes] _SendErrs = Dict[str, _Reply] diff --git a/stdlib/sndhdr.pyi b/stdlib/sndhdr.pyi index 69779d7db06a..84d6441a83b1 100644 --- a/stdlib/sndhdr.pyi +++ b/stdlib/sndhdr.pyi @@ -1,5 +1,5 @@ from _typeshed import StrOrBytesPath -from typing import NamedTuple, Union +from typing import NamedTuple class SndHeaders(NamedTuple): filetype: str diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index 6b28577cfd78..5671b67e6b19 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -3,7 +3,7 @@ from _typeshed import ReadableBuffer, WriteableBuffer from collections.abc import Iterable from enum import IntEnum, IntFlag from io import RawIOBase -from typing import Any, BinaryIO, 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 a4fa37265617..5bac7a46b863 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -1,7 +1,7 @@ import sys import types from socket import socket as _socket -from typing import Any, BinaryIO, Callable, ClassVar, Set, Tuple, Type, TypeVar, Union +from typing import Any, BinaryIO, Callable, ClassVar, Set, Tuple, Type, TypeVar _T = TypeVar("_T") _RequestType = _socket | Tuple[bytes, _socket] diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index f6716c04d5f4..206afea66bc9 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import 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, Optional, 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 626312a428ec..22e0a6942219 100644 --- a/stdlib/sre_constants.pyi +++ b/stdlib/sre_constants.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Dict, List, Union +from typing import Any, Dict, List MAGIC: int diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index 2d5a292d5b53..1ae2b5e040c6 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, Sequence, SupportsFloat, Type, TypeVar, Union +from typing import Any, Hashable, Iterable, List, NamedTuple, Sequence, SupportsFloat, Type, TypeVar _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 30c72244cdcc..ceed38f00931 100644 --- a/stdlib/string.pyi +++ b/stdlib/string.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Mapping, 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 7c72efbedee3..4267494620b0 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -1,7 +1,7 @@ import sys from _typeshed import StrOrBytesPath from types import TracebackType -from typing import IO, Any, AnyStr, Callable, Generic, Mapping, Optional, Sequence, Tuple, Type, TypeVar, Union, overload +from typing import IO, Any, AnyStr, Callable, Generic, Mapping, Optional, Sequence, Tuple, Type, TypeVar, overload from typing_extensions import Literal if sys.version_info >= (3, 9): diff --git a/stdlib/sunau.pyi b/stdlib/sunau.pyi index d7f379f66790..faaccc727287 100644 --- a/stdlib/sunau.pyi +++ b/stdlib/sunau.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Any, NamedTuple, NoReturn, Union +from typing import IO, Any, NamedTuple, NoReturn _File = str | IO[bytes] diff --git a/stdlib/telnetlib.pyi b/stdlib/telnetlib.pyi index 5317e082811f..164cb3be8153 100644 --- a/stdlib/telnetlib.pyi +++ b/stdlib/telnetlib.pyi @@ -1,5 +1,5 @@ import socket -from typing import Any, Callable, Match, Optional, Pattern, Sequence, Tuple, Union +from typing import Any, Callable, Match, Optional, Pattern, Sequence, Tuple DEBUGLEVEL: int TELNET_PORT: int diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index fb953c5248a2..8d2a548fd825 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -1,7 +1,7 @@ import os import sys from types import TracebackType -from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, List, Tuple, Type, TypeVar, Union, overload +from typing import IO, Any, AnyStr, Generic, Iterable, Iterator, List, Tuple, Type, TypeVar, overload from typing_extensions import Literal if sys.version_info >= (3, 9): diff --git a/stdlib/termios.pyi b/stdlib/termios.pyi index 86da7243817d..a0774e7f1728 100644 --- a/stdlib/termios.pyi +++ b/stdlib/termios.pyi @@ -1,5 +1,5 @@ from _typeshed import FileDescriptorLike -from typing import Any, List, Union +from typing import Any, List _Attr = List[int | List[bytes | int]] diff --git a/stdlib/threading.pyi b/stdlib/threading.pyi index 686380756c34..b32c2f49a4a7 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], Callable[..., Any] | None] diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index 8c18e24a9c1c..78b4cbbb2818 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -1,6 +1,6 @@ import sys import tkinter -from typing import Any, List, Tuple, TypeVar, Union, overload +from typing import Any, List, Tuple, TypeVar, overload from typing_extensions import Literal, TypedDict NORMAL: Literal["normal"] diff --git a/stdlib/trace.pyi b/stdlib/trace.pyi index b70abc7c2af6..54ac91fb2c02 100644 --- a/stdlib/trace.pyi +++ b/stdlib/trace.pyi @@ -1,6 +1,6 @@ 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/tty.pyi b/stdlib/tty.pyi index 47132006edeb..c25f22a5a4ff 100644 --- a/stdlib/tty.pyi +++ b/stdlib/tty.pyi @@ -1,4 +1,4 @@ -from typing import IO, Union +from typing import IO _FD = int | IO[str] 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/main.pyi b/stdlib/unittest/main.pyi index 57fb7557a5a8..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, 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/runner.pyi b/stdlib/unittest/runner.pyi index 4ad97c0ba58a..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, TextIO, Tuple, Type, Union +from typing import Callable, TextIO, Tuple, Type _ResultClassType = Callable[[TextIO, bool, int], unittest.result.TestResult] diff --git a/stdlib/unittest/suite.pyi b/stdlib/unittest/suite.pyi index 496d3fa442ba..15a77227c497 100644 --- a/stdlib/unittest/suite.pyi +++ b/stdlib/unittest/suite.pyi @@ -1,6 +1,6 @@ import unittest.case import unittest.result -from typing import Iterable, Iterator, List, Union +from typing import Iterable, Iterator, List _TestType = unittest.case.TestCase | TestSuite diff --git a/stdlib/urllib/error.pyi b/stdlib/urllib/error.pyi index deefebb352e1..e13a445fff77 100644 --- a/stdlib/urllib/error.pyi +++ b/stdlib/urllib/error.pyi @@ -1,5 +1,5 @@ from email.message import Message -from typing import IO, Mapping, Tuple, Union +from typing import IO, Mapping, Tuple from urllib.response import addinfourl # Stubs for urllib.error diff --git a/stdlib/uu.pyi b/stdlib/uu.pyi index fd7e83dc0f6a..3687a843d39d 100644 --- a/stdlib/uu.pyi +++ b/stdlib/uu.pyi @@ -1,5 +1,5 @@ import sys -from typing import BinaryIO, Union +from typing import BinaryIO _File = str | BinaryIO diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index d55db01ec559..c8bb573a9eee 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -1,5 +1,5 @@ from types import ModuleType, TracebackType -from typing import Any, List, 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 645d28331054..affa3b252e75 100644 --- a/stdlib/wave.pyi +++ b/stdlib/wave.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Any, BinaryIO, NamedTuple, NoReturn, Union +from typing import IO, Any, BinaryIO, NamedTuple, NoReturn _File = str | IO[bytes] diff --git a/stdlib/webbrowser.pyi b/stdlib/webbrowser.pyi index 216af49c2e78..66bc5fb59974 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, Optional, Sequence class Error(Exception): ... diff --git a/stdlib/winreg.pyi b/stdlib/winreg.pyi index 5e7f63c9d101..0edebbf0969e 100644 --- a/stdlib/winreg.pyi +++ b/stdlib/winreg.pyi @@ -1,5 +1,5 @@ from types import TracebackType -from typing import Any, Tuple, Type, Union +from typing import Any, Tuple, Type _KeyType = HKEYType | int diff --git a/stdlib/xml/dom/minidom.pyi b/stdlib/xml/dom/minidom.pyi index 138ed6369e1d..3de069bc7eed 100644 --- a/stdlib/xml/dom/minidom.pyi +++ b/stdlib/xml/dom/minidom.pyi @@ -1,6 +1,6 @@ import sys import xml.dom -from typing import IO, Any, TypeVar, Union +from typing import IO, Any, TypeVar from xml.dom.xmlbuilder import DocumentLS, DOMImplementationLS from xml.sax.xmlreader import XMLReader diff --git a/stdlib/xml/etree/ElementInclude.pyi b/stdlib/xml/etree/ElementInclude.pyi index 20cec64556ae..398eb5243c48 100644 --- a/stdlib/xml/etree/ElementInclude.pyi +++ b/stdlib/xml/etree/ElementInclude.pyi @@ -1,5 +1,5 @@ import sys -from typing import Callable, 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 66e1139ee161..4e75e924eecc 100644 --- a/stdlib/xml/etree/ElementPath.pyi +++ b/stdlib/xml/etree/ElementPath.pyi @@ -1,4 +1,4 @@ -from typing import Callable, Dict, Generator, List, 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/sax/__init__.pyi b/stdlib/xml/sax/__init__.pyi index d8b83df8dd9e..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, 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/zipapp.pyi b/stdlib/zipapp.pyi index 06f62f992f63..89a37cb20cd0 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, Optional _Path = str | Path | BinaryIO diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index a0cd2f1bf38b..79dab171bfc7 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -2,7 +2,7 @@ import io import sys from _typeshed import 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, Optional, 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 593d2b047f3a..028fa4835c05 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, 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 052537b8f7a1..5acc4190f1fe 100644 --- a/stdlib/zlib.pyi +++ b/stdlib/zlib.pyi @@ -1,5 +1,5 @@ from array import array -from typing import Any, Union +from typing import Any DEFLATED: int DEF_MEM_LEVEL: int From 285129a321733e3163a5c2bc57e226ce7472326a Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 1 Jun 2021 00:42:51 -0700 Subject: [PATCH 16/16] black and isort --- stdlib/@python2/UserDict.pyi | 17 +---- stdlib/@python2/__builtin__.pyi | 32 +++------- stdlib/@python2/_io.pyi | 8 +-- stdlib/@python2/_sha256.pyi | 2 - stdlib/@python2/_sha512.pyi | 2 - stdlib/@python2/argparse.pyi | 17 +---- stdlib/@python2/bdb.pyi | 8 +-- stdlib/@python2/builtins.pyi | 32 +++------- stdlib/@python2/bz2.pyi | 4 +- stdlib/@python2/cgitb.pyi | 11 +--- stdlib/@python2/codecs.pyi | 21 ++----- stdlib/@python2/collections.pyi | 5 +- stdlib/@python2/compileall.pyi | 7 +-- stdlib/@python2/csv.pyi | 1 - stdlib/@python2/ctypes/__init__.pyi | 1 - stdlib/@python2/datetime.pyi | 7 +-- stdlib/@python2/distutils/archive_util.pyi | 9 +-- stdlib/@python2/distutils/command/config.pyi | 6 +- stdlib/@python2/doctest.pyi | 11 +--- stdlib/@python2/ensurepip/__init__.pyi | 2 - stdlib/@python2/fractions.pyi | 6 +- stdlib/@python2/lib2to3/pytree.pyi | 7 +-- stdlib/@python2/logging/__init__.pyi | 8 +-- stdlib/@python2/logging/config.pyi | 4 +- stdlib/@python2/logging/handlers.pyi | 4 +- stdlib/@python2/macurl2path.pyi | 2 - stdlib/@python2/mailbox.pyi | 8 +-- stdlib/@python2/mmap.pyi | 4 +- stdlib/@python2/msilib/__init__.pyi | 26 +------- stdlib/@python2/msilib/schema.pyi | 4 +- stdlib/@python2/multiprocessing/process.pyi | 4 +- stdlib/@python2/nntplib.pyi | 4 +- stdlib/@python2/optparse.pyi | 4 +- stdlib/@python2/pdb.pyi | 6 +- stdlib/@python2/pickletools.pyi | 5 +- stdlib/@python2/pprint.pyi | 4 +- stdlib/@python2/py_compile.pyi | 4 +- stdlib/@python2/pydoc.pyi | 4 +- stdlib/@python2/re.pyi | 12 +--- stdlib/@python2/ssl.pyi | 4 +- stdlib/@python2/tarfile.pyi | 4 +- stdlib/@python2/tempfile.pyi | 4 +- stdlib/@python2/trace.pyi | 5 +- stdlib/@python2/turtle.pyi | 6 +- stdlib/@python2/types.pyi | 4 +- stdlib/@python2/typing.pyi | 12 +--- stdlib/@python2/typing_extensions.pyi | 2 - stdlib/@python2/unittest.pyi | 4 +- stdlib/@python2/urllib2.pyi | 4 +- stdlib/@python2/warnings.pyi | 11 +--- stdlib/@python2/xml/dom/minidom.pyi | 4 +- stdlib/@python2/xml/etree/ElementPath.pyi | 4 +- stdlib/@python2/xml/etree/ElementTree.pyi | 12 +--- stdlib/@python2/zipfile.pyi | 8 +-- stdlib/_codecs.pyi | 4 +- stdlib/argparse.pyi | 18 ++---- stdlib/asyncio/base_events.pyi | 21 +------ stdlib/asyncio/events.pyi | 21 +------ 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 | 66 +++++--------------- stdlib/bz2.pyi | 6 +- stdlib/cgitb.pyi | 4 +- stdlib/codecs.pyi | 17 ++--- stdlib/collections/__init__.pyi | 11 +--- stdlib/concurrent/futures/_base.pyi | 16 +---- stdlib/configparser.pyi | 14 +---- stdlib/contextlib.pyi | 11 +--- stdlib/ctypes/__init__.pyi | 8 +-- stdlib/difflib.pyi | 4 +- stdlib/dis.pyi | 4 +- stdlib/distutils/archive_util.pyi | 2 - stdlib/distutils/command/config.pyi | 6 +- stdlib/distutils/debug.pyi | 2 - stdlib/distutils/filelist.pyi | 17 +---- stdlib/doctest.pyi | 11 +--- stdlib/email/generator.pyi | 14 +---- stdlib/email/mime/text.pyi | 4 +- stdlib/ensurepip/__init__.pyi | 2 - stdlib/filecmp.pyi | 5 +- stdlib/fractions.pyi | 6 +- stdlib/functools.pyi | 2 - stdlib/http/client.pyi | 15 +---- stdlib/http/cookiejar.pyi | 8 +-- stdlib/importlib/machinery.pyi | 12 +--- stdlib/itertools.pyi | 4 +- stdlib/lib2to3/pytree.pyi | 7 +-- stdlib/logging/__init__.pyi | 11 +--- stdlib/logging/config.pyi | 4 +- stdlib/logging/handlers.pyi | 15 +---- stdlib/lzma.pyi | 4 +- stdlib/macurl2path.pyi | 2 - 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 | 35 ++--------- 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 | 4 +- stdlib/random.pyi | 10 +-- stdlib/shutil.pyi | 4 +- stdlib/smtplib.pyi | 10 +-- stdlib/socket.pyi | 6 +- stdlib/ssl.pyi | 8 +-- stdlib/sys.pyi | 5 +- stdlib/tarfile.pyi | 4 +- stdlib/tempfile.pyi | 8 +-- stdlib/tkinter/__init__.pyi | 30 +++------ stdlib/tkinter/tix.pyi | 8 +-- stdlib/tokenize.pyi | 17 +---- stdlib/trace.pyi | 5 +- stdlib/tracemalloc.pyi | 7 +-- stdlib/turtle.pyi | 13 +--- stdlib/typing.pyi | 5 +- stdlib/typing_extensions.pyi | 2 - stdlib/unittest/case.pyi | 4 +- stdlib/unittest/result.pyi | 8 +-- stdlib/urllib/parse.pyi | 4 +- stdlib/urllib/request.pyi | 8 +-- stdlib/warnings.pyi | 11 +--- stdlib/xml/dom/minidom.pyi | 4 +- stdlib/xml/etree/ElementInclude.pyi | 5 +- stdlib/xml/etree/ElementPath.pyi | 4 +- stdlib/xml/etree/ElementTree.pyi | 6 +- stdlib/xmlrpc/client.pyi | 4 +- stdlib/xmlrpc/server.pyi | 12 +--- stdlib/zipfile.pyi | 19 ++---- stdlib/zipimport.pyi | 4 +- 141 files changed, 240 insertions(+), 1010 deletions(-) diff --git a/stdlib/@python2/UserDict.pyi b/stdlib/@python2/UserDict.pyi index fea2d391bb82..dce7bebafd66 100644 --- a/stdlib/@python2/UserDict.pyi +++ b/stdlib/@python2/UserDict.pyi @@ -1,19 +1,4 @@ -from typing import ( - Any, - Container, - Dict, - Generic, - Iterable, - Iterator, - List, - Mapping, - - Sized, - Tuple, - TypeVar, - - overload, -) +from typing import Any, Container, Dict, Generic, Iterable, Iterator, List, Mapping, Sized, Tuple, TypeVar, overload _KT = TypeVar("_KT") _VT = TypeVar("_VT") diff --git a/stdlib/@python2/__builtin__.pyi b/stdlib/@python2/__builtin__.pyi index 252b0b54fea0..6ebab9355d22 100644 --- a/stdlib/@python2/__builtin__.pyi +++ b/stdlib/@python2/__builtin__.pyi @@ -295,9 +295,7 @@ class unicode(basestring, Sequence[unicode]): def count(self, x: unicode) -> int: ... def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ... def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... - def endswith( - self, __suffix: unicode | Tuple[unicode, ...], __start: int | None = ..., __end: int | None = ... - ) -> bool: ... + def endswith(self, __suffix: unicode | Tuple[unicode, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... def expandtabs(self, tabsize: int = ...) -> unicode: ... def find(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... def format(self, *args: object, **kwargs: object) -> unicode: ... @@ -327,9 +325,7 @@ class unicode(basestring, Sequence[unicode]): def rstrip(self, chars: unicode = ...) -> unicode: ... def split(self, sep: unicode | None = ..., maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[unicode]: ... - def startswith( - self, __prefix: unicode | Tuple[unicode, ...], __start: int | None = ..., __end: int | None = ... - ) -> bool: ... + def startswith(self, __prefix: unicode | Tuple[unicode, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... def strip(self, chars: unicode = ...) -> unicode: ... def swapcase(self) -> unicode: ... def title(self) -> unicode: ... @@ -372,9 +368,7 @@ class str(Sequence[str], basestring): def count(self, x: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... def encode(self, encoding: Text = ..., errors: Text = ...) -> bytes: ... - def endswith( - self, __suffix: Text | Tuple[Text, ...], __start: int | None = ..., __end: int | None = ... - ) -> bool: ... + def endswith(self, __suffix: Text | Tuple[Text, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... def expandtabs(self, tabsize: int = ...) -> str: ... def find(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... def format(self, *args: object, **kwargs: object) -> str: ... @@ -423,9 +417,7 @@ class str(Sequence[str], basestring): @overload def split(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[str]: ... - def startswith( - self, __prefix: Text | Tuple[Text, ...], __start: int | None = ..., __end: int | None = ... - ) -> bool: ... + def startswith(self, __prefix: Text | Tuple[Text, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... @overload def strip(self, __chars: str = ...) -> str: ... @overload @@ -475,9 +467,7 @@ class bytearray(MutableSequence[int], ByteString): def center(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... def count(self, __sub: str) -> int: ... def decode(self, encoding: Text = ..., errors: Text = ...) -> str: ... - def endswith( - self, __suffix: bytes | Tuple[bytes, ...], __start: int | None = ..., __end: int | None = ... - ) -> bool: ... + def endswith(self, __suffix: bytes | Tuple[bytes, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... def expandtabs(self, tabsize: int = ...) -> bytearray: ... def extend(self, iterable: str | Iterable[int]) -> None: ... def find(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ... @@ -504,9 +494,7 @@ class bytearray(MutableSequence[int], ByteString): def rstrip(self, __bytes: bytes | None = ...) -> bytearray: ... def split(self, sep: bytes | None = ..., maxsplit: int = ...) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... - def startswith( - self, __prefix: bytes | Tuple[bytes, ...], __start: int | None = ..., __end: int | None = ... - ) -> bool: ... + def startswith(self, __prefix: bytes | Tuple[bytes, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... def strip(self, __bytes: bytes | None = ...) -> bytearray: ... def swapcase(self) -> bytearray: ... def title(self) -> bytearray: ... @@ -972,9 +960,7 @@ def open(name: unicode | int, mode: unicode = ..., buffering: int = ...) -> Bina def ord(__c: Text | bytes) -> int: ... # This is only available after from __future__ import print_function. -def print( - *values: object, sep: Text | None = ..., end: Text | None = ..., file: SupportsWrite[Any] | None = ... -) -> None: ... +def print(*values: object, sep: Text | None = ..., end: Text | None = ..., file: SupportsWrite[Any] | None = ...) -> None: ... _E = TypeVar("_E", contravariant=True) _M = TypeVar("_M", contravariant=True) @@ -1181,9 +1167,7 @@ class file(BinaryIO): def next(self) -> str: ... def read(self, n: int = ...) -> str: ... def __enter__(self) -> BinaryIO: ... - def __exit__( - self, t: type | None = ..., exc: BaseException | None = ..., tb: Any | None = ... - ) -> bool | None: ... + def __exit__(self, t: type | None = ..., exc: BaseException | None = ..., tb: Any | None = ...) -> bool | None: ... def flush(self) -> None: ... def fileno(self) -> int: ... def isatty(self) -> bool: ... diff --git a/stdlib/@python2/_io.pyi b/stdlib/@python2/_io.pyi index d8ba56ebbc8c..5e8d5bfe2d3e 100644 --- a/stdlib/@python2/_io.pyi +++ b/stdlib/@python2/_io.pyi @@ -31,9 +31,7 @@ class _IOBase(BinaryIO): def truncate(self, size: int | None = ...) -> int: ... def writable(self) -> bool: ... def __enter__(self: _T) -> _T: ... - def __exit__( - self, t: Type[BaseException] | None, value: BaseException | None, traceback: Any | None - ) -> bool | None: ... + def __exit__(self, t: Type[BaseException] | None, value: BaseException | None, traceback: Any | None) -> bool | None: ... def __iter__(self: _T) -> _T: ... # The parameter type of writelines[s]() is determined by that of write(): def writelines(self, lines: Iterable[bytes]) -> None: ... @@ -141,9 +139,7 @@ class _TextIOBase(TextIO): def write(self, pbuf: unicode) -> int: ... def writelines(self, lines: Iterable[unicode]) -> None: ... def __enter__(self: _T) -> _T: ... - def __exit__( - self, t: Type[BaseException] | None, value: BaseException | None, traceback: Any | None - ) -> bool | None: ... + def __exit__(self, t: Type[BaseException] | None, value: BaseException | None, traceback: Any | None) -> bool | None: ... def __iter__(self: _T) -> _T: ... class StringIO(_TextIOBase): diff --git a/stdlib/@python2/_sha256.pyi b/stdlib/@python2/_sha256.pyi index 5427e384390d..746432094bf2 100644 --- a/stdlib/@python2/_sha256.pyi +++ b/stdlib/@python2/_sha256.pyi @@ -1,5 +1,3 @@ - - class sha224(object): name: str block_size: int diff --git a/stdlib/@python2/_sha512.pyi b/stdlib/@python2/_sha512.pyi index e07adaed60cc..90e2aee1542f 100644 --- a/stdlib/@python2/_sha512.pyi +++ b/stdlib/@python2/_sha512.pyi @@ -1,5 +1,3 @@ - - class sha384(object): name: str block_size: int diff --git a/stdlib/@python2/argparse.pyi b/stdlib/@python2/argparse.pyi index 6b71a2e9d34b..785cea7da83d 100644 --- a/stdlib/@python2/argparse.pyi +++ b/stdlib/@python2/argparse.pyi @@ -58,9 +58,7 @@ class _ActionsContainer: _defaults: Dict[str, Any] _negative_number_matcher: Pattern[str] _has_negative_number_optionals: List[bool] - def __init__( - self, description: Text | None, prefix_chars: Text, argument_default: Any, conflict_handler: Text - ) -> None: ... + def __init__(self, description: Text | None, prefix_chars: Text, argument_default: Any, conflict_handler: Text) -> None: ... def register(self, registry_name: Text, value: Any, object: Any) -> None: ... def _registry_get(self, registry_name: Text, value: Any, default: Any = ...) -> Any: ... def set_defaults(self, **kwargs: Any) -> None: ... @@ -250,11 +248,7 @@ class Action(_AttributeHolder): metavar: Text | Tuple[Text, ...] | None = ..., ) -> None: ... def __call__( - self, - parser: ArgumentParser, - namespace: Namespace, - values: Text | Sequence[Any] | None, - option_string: Text | None = ..., + self, parser: ArgumentParser, namespace: Namespace, values: Text | Sequence[Any] | None, option_string: Text | None = ... ) -> None: ... class Namespace(_AttributeHolder): @@ -344,12 +338,7 @@ class _HelpAction(Action): class _VersionAction(Action): version: _Text | None def __init__( - self, - option_strings: Sequence[Text], - version: Text | None = ..., - dest: Text = ..., - default: Text = ..., - help: Text = ..., + self, option_strings: Sequence[Text], version: Text | None = ..., dest: Text = ..., default: Text = ..., help: Text = ... ) -> None: ... # undocumented diff --git a/stdlib/@python2/bdb.pyi b/stdlib/@python2/bdb.pyi index 4816d183b44d..5bee9dadb928 100644 --- a/stdlib/@python2/bdb.pyi +++ b/stdlib/@python2/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/@python2/builtins.pyi b/stdlib/@python2/builtins.pyi index 252b0b54fea0..6ebab9355d22 100644 --- a/stdlib/@python2/builtins.pyi +++ b/stdlib/@python2/builtins.pyi @@ -295,9 +295,7 @@ class unicode(basestring, Sequence[unicode]): def count(self, x: unicode) -> int: ... def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ... def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... - def endswith( - self, __suffix: unicode | Tuple[unicode, ...], __start: int | None = ..., __end: int | None = ... - ) -> bool: ... + def endswith(self, __suffix: unicode | Tuple[unicode, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... def expandtabs(self, tabsize: int = ...) -> unicode: ... def find(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... def format(self, *args: object, **kwargs: object) -> unicode: ... @@ -327,9 +325,7 @@ class unicode(basestring, Sequence[unicode]): def rstrip(self, chars: unicode = ...) -> unicode: ... def split(self, sep: unicode | None = ..., maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[unicode]: ... - def startswith( - self, __prefix: unicode | Tuple[unicode, ...], __start: int | None = ..., __end: int | None = ... - ) -> bool: ... + def startswith(self, __prefix: unicode | Tuple[unicode, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... def strip(self, chars: unicode = ...) -> unicode: ... def swapcase(self) -> unicode: ... def title(self) -> unicode: ... @@ -372,9 +368,7 @@ class str(Sequence[str], basestring): def count(self, x: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... def encode(self, encoding: Text = ..., errors: Text = ...) -> bytes: ... - def endswith( - self, __suffix: Text | Tuple[Text, ...], __start: int | None = ..., __end: int | None = ... - ) -> bool: ... + def endswith(self, __suffix: Text | Tuple[Text, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... def expandtabs(self, tabsize: int = ...) -> str: ... def find(self, sub: Text, __start: int | None = ..., __end: int | None = ...) -> int: ... def format(self, *args: object, **kwargs: object) -> str: ... @@ -423,9 +417,7 @@ class str(Sequence[str], basestring): @overload def split(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[str]: ... - def startswith( - self, __prefix: Text | Tuple[Text, ...], __start: int | None = ..., __end: int | None = ... - ) -> bool: ... + def startswith(self, __prefix: Text | Tuple[Text, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... @overload def strip(self, __chars: str = ...) -> str: ... @overload @@ -475,9 +467,7 @@ class bytearray(MutableSequence[int], ByteString): def center(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... def count(self, __sub: str) -> int: ... def decode(self, encoding: Text = ..., errors: Text = ...) -> str: ... - def endswith( - self, __suffix: bytes | Tuple[bytes, ...], __start: int | None = ..., __end: int | None = ... - ) -> bool: ... + def endswith(self, __suffix: bytes | Tuple[bytes, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... def expandtabs(self, tabsize: int = ...) -> bytearray: ... def extend(self, iterable: str | Iterable[int]) -> None: ... def find(self, __sub: str, __start: int = ..., __end: int = ...) -> int: ... @@ -504,9 +494,7 @@ class bytearray(MutableSequence[int], ByteString): def rstrip(self, __bytes: bytes | None = ...) -> bytearray: ... def split(self, sep: bytes | None = ..., maxsplit: int = ...) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... - def startswith( - self, __prefix: bytes | Tuple[bytes, ...], __start: int | None = ..., __end: int | None = ... - ) -> bool: ... + def startswith(self, __prefix: bytes | Tuple[bytes, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... def strip(self, __bytes: bytes | None = ...) -> bytearray: ... def swapcase(self) -> bytearray: ... def title(self) -> bytearray: ... @@ -972,9 +960,7 @@ def open(name: unicode | int, mode: unicode = ..., buffering: int = ...) -> Bina def ord(__c: Text | bytes) -> int: ... # This is only available after from __future__ import print_function. -def print( - *values: object, sep: Text | None = ..., end: Text | None = ..., file: SupportsWrite[Any] | None = ... -) -> None: ... +def print(*values: object, sep: Text | None = ..., end: Text | None = ..., file: SupportsWrite[Any] | None = ...) -> None: ... _E = TypeVar("_E", contravariant=True) _M = TypeVar("_M", contravariant=True) @@ -1181,9 +1167,7 @@ class file(BinaryIO): def next(self) -> str: ... def read(self, n: int = ...) -> str: ... def __enter__(self) -> BinaryIO: ... - def __exit__( - self, t: type | None = ..., exc: BaseException | None = ..., tb: Any | None = ... - ) -> bool | None: ... + def __exit__(self, t: type | None = ..., exc: BaseException | None = ..., tb: Any | None = ...) -> bool | None: ... def flush(self) -> None: ... def fileno(self) -> int: ... def isatty(self) -> bool: ... diff --git a/stdlib/@python2/bz2.pyi b/stdlib/@python2/bz2.pyi index 792da2cbf31b..f04c9394a0e1 100644 --- a/stdlib/@python2/bz2.pyi +++ b/stdlib/@python2/bz2.pyi @@ -11,9 +11,7 @@ def decompress(data: bytes) -> bytes: ... class BZ2File(io.BufferedIOBase, IO[bytes]): def __enter__(self: _T) -> _T: ... - def __init__( - self, filename: _PathOrFile, mode: str = ..., buffering: Any | None = ..., compresslevel: int = ... - ) -> None: ... + def __init__(self, filename: _PathOrFile, mode: str = ..., buffering: Any | None = ..., compresslevel: int = ...) -> None: ... def read(self, size: int | None = ...) -> bytes: ... def read1(self, size: int = ...) -> bytes: ... def readline(self, size: SupportsIndex = ...) -> bytes: ... # type: ignore diff --git a/stdlib/@python2/cgitb.pyi b/stdlib/@python2/cgitb.pyi index 966e6cfb0b8e..c368d4839c8d 100644 --- a/stdlib/@python2/cgitb.pyi +++ b/stdlib/@python2/cgitb.pyi @@ -16,16 +16,9 @@ def text(einfo: _ExcInfo, context: int = ...) -> str: ... class Hook: # undocumented def __init__( - self, - display: int = ..., - logdir: Text | None = ..., - context: int = ..., - file: IO[str] | None = ..., - format: str = ..., - ) -> None: ... - def __call__( - self, etype: Type[BaseException] | None, evalue: BaseException | None, etb: TracebackType | None + self, display: int = ..., logdir: Text | None = ..., context: int = ..., file: IO[str] | None = ..., format: str = ... ) -> 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/@python2/codecs.pyi b/stdlib/@python2/codecs.pyi index 71c3c4c1af28..a7835106336d 100644 --- a/stdlib/@python2/codecs.pyi +++ b/stdlib/@python2/codecs.pyi @@ -9,7 +9,6 @@ from typing import ( Iterable, Iterator, List, - Protocol, Text, TextIO, @@ -124,9 +123,7 @@ def register(__search_function: Callable[[str], CodecInfo | None]) -> None: ... def open( filename: str, mode: str = ..., encoding: str | None = ..., errors: str = ..., buffering: int = ... ) -> StreamReaderWriter: ... -def EncodedFile( - file: IO[_Encoded], data_encoding: str, file_encoding: str | None = ..., errors: str = ... -) -> StreamRecoder: ... +def EncodedFile(file: IO[_Encoded], data_encoding: str, file_encoding: str | None = ..., errors: str = ...) -> StreamRecoder: ... def iterencode(iterator: Iterable[_Decoded], encoding: str, errors: str = ...) -> Generator[_Encoded, None, None]: ... def iterdecode(iterator: Iterable[_Encoded], encoding: str, errors: str = ...) -> Generator[_Decoded, None, None]: ... @@ -203,9 +200,7 @@ class StreamWriter(Codec): def writelines(self, list: Iterable[_Decoded]) -> None: ... def reset(self) -> None: ... def __enter__(self: _SW) -> _SW: ... - 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: ... _SR = TypeVar("_SR", bound=StreamReader) @@ -218,9 +213,7 @@ class StreamReader(Codec): def readlines(self, sizehint: int | None = ..., keepends: bool = ...) -> List[_Decoded]: ... def reset(self) -> None: ... def __enter__(self: _SR) -> _SR: ... - 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[_Decoded]: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... @@ -242,9 +235,7 @@ class StreamReaderWriter(TextIO): # Same as write() def seek(self, offset: int, whence: int = ...) -> int: ... def __enter__(self: _T) -> _T: ... - 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__. @@ -280,9 +271,7 @@ class StreamRecoder(BinaryIO): def reset(self) -> None: ... def __getattr__(self, name: str) -> Any: ... def __enter__(self: _SRT) -> _SRT: ... - 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/@python2/collections.pyi b/stdlib/@python2/collections.pyi index 09045e480152..ce4d5c1418d3 100644 --- a/stdlib/@python2/collections.pyi +++ b/stdlib/@python2/collections.pyi @@ -37,10 +37,7 @@ _VT = TypeVar("_VT") # namedtuple is special-cased in the type checker; the initializer is ignored. def namedtuple( - typename: str | unicode, - field_names: str | unicode | Iterable[str | unicode], - verbose: bool = ..., - rename: bool = ..., + typename: str | unicode, field_names: str | unicode | Iterable[str | unicode], verbose: bool = ..., rename: bool = ... ) -> Type[Tuple[Any, ...]]: ... class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]): diff --git a/stdlib/@python2/compileall.pyi b/stdlib/@python2/compileall.pyi index cd69bcdcb3a7..ef22929c4c19 100644 --- a/stdlib/@python2/compileall.pyi +++ b/stdlib/@python2/compileall.pyi @@ -2,12 +2,7 @@ from typing import Any, Pattern, Text # rx can be any object with a 'search' method; once we have Protocols we can change the type def compile_dir( - dir: Text, - maxlevels: int = ..., - ddir: Text | None = ..., - force: bool = ..., - rx: Pattern[Any] | None = ..., - quiet: int = ..., + dir: Text, maxlevels: int = ..., ddir: Text | None = ..., force: bool = ..., rx: Pattern[Any] | None = ..., quiet: int = ... ) -> int: ... def compile_file( fullname: Text, ddir: Text | None = ..., force: bool = ..., rx: Pattern[Any] | None = ..., quiet: int = ... diff --git a/stdlib/@python2/csv.pyi b/stdlib/@python2/csv.pyi index d1c9092d51f7..886de6210ca9 100644 --- a/stdlib/@python2/csv.pyi +++ b/stdlib/@python2/csv.pyi @@ -24,7 +24,6 @@ from typing import ( Iterator, List, Mapping, - Sequence, Text, Type, diff --git a/stdlib/@python2/ctypes/__init__.pyi b/stdlib/@python2/ctypes/__init__.pyi index 749d108d75c0..663e32bba3fa 100644 --- a/stdlib/@python2/ctypes/__init__.pyi +++ b/stdlib/@python2/ctypes/__init__.pyi @@ -9,7 +9,6 @@ from typing import ( Iterator, List, Mapping, - Sequence, Text, Tuple, diff --git a/stdlib/@python2/datetime.pyi b/stdlib/@python2/datetime.pyi index 2da3f9a7d207..4655865984c9 100644 --- a/stdlib/@python2/datetime.pyi +++ b/stdlib/@python2/datetime.pyi @@ -60,12 +60,7 @@ class time: max: ClassVar[time] resolution: ClassVar[timedelta] def __new__( - cls: Type[_S], - hour: int = ..., - minute: int = ..., - second: int = ..., - microsecond: int = ..., - tzinfo: _tzinfo | None = ..., + cls: Type[_S], hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: _tzinfo | None = ... ) -> _S: ... @property def hour(self) -> int: ... diff --git a/stdlib/@python2/distutils/archive_util.pyi b/stdlib/@python2/distutils/archive_util.pyi index 7208326a8607..dd2cbda73fc6 100644 --- a/stdlib/@python2/distutils/archive_util.pyi +++ b/stdlib/@python2/distutils/archive_util.pyi @@ -1,12 +1,5 @@ - - def make_archive( - base_name: str, - format: str, - root_dir: str | None = ..., - base_dir: str | None = ..., - verbose: int = ..., - dry_run: int = ..., + base_name: str, format: str, root_dir: str | None = ..., base_dir: str | None = ..., verbose: int = ..., dry_run: int = ... ) -> str: ... def make_tarball(base_name: str, base_dir: str, compress: str | None = ..., verbose: int = ..., dry_run: int = ...) -> str: ... def make_zipfile(base_name: str, base_dir: str, verbose: int = ..., dry_run: int = ...) -> str: ... diff --git a/stdlib/@python2/distutils/command/config.pyi b/stdlib/@python2/distutils/command/config.pyi index 5b1363f49310..d0fd762e83b2 100644 --- a/stdlib/@python2/distutils/command/config.pyi +++ b/stdlib/@python2/distutils/command/config.pyi @@ -77,11 +77,7 @@ class config(Command): other_libraries: List[str] = ..., ) -> bool: ... def check_header( - self, - header: str, - include_dirs: Sequence[str] | None = ..., - library_dirs: Sequence[str] | None = ..., - lang: str = ..., + self, header: str, include_dirs: Sequence[str] | None = ..., library_dirs: Sequence[str] | None = ..., lang: str = ... ) -> bool: ... def dump_file(filename: str, head: str | None = ...) -> None: ... diff --git a/stdlib/@python2/doctest.pyi b/stdlib/@python2/doctest.pyi index 25db739aaa9d..50c83b6d5c6e 100644 --- a/stdlib/@python2/doctest.pyi +++ b/stdlib/@python2/doctest.pyi @@ -67,9 +67,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: @@ -152,12 +150,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/@python2/ensurepip/__init__.pyi b/stdlib/@python2/ensurepip/__init__.pyi index 8657f4cd29d5..60946e7cf35a 100644 --- a/stdlib/@python2/ensurepip/__init__.pyi +++ b/stdlib/@python2/ensurepip/__init__.pyi @@ -1,5 +1,3 @@ - - def version() -> str: ... def bootstrap( root: str | None = ..., diff --git a/stdlib/@python2/fractions.pyi b/stdlib/@python2/fractions.pyi index 20dc8254d7d5..78960fff7a29 100644 --- a/stdlib/@python2/fractions.pyi +++ b/stdlib/@python2/fractions.pyi @@ -18,11 +18,7 @@ def gcd(a: Integral, b: Integral) -> Integral: ... 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/@python2/lib2to3/pytree.pyi b/stdlib/@python2/lib2to3/pytree.pyi index 05399f3763c4..75d323775e5f 100644 --- a/stdlib/@python2/lib2to3/pytree.pyi +++ b/stdlib/@python2/lib2to3/pytree.pyi @@ -58,12 +58,7 @@ class Leaf(Base): value: Text fixers_applied: List[Any] def __init__( - self, - type: int, - value: Text, - context: _Context | None = ..., - prefix: Text | None = ..., - fixers_applied: List[Any] = ..., + self, type: int, value: Text, context: _Context | None = ..., prefix: Text | None = ..., fixers_applied: List[Any] = ... ) -> None: ... def convert(gr: Grammar, raw_node: _RawNode) -> _NL: ... diff --git a/stdlib/@python2/logging/__init__.pyi b/stdlib/@python2/logging/__init__.pyi index a3a60ec3f7b4..9e8eb68cc88c 100644 --- a/stdlib/@python2/logging/__init__.pyi +++ b/stdlib/@python2/logging/__init__.pyi @@ -199,12 +199,8 @@ def warning(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, warn = warning def error(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any) -> None: ... -def critical( - msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any -) -> None: ... -def exception( - msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any -) -> None: ... +def critical(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any) -> None: ... +def exception(msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any) -> None: ... def log( level: int, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Dict[str, Any] | None = ..., **kwargs: Any ) -> None: ... diff --git a/stdlib/@python2/logging/config.pyi b/stdlib/@python2/logging/config.pyi index d6e71a36618e..03707bb98f55 100644 --- a/stdlib/@python2/logging/config.pyi +++ b/stdlib/@python2/logging/config.pyi @@ -5,8 +5,6 @@ from typing import IO, Any, Dict _Path = StrPath def dictConfig(config: Dict[str, Any]) -> None: ... -def fileConfig( - fname: str | IO[str], defaults: Dict[str, str] | None = ..., disable_existing_loggers: bool = ... -) -> None: ... +def fileConfig(fname: str | IO[str], defaults: Dict[str, str] | None = ..., disable_existing_loggers: bool = ...) -> None: ... def listen(port: int = ...) -> Thread: ... def stopListening() -> None: ... diff --git a/stdlib/@python2/logging/handlers.pyi b/stdlib/@python2/logging/handlers.pyi index 38cdcc0a8307..174c7bde3d68 100644 --- a/stdlib/@python2/logging/handlers.pyi +++ b/stdlib/@python2/logging/handlers.pyi @@ -90,9 +90,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: ... diff --git a/stdlib/@python2/macurl2path.pyi b/stdlib/@python2/macurl2path.pyi index 053ea4f7541e..6aac6dfeace5 100644 --- a/stdlib/@python2/macurl2path.pyi +++ b/stdlib/@python2/macurl2path.pyi @@ -1,5 +1,3 @@ - - def url2pathname(pathname: str) -> str: ... def pathname2url(pathname: str) -> str: ... def _pncomp2url(component: str | bytes) -> str: ... diff --git a/stdlib/@python2/mailbox.pyi b/stdlib/@python2/mailbox.pyi index 8ee13710f659..d7143a0c6188 100644 --- a/stdlib/@python2/mailbox.pyi +++ b/stdlib/@python2/mailbox.pyi @@ -136,9 +136,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: ... @@ -174,9 +172,7 @@ class _ProxyFile(Generic[AnyStr]): def seek(self, offset: int, whence: int = ...) -> None: ... def close(self) -> None: ... def __enter__(self) -> _ProxyFile[AnyStr]: ... - 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/@python2/mmap.pyi b/stdlib/@python2/mmap.pyi index a0fe88703350..dbc6ee90cb5b 100644 --- a/stdlib/@python2/mmap.pyi +++ b/stdlib/@python2/mmap.pyi @@ -25,9 +25,7 @@ if sys.platform != "win32": class _mmap(Generic[AnyStr]): 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/@python2/msilib/__init__.pyi b/stdlib/@python2/msilib/__init__.pyi index b78299e90188..fa6757696845 100644 --- a/stdlib/@python2/msilib/__init__.pyi +++ b/stdlib/@python2/msilib/__init__.pyi @@ -87,9 +87,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: @@ -170,26 +168,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/@python2/msilib/schema.pyi b/stdlib/@python2/msilib/schema.pyi index 90dcd04d06f2..d59e9767c3de 100644 --- a/stdlib/@python2/msilib/schema.pyi +++ b/stdlib/@python2/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/@python2/multiprocessing/process.pyi b/stdlib/@python2/multiprocessing/process.pyi index 3c381f7ac232..2cb691342580 100644 --- a/stdlib/@python2/multiprocessing/process.pyi +++ b/stdlib/@python2/multiprocessing/process.pyi @@ -4,9 +4,7 @@ def current_process(): ... def active_children(): ... class Process: - def __init__( - self, group: Any | None = ..., target: Any | None = ..., name: Any | None = ..., args=..., kwargs=... - ): ... + def __init__(self, group: Any | None = ..., target: Any | None = ..., name: Any | None = ..., args=..., kwargs=...): ... def run(self): ... def start(self): ... def terminate(self): ... diff --git a/stdlib/@python2/nntplib.pyi b/stdlib/@python2/nntplib.pyi index 9cc482b5a2e3..667a4477e948 100644 --- a/stdlib/@python2/nntplib.pyi +++ b/stdlib/@python2/nntplib.pyi @@ -53,9 +53,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/@python2/optparse.pyi b/stdlib/@python2/optparse.pyi index e380816a0626..b5be571bf464 100644 --- a/stdlib/@python2/optparse.pyi +++ b/stdlib/@python2/optparse.pyi @@ -219,9 +219,7 @@ class OptionParser(OptionContainer): def get_prog_name(self) -> _Text: ... def get_usage(self) -> _Text: ... def get_version(self) -> _Text: ... - 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/@python2/pdb.pyi b/stdlib/@python2/pdb.pyi index 9931422af598..6d3a6d5c5903 100644 --- a/stdlib/@python2/pdb.pyi +++ b/stdlib/@python2/pdb.pyi @@ -37,11 +37,7 @@ class Pdb(Bdb, Cmd): curframe: FrameType | None curframe_locals: Mapping[str, Any] def __init__( - self, - completekey: str = ..., - stdin: IO[str] | None = ..., - stdout: IO[str] | None = ..., - skip: Iterable[str] | None = ..., + self, completekey: str = ..., stdin: IO[str] | None = ..., stdout: IO[str] | None = ..., skip: Iterable[str] | None = ... ) -> None: ... def forget(self) -> None: ... def setup(self, f: FrameType | None, tb: TracebackType | None) -> None: ... diff --git a/stdlib/@python2/pickletools.pyi b/stdlib/@python2/pickletools.pyi index 4f6d8f36a4c2..dfe2ac3f30e5 100644 --- a/stdlib/@python2/pickletools.pyi +++ b/stdlib/@python2/pickletools.pyi @@ -120,8 +120,5 @@ opcodes: List[OpcodeInfo] def genops(pickle: bytes | IO[bytes]) -> Iterator[Tuple[OpcodeInfo, Any | None, int | None]]: ... def optimize(p: bytes | IO[bytes]) -> bytes: ... def dis( - pickle: bytes | IO[bytes], - out: IO[str] | None = ..., - memo: MutableMapping[int, Any] | None = ..., - indentlevel: int = ..., + pickle: bytes | IO[bytes], out: IO[str] | None = ..., memo: MutableMapping[int, Any] | None = ..., indentlevel: int = ... ) -> None: ... diff --git a/stdlib/@python2/pprint.pyi b/stdlib/@python2/pprint.pyi index 16fdc9efe0aa..407a9afb8e47 100644 --- a/stdlib/@python2/pprint.pyi +++ b/stdlib/@python2/pprint.pyi @@ -9,9 +9,7 @@ def isrecursive(object: object) -> bool: ... def saferepr(object: object) -> str: ... class PrettyPrinter: - def __init__( - self, indent: int = ..., width: int = ..., depth: int | None = ..., stream: IO[str] | None = ... - ) -> None: ... + def __init__(self, indent: int = ..., width: int = ..., depth: int | None = ..., stream: IO[str] | None = ...) -> None: ... def pformat(self, object: object) -> str: ... def pprint(self, object: object) -> None: ... def isreadable(self, object: object) -> bool: ... diff --git a/stdlib/@python2/py_compile.pyi b/stdlib/@python2/py_compile.pyi index 583cda40ef89..6601b20f0596 100644 --- a/stdlib/@python2/py_compile.pyi +++ b/stdlib/@python2/py_compile.pyi @@ -9,7 +9,5 @@ class PyCompileError(Exception): msg: str def __init__(self, exc_type: Type[BaseException], exc_value: BaseException, file: str, msg: str = ...) -> None: ... -def compile( - file: _EitherStr, cfile: _EitherStr | None = ..., dfile: _EitherStr | None = ..., doraise: bool = ... -) -> None: ... +def compile(file: _EitherStr, cfile: _EitherStr | None = ..., dfile: _EitherStr | None = ..., doraise: bool = ...) -> None: ... def main(args: List[Text] | None = ...) -> int: ... diff --git a/stdlib/@python2/pydoc.pyi b/stdlib/@python2/pydoc.pyi index 97b6a37f678d..00e696db5745 100644 --- a/stdlib/@python2/pydoc.pyi +++ b/stdlib/@python2/pydoc.pyi @@ -211,9 +211,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/@python2/re.pyi b/stdlib/@python2/re.pyi index b34e454ffcf9..fbe021ce67be 100644 --- a/stdlib/@python2/re.pyi +++ b/stdlib/@python2/re.pyi @@ -34,9 +34,7 @@ def match(pattern: Pattern[str] | Pattern[unicode], string: AnyStr, flags: int = @overload def split(pattern: str | unicode, string: AnyStr, maxsplit: int = ..., flags: int = ...) -> List[AnyStr]: ... @overload -def split( - pattern: Pattern[str] | Pattern[unicode], string: AnyStr, maxsplit: int = ..., flags: int = ... -) -> List[AnyStr]: ... +def split(pattern: Pattern[str] | Pattern[unicode], string: AnyStr, maxsplit: int = ..., flags: int = ...) -> List[AnyStr]: ... @overload def findall(pattern: str | unicode, string: AnyStr, flags: int = ...) -> List[Any]: ... @overload @@ -57,9 +55,7 @@ def sub( pattern: str | unicode, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: int = ... ) -> AnyStr: ... @overload -def sub( - pattern: Pattern[str] | Pattern[unicode], repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ... -) -> AnyStr: ... +def sub(pattern: Pattern[str] | Pattern[unicode], repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ...) -> AnyStr: ... @overload def sub( pattern: Pattern[str] | Pattern[unicode], @@ -69,9 +65,7 @@ def sub( flags: int = ..., ) -> AnyStr: ... @overload -def subn( - pattern: str | unicode, repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ... -) -> Tuple[AnyStr, int]: ... +def subn(pattern: str | unicode, repl: AnyStr, string: AnyStr, count: int = ..., flags: int = ...) -> Tuple[AnyStr, int]: ... @overload def subn( pattern: str | unicode, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: int = ... diff --git a/stdlib/@python2/ssl.pyi b/stdlib/@python2/ssl.pyi index 6c2f8971d7ff..3660ff2940dc 100644 --- a/stdlib/@python2/ssl.pyi +++ b/stdlib/@python2/ssl.pyi @@ -220,9 +220,7 @@ class SSLContext: verify_mode: int 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: Text | bytes | None = ... diff --git a/stdlib/@python2/tarfile.pyi b/stdlib/@python2/tarfile.pyi index 3e10b9d53d59..00a281e826d6 100644 --- a/stdlib/@python2/tarfile.pyi +++ b/stdlib/@python2/tarfile.pyi @@ -220,9 +220,7 @@ class TarFile(Iterable[TarInfo]): filter: Optional[Callable[[TarInfo], TarInfo | 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: ... def is_tarfile(name: Text) -> bool: ... diff --git a/stdlib/@python2/tempfile.pyi b/stdlib/@python2/tempfile.pyi index 81fc73f0a1da..cb69c02aba65 100644 --- a/stdlib/@python2/tempfile.pyi +++ b/stdlib/@python2/tempfile.pyi @@ -76,9 +76,7 @@ def SpooledTemporaryFile( class TemporaryDirectory: name: Any - def __init__( - self, suffix: bytes | unicode = ..., prefix: bytes | unicode = ..., dir: bytes | unicode = ... - ) -> None: ... + def __init__(self, suffix: bytes | unicode = ..., prefix: bytes | unicode = ..., dir: bytes | unicode = ...) -> None: ... def cleanup(self) -> None: ... def __enter__(self) -> Any: ... # Can be str or unicode def __exit__(self, type, value, traceback) -> None: ... diff --git a/stdlib/@python2/trace.pyi b/stdlib/@python2/trace.pyi index 54ac91fb2c02..a5003d7083f4 100644 --- a/stdlib/@python2/trace.pyi +++ b/stdlib/@python2/trace.pyi @@ -36,10 +36,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: ... def runfunc(self, func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... def file_module_function_of(self, frame: types.FrameType) -> _fileModuleFunction: ... diff --git a/stdlib/@python2/turtle.pyi b/stdlib/@python2/turtle.pyi index b13e70c3ac9d..78304d84d7bb 100644 --- a/stdlib/@python2/turtle.pyi +++ b/stdlib/@python2/turtle.pyi @@ -254,11 +254,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/@python2/types.pyi b/stdlib/@python2/types.pyi index 06cce4b2c934..72b9321a860f 100644 --- a/stdlib/@python2/types.pyi +++ b/stdlib/@python2/types.pyi @@ -95,9 +95,7 @@ class GeneratorType: def next(self) -> Any: ... def send(self, __arg: Any) -> Any: ... @overload - def throw( - self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... - ) -> Any: ... + def throw(self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...) -> Any: ... @overload def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> Any: ... diff --git a/stdlib/@python2/typing.pyi b/stdlib/@python2/typing.pyi index b0994d8fbddd..a1b02e81990c 100644 --- a/stdlib/@python2/typing.pyi +++ b/stdlib/@python2/typing.pyi @@ -14,12 +14,7 @@ class TypeVar: __covariant__: bool __contravariant__: bool def __init__( - self, - name: str, - *constraints: Type[Any], - bound: Type[Any] | None = ..., - covariant: bool = ..., - contravariant: bool = ..., + self, name: str, *constraints: Type[Any], bound: Type[Any] | None = ..., covariant: bool = ..., contravariant: bool = ... ) -> None: ... _promote = object() @@ -263,10 +258,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: ... class Mapping(Iterable[_KT], Container[_KT], Generic[_KT, _VT_co]): diff --git a/stdlib/@python2/typing_extensions.pyi b/stdlib/@python2/typing_extensions.pyi index 12f5cbd8f3c4..d946cc278d32 100644 --- a/stdlib/@python2/typing_extensions.pyi +++ b/stdlib/@python2/typing_extensions.pyi @@ -14,12 +14,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/@python2/unittest.pyi b/stdlib/@python2/unittest.pyi index 47f2820c8e08..b386af88de6c 100644 --- a/stdlib/@python2/unittest.pyi +++ b/stdlib/@python2/unittest.pyi @@ -144,9 +144,7 @@ class TestCase(Testable): ) -> None: ... def assertListEqual(self, first: List[Any], second: List[Any], msg: object = ...) -> None: ... def assertTupleEqual(self, first: Tuple[Any, ...], second: Tuple[Any, ...], msg: object = ...) -> None: ... - def assertSetEqual( - self, first: Set[Any] | FrozenSet[Any], second: Set[Any] | FrozenSet[Any], msg: object = ... - ) -> None: ... + def assertSetEqual(self, first: Set[Any] | FrozenSet[Any], second: Set[Any] | FrozenSet[Any], msg: object = ...) -> None: ... def assertDictEqual(self, first: Dict[Any, Any], second: Dict[Any, Any], msg: object = ...) -> None: ... def assertLess(self, first: Any, second: Any, msg: object = ...) -> None: ... def assertLessEqual(self, first: Any, second: Any, msg: object = ...) -> None: ... diff --git a/stdlib/@python2/urllib2.pyi b/stdlib/@python2/urllib2.pyi index d76e1a717648..ad65fddff6fc 100644 --- a/stdlib/@python2/urllib2.pyi +++ b/stdlib/@python2/urllib2.pyi @@ -53,9 +53,7 @@ class Request(object): class OpenerDirector(object): addheaders: List[Tuple[str, str]] def add_handler(self, handler: BaseHandler) -> None: ... - def open( - self, fullurl: Request | _string, data: _string | None = ..., timeout: float | None = ... - ) -> addinfourl | None: ... + def open(self, fullurl: Request | _string, data: _string | None = ..., timeout: float | None = ...) -> addinfourl | None: ... def error(self, proto: _string, *args: Any): ... # Note that this type is somewhat a lie. The return *can* be None if diff --git a/stdlib/@python2/warnings.pyi b/stdlib/@python2/warnings.pyi index e432ebae0cde..e3540ed60b0c 100644 --- a/stdlib/@python2/warnings.pyi +++ b/stdlib/@python2/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/@python2/xml/dom/minidom.pyi b/stdlib/@python2/xml/dom/minidom.pyi index 05b968e994c9..ed46ac4561ec 100644 --- a/stdlib/@python2/xml/dom/minidom.pyi +++ b/stdlib/@python2/xml/dom/minidom.pyi @@ -288,7 +288,5 @@ class Document(Node, DocumentLS): def getElementsByTagNameNS(self, namespaceURI: str, localName): ... def isSupported(self, feature, version): ... def importNode(self, node, deep): ... - def writexml( - self, writer, indent: str = ..., addindent: str = ..., newl: str = ..., encoding: Any | None = ... - ) -> None: ... + def writexml(self, writer, indent: str = ..., addindent: str = ..., newl: str = ..., encoding: Any | None = ...) -> None: ... def renameNode(self, n, namespaceURI: str, name): ... diff --git a/stdlib/@python2/xml/etree/ElementPath.pyi b/stdlib/@python2/xml/etree/ElementPath.pyi index 4e75e924eecc..02fe84567543 100644 --- a/stdlib/@python2/xml/etree/ElementPath.pyi +++ b/stdlib/@python2/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/@python2/xml/etree/ElementTree.pyi b/stdlib/@python2/xml/etree/ElementTree.pyi index a13775b29d39..bb12aa018628 100644 --- a/stdlib/@python2/xml/etree/ElementTree.pyi +++ b/stdlib/@python2/xml/etree/ElementTree.pyi @@ -11,12 +11,10 @@ from typing import ( KeysView, List, MutableSequence, - Sequence, Text, Tuple, TypeVar, - overload, ) @@ -74,10 +72,7 @@ class Element(MutableSequence[Element]): ) -> List[Element]: ... @overload def findtext( - self, - path: _str_argument_type, - default: None = ..., - namespaces: Dict[_str_argument_type, _str_argument_type] | None = ..., + self, path: _str_argument_type, default: None = ..., namespaces: Dict[_str_argument_type, _str_argument_type] | None = ... ) -> _str_result_type | None: ... @overload def findtext( @@ -137,10 +132,7 @@ class ElementTree: ) -> Element | None: ... @overload def findtext( - self, - path: _str_argument_type, - default: None = ..., - namespaces: Dict[_str_argument_type, _str_argument_type] | None = ..., + self, path: _str_argument_type, default: None = ..., namespaces: Dict[_str_argument_type, _str_argument_type] | None = ... ) -> _str_result_type | None: ... @overload def findtext( diff --git a/stdlib/@python2/zipfile.pyi b/stdlib/@python2/zipfile.pyi index bfddecad0d94..c40d3cccdb88 100644 --- a/stdlib/@python2/zipfile.pyi +++ b/stdlib/@python2/zipfile.pyi @@ -46,9 +46,7 @@ class ZipFile: fp: IO[bytes] | None NameToInfo: Dict[Text, ZipInfo] start_dir: int # undocumented - def __init__( - self, file: StrPath | IO[bytes], mode: Text = ..., compression: int = ..., allowZip64: bool = ... - ) -> None: ... + def __init__(self, file: StrPath | IO[bytes], mode: Text = ..., compression: int = ..., allowZip64: bool = ...) -> None: ... def __enter__(self) -> ZipFile: ... def __exit__( self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None @@ -59,9 +57,7 @@ class ZipFile: def namelist(self) -> List[Text]: ... def open(self, name: _SZI, mode: Text = ..., pwd: bytes | None = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... def extract(self, member: _SZI, path: StrPath | None = ..., pwd: bytes | None = ...) -> str: ... - def extractall( - self, path: StrPath | None = ..., members: Iterable[Text] | None = ..., pwd: bytes | None = ... - ) -> None: ... + def extractall(self, path: StrPath | None = ..., members: Iterable[Text] | None = ..., pwd: bytes | None = ...) -> None: ... def printdir(self) -> None: ... def setpassword(self, pwd: bytes) -> None: ... def read(self, name: _SZI, pwd: bytes | None = ...) -> bytes: ... diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index 25af85974cc5..d1e2ce0b9e24 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 07441592b6c3..ed6cc5cb9ab3 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 207a188d7ac5..d529f8ba2d8c 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -90,18 +90,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 +241,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 291d5e0ebc5f..b0f83695188b 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -119,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 @@ -303,13 +294,7 @@ class AbstractEventLoop(metaclass=ABCMeta): ) -> AbstractServer: ... @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 ecf1c670b3ce..93227bf2c6b9 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 76f38a830a57..d0221ab3da24 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 1ec04d94ada8..3fc14fb93d11 100644 --- a/stdlib/asyncio/unix_events.pyi +++ b/stdlib/asyncio/unix_events.pyi @@ -16,9 +16,7 @@ class AbstractChildWatcher: def attach_loop(self, loop: AbstractEventLoop | None) -> None: ... def close(self) -> None: ... def __enter__(self: _T1) -> _T1: ... - 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 4653254dbc29..8610eea17b52 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 4816d183b44d..5bee9dadb928 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 d7f6a9a12e08..a4558f05e5b2 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -423,27 +423,18 @@ class bytes(ByteString): def __new__(cls: Type[_T], o: SupportsBytes) -> _T: ... def capitalize(self) -> bytes: ... def center(self, __width: int, __fillchar: bytes = ...) -> bytes: ... - def count( - self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... - ) -> int: ... + def count(self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> 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: ... def expandtabs(self, tabsize: int = ...) -> bytes: ... - def find( - self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... - ) -> int: ... + def find(self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... if sys.version_info >= (3, 8): def hex(self, sep: str | bytes = ..., bytes_per_sep: int = ...) -> str: ... else: def hex(self) -> str: ... - def index( - self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... - ) -> int: ... + def index(self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... if sys.version_info >= (3, 7): @@ -462,12 +453,8 @@ class bytes(ByteString): if sys.version_info >= (3, 9): def removeprefix(self, __prefix: bytes) -> bytes: ... def removesuffix(self, __suffix: bytes) -> bytes: ... - def rfind( - self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... - ) -> int: ... - def rindex( - self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... - ) -> int: ... + def rfind(self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... + def rindex(self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... def rjust(self, __width: int, __fillchar: bytes = ...) -> bytes: ... def rpartition(self, __sep: bytes) -> Tuple[bytes, bytes, bytes]: ... def rsplit(self, sep: bytes | None = ..., maxsplit: int = ...) -> List[bytes]: ... @@ -475,10 +462,7 @@ class bytes(ByteString): def split(self, sep: bytes | None = ..., maxsplit: int = ...) -> 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: ... @@ -525,29 +509,20 @@ class bytearray(MutableSequence[int], ByteString): def append(self, __item: int) -> None: ... def capitalize(self) -> bytearray: ... def center(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... - def count( - self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... - ) -> int: ... + def count(self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... 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: ... def expandtabs(self, tabsize: int = ...) -> bytearray: ... def extend(self, __iterable_of_ints: Iterable[int]) -> None: ... - def find( - self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... - ) -> int: ... + def find(self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... if sys.version_info >= (3, 8): def hex(self, sep: str | bytes = ..., bytes_per_sep: int = ...) -> str: ... else: def hex(self) -> str: ... - def index( - self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... - ) -> int: ... + def index(self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... def insert(self, __index: int, __item: int) -> None: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... @@ -567,12 +542,8 @@ class bytearray(MutableSequence[int], ByteString): def removeprefix(self, __prefix: bytes) -> bytearray: ... def removesuffix(self, __suffix: bytes) -> bytearray: ... def replace(self, __old: bytes, __new: bytes, __count: int = ...) -> bytearray: ... - def rfind( - self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... - ) -> int: ... - def rindex( - self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ... - ) -> int: ... + def rfind(self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... + def rindex(self, __sub: bytes | int, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... def rjust(self, __width: int, __fillchar: bytes = ...) -> bytearray: ... def rpartition(self, __sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... def rsplit(self, sep: bytes | None = ..., maxsplit: int = ...) -> List[bytearray]: ... @@ -580,10 +551,7 @@ class bytearray(MutableSequence[int], ByteString): def split(self, sep: bytes | None = ..., maxsplit: int = ...) -> 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: ... @@ -1228,11 +1196,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 f783623edb77..320e888b5fef 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 f9f0de7bbaf5..62d9e4dac538 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 fd2a7ede1603..28d2b65b95c2 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -10,7 +10,6 @@ from typing import ( Iterable, Iterator, List, - Protocol, TextIO, Tuple, @@ -199,9 +198,7 @@ class StreamWriter(Codec): def writelines(self, list: Iterable[str]) -> None: ... def reset(self) -> None: ... def __enter__(self: _SW) -> _SW: ... - 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: ... _SR = TypeVar("_SR", bound=StreamReader) @@ -214,9 +211,7 @@ class StreamReader(Codec): def readlines(self, sizehint: int | None = ..., keepends: bool = ...) -> List[str]: ... def reset(self) -> None: ... def __enter__(self: _SR) -> _SR: ... - 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: ... @@ -238,9 +233,7 @@ class StreamReaderWriter(TextIO): # Same as write() def seek(self, offset: int, whence: int = ...) -> int: ... def __enter__(self: _T) -> _T: ... - 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__. @@ -276,9 +269,7 @@ class StreamRecoder(BinaryIO): def reset(self) -> None: ... def __getattr__(self, name: str) -> Any: ... def __enter__(self: _SRT) -> _SRT: ... - 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 45f8f0d6e573..29e59b0c1aa9 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -36,12 +36,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]): @@ -150,9 +145,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: ... diff --git a/stdlib/concurrent/futures/_base.pyi b/stdlib/concurrent/futures/_base.pyi index 4705cb198cbd..5a71027b7686 100644 --- a/stdlib/concurrent/futures/_base.pyi +++ b/stdlib/concurrent/futures/_base.pyi @@ -2,21 +2,7 @@ import sys import threading 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 6e0ecb50a1c5..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 @@ -143,9 +141,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 +177,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 11ed0591ebcb..d23f0d2bc4a7 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -9,7 +9,6 @@ from typing import ( Callable, ContextManager, Iterator, - Type, TypeVar, overload, @@ -80,10 +79,7 @@ class ExitStack(ContextManager[ExitStack]): def close(self) -> None: ... def __enter__(self: _U) -> _U: ... 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): @@ -104,10 +100,7 @@ if sys.version_info >= (3, 7): def aclose(self) -> Awaitable[None]: ... def __aenter__(self: _S) -> Awaitable[_S]: ... 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, 7): diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index 0b3438ab14c6..5f0eab9a5ef7 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -9,7 +9,6 @@ from typing import ( Iterator, List, Mapping, - Sequence, Tuple, Type, @@ -47,12 +46,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 5d65d1514cec..34a659a37aa1 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 d87a8372b0a2..0f50a0529273 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/archive_util.pyi b/stdlib/distutils/archive_util.pyi index 317221e7b8b4..38458fc0e003 100644 --- a/stdlib/distutils/archive_util.pyi +++ b/stdlib/distutils/archive_util.pyi @@ -1,5 +1,3 @@ - - def make_archive( base_name: str, format: str, diff --git a/stdlib/distutils/command/config.pyi b/stdlib/distutils/command/config.pyi index 5b1363f49310..d0fd762e83b2 100644 --- a/stdlib/distutils/command/config.pyi +++ b/stdlib/distutils/command/config.pyi @@ -77,11 +77,7 @@ class config(Command): other_libraries: List[str] = ..., ) -> bool: ... def check_header( - self, - header: str, - include_dirs: Sequence[str] | None = ..., - library_dirs: Sequence[str] | None = ..., - lang: str = ..., + self, header: str, include_dirs: Sequence[str] | None = ..., library_dirs: Sequence[str] | None = ..., lang: str = ... ) -> bool: ... def dump_file(filename: str, head: str | None = ...) -> None: ... diff --git a/stdlib/distutils/debug.pyi b/stdlib/distutils/debug.pyi index 73af13047df6..11f28a8bc8ae 100644 --- a/stdlib/distutils/debug.pyi +++ b/stdlib/distutils/debug.pyi @@ -1,3 +1 @@ - - DEBUG: bool | None diff --git a/stdlib/distutils/filelist.pyi b/stdlib/distutils/filelist.pyi index 787e1bf5c745..a0b02c87dc85 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 e49750d910ea..493830642930 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 e36274c75f38..1a810558a0da 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 41b430f11a81..afcafa66ee60 100644 --- a/stdlib/email/mime/text.pyi +++ b/stdlib/email/mime/text.pyi @@ -2,6 +2,4 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy 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/ensurepip/__init__.pyi b/stdlib/ensurepip/__init__.pyi index 5153f559d7df..749fedc04424 100644 --- a/stdlib/ensurepip/__init__.pyi +++ b/stdlib/ensurepip/__init__.pyi @@ -1,5 +1,3 @@ - - def version() -> str: ... def bootstrap( *, diff --git a/stdlib/filecmp.pyi b/stdlib/filecmp.pyi index 8b16bf87a986..2ddfd18c2d99 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 2ff1fac38c66..14ec78bda3cc 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/functools.pyi b/stdlib/functools.pyi index 30e60ab14b38..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/http/client.pyi b/stdlib/http/client.pyi index 920474a1f9dc..5b555db808b1 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -15,7 +15,6 @@ from typing import ( Iterator, List, Mapping, - Protocol, Tuple, Type, @@ -157,20 +156,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 e9778d06d53e..826445921f27 100644 --- a/stdlib/http/cookiejar.pyi +++ b/stdlib/http/cookiejar.pyi @@ -25,13 +25,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 53248791ed8b..3f879dfcbf15 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 2a1d86911764..6b56d48e9e37 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 1b0574eb2477..40aebfe1beb1 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 bd3f353b92b0..19cb23e022fd 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -299,9 +299,7 @@ class Formatter: default_msec_format: str if sys.version_info >= (3, 8): - def __init__( - self, fmt: str | None = ..., datefmt: str | None = ..., style: str = ..., validate: bool = ... - ) -> None: ... + def __init__(self, fmt: str | None = ..., datefmt: str | None = ..., style: str = ..., validate: bool = ...) -> None: ... else: def __init__(self, fmt: str | None = ..., datefmt: str | None = ..., style: str = ...) -> None: ... def format(self, record: LogRecord) -> str: ... @@ -750,12 +748,7 @@ class FileHandler(StreamHandler): if sys.version_info >= (3, 9): errors: str | None # undocumented 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: ... diff --git a/stdlib/logging/config.pyi b/stdlib/logging/config.pyi index 3f0567ac636f..fd2745d7566d 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 304488fc2cfb..b98f40a1e8e8 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 22ea2b5b6337..3e5f42de587a 100644 --- a/stdlib/lzma.pyi +++ b/stdlib/lzma.pyi @@ -42,9 +42,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/macurl2path.pyi b/stdlib/macurl2path.pyi index 053ea4f7541e..6aac6dfeace5 100644 --- a/stdlib/macurl2path.pyi +++ b/stdlib/macurl2path.pyi @@ -1,5 +1,3 @@ - - def url2pathname(pathname: str) -> str: ... def pathname2url(pathname: str) -> str: ... def _pncomp2url(component: str | bytes) -> str: ... diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index 2af493368545..6cc27444141d 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) -> _ProxyFile[AnyStr]: ... - 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 52ce63f2b2f7..c813e96b5c15 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -26,9 +26,7 @@ if sys.platform != "win32": class _mmap(Generic[AnyStr]): 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 d9998fd265bf..b0d77b141d4a 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 90dcd04d06f2..d59e9767c3de 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 582c952be93c..c92cbd5e8353 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 0fd21d4f0d29..64e0bb61e158 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 e27caac71415..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 @@ -47,16 +32,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 +73,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 0f1ffd5547ff..259a460dbf92 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 b52277b961a3..8cffefe12d65 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 97c57d8391d9..debb9e943689 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 eaa31640e359..0afc7df6fcd8 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -633,13 +633,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]]): @@ -671,9 +667,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 cfbba920b9f8..a77ac5b7a939 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -130,12 +130,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 6a94d26f17d9..56386da1d678 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 = ... @@ -62,12 +52,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 b1f3d86aadb4..d0f08a20fcd6 100644 --- a/stdlib/platform.pyi +++ b/stdlib/platform.pyi @@ -7,9 +7,7 @@ if sys.version_info < (3, 8): from typing import NamedTuple, Tuple if sys.version_info >= (3, 8): - def libc_ver( - executable: str | None = ..., lib: str = ..., version: str = ..., chunksize: int = ... - ) -> Tuple[str, str]: ... + def libc_ver(executable: str | None = ..., lib: str = ..., version: str = ..., chunksize: int = ...) -> Tuple[str, str]: ... else: def libc_ver(executable: str = ..., lib: str = ..., version: str = ..., chunksize: int = ...) -> Tuple[str, str]: ... diff --git a/stdlib/pprint.pyi b/stdlib/pprint.pyi index fc77ef6a216e..688561b43115 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 a558495a9abd..64adc2800d91 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 e3274b73aa8d..fa4ad56bace3 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -209,9 +209,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/random.pyi b/stdlib/random.pyi index d46800eb3460..01947a9918d6 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -26,9 +26,7 @@ class Random(_random.Random): ) -> list[_T]: ... def shuffle(self, x: MutableSequence[Any], random: Optional[Callable[[], float]] = ...) -> 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: ... @@ -62,11 +60,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: Optional[Callable[[], float]] = ...) -> None: ... diff --git a/stdlib/shutil.pyi b/stdlib/shutil.pyi index 7767c9494a8b..fbf174231a42 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: Optional[Callable[[Any, Any, Any], Any]] = ... -) -> None: ... +def rmtree(path: bytes | StrPath, ignore_errors: bool = ..., onerror: Optional[Callable[[Any, Any, Any], Any]] = ...) -> None: ... _CopyFn = Union[Callable[[str, str], None], Callable[[StrPath, StrPath], None]] diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index da3d158aa0f7..bb172f56c226 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -108,9 +108,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, @@ -151,9 +149,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 5671b67e6b19..45a0d7c76278 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: _T) -> _T: ... def __exit__(self, *args: object) -> None: ... diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index d9052c61d4de..e9abe8d05470 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -303,9 +303,7 @@ class SSLContext: verify_mode: int 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 = ... @@ -356,9 +354,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 fcff953b9fe5..376af027954e 100644 --- a/stdlib/sys.pyi +++ b/stdlib/sys.pyi @@ -18,7 +18,6 @@ from typing import ( Tuple, Type, TypeVar, - overload, ) @@ -32,9 +31,7 @@ _PathSequence = Sequence[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 19d9a56b4fd0..9cf64af9daac 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -292,9 +292,7 @@ class TarFile: filter: Optional[Callable[[TarInfo], TarInfo | 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 8d2a548fd825..dc045d229c0c 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) -> _TemporaryFileWrapper[AnyStr]: ... - 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 @@ -320,9 +318,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/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 76a8e02d5a11..cd1656a2ed69 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -520,11 +520,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 = ...): ... @@ -1288,9 +1284,7 @@ class Canvas(Widget, XView, YView): lower: Any 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): ... def tag_raise(self, *args): ... lift: Any @@ -2723,12 +2717,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 @@ -2770,9 +2760,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): ... @@ -2816,12 +2804,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/tix.pyi b/stdlib/tkinter/tix.pyi index 36c860cda6a4..a5242bd9fe16 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/tokenize.pyi b/stdlib/tokenize.pyi index 739f31d4ae13..99ac4dd73b92 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, - -) +from typing import Any, Callable, Dict, Generator, Iterable, List, NamedTuple, Pattern, Sequence, Set, TextIO, Tuple if sys.version_info < (3, 7): COMMENT: int diff --git a/stdlib/trace.pyi b/stdlib/trace.pyi index 54ac91fb2c02..a5003d7083f4 100644 --- a/stdlib/trace.pyi +++ b/stdlib/trace.pyi @@ -36,10 +36,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: ... def runfunc(self, func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... def file_module_function_of(self, frame: types.FrameType) -> _fileModuleFunction: ... diff --git a/stdlib/tracemalloc.pyi b/stdlib/tracemalloc.pyi index 35af91048960..fb6b6938e436 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 d63a84f62bd7..1253dce8e87c 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 418286eb7493..1f20ac47126d 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -421,10 +421,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/typing_extensions.pyi b/stdlib/typing_extensions.pyi index e37f33b6c147..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 e725aa5e6fd4..1970bea88d79 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -137,9 +137,7 @@ class TestCase: expected_regex: Union[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 bc4959f0304d..f31d8ca4922c 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 4b306359d92f..56e584a89a4e 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 7d35c5fbe95d..ce7d24948b72 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -347,12 +347,8 @@ class FancyURLopener(URLopener): def redirect_internal( self, url: str, fp: IO[str], errcode: int, errmsg: str, headers: Mapping[str, 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_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 c8bb573a9eee..a612146b1399 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/minidom.pyi b/stdlib/xml/dom/minidom.pyi index 3de069bc7eed..bfe6527e309f 100644 --- a/stdlib/xml/dom/minidom.pyi +++ b/stdlib/xml/dom/minidom.pyi @@ -19,9 +19,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/etree/ElementInclude.pyi b/stdlib/xml/etree/ElementInclude.pyi index 398eb5243c48..0ccccce4f3d0 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 4e75e924eecc..02fe84567543 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 26d50b6aca07..8253d1f8c50f 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -12,11 +12,9 @@ from typing import ( KeysView, List, MutableSequence, - Sequence, Tuple, TypeVar, - overload, ) from typing_extensions import Literal @@ -234,9 +232,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 22854d97f60d..f9fcecd86da6 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 b1a2e7f2b2e9..24f98ed780e5 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: ... @@ -56,9 +54,7 @@ class SimpleXMLRPCDispatcher: # undocumented def _marshaled_dispatch( self, data: str, - dispatch_method: Optional[ - Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] - ] = ..., + dispatch_method: Optional[Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]]] = ..., path: Any | None = ..., ) -> str: ... # undocumented def system_listMethods(self) -> List[str]: ... # undocumented @@ -114,9 +110,7 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented def _marshaled_dispatch( self, data: str, - dispatch_method: Optional[ - Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] - ] = ..., + dispatch_method: Optional[Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]]] = ..., path: Any | None = ..., ) -> str: ... diff --git a/stdlib/zipfile.pyi b/stdlib/zipfile.pyi index 79dab171bfc7..4d371659cd54 100644 --- a/stdlib/zipfile.pyi +++ b/stdlib/zipfile.pyi @@ -51,12 +51,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 @@ -136,13 +131,9 @@ class ZipFile: def getinfo(self, name: str) -> ZipInfo: ... def infolist(self) -> List[ZipInfo]: ... def namelist(self) -> List[str]: ... - def open( - self, name: str | ZipInfo, mode: str = ..., pwd: bytes | None = ..., *, force_zip64: bool = ... - ) -> IO[bytes]: ... + def open(self, name: str | ZipInfo, mode: str = ..., 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: ... @@ -166,9 +157,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 028fa4835c05..a83a8793ccac 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: ...