From 1acc8f3bd645aea6b18cf15d5fca271b9c3cd785 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sat, 19 Mar 2022 14:27:35 +0000 Subject: [PATCH] Use PEP 604 syntax wherever possible, part II (#7514) Co-authored-by: Jelle Zijlstra --- stdlib/@python2/calendar.pyi | 4 ++-- stdlib/@python2/copy_reg.pyi | 4 ++-- stdlib/@python2/copyreg.pyi | 4 ++-- stdlib/@python2/ctypes/__init__.pyi | 3 +-- stdlib/@python2/distutils/ccompiler.pyi | 4 ++-- stdlib/@python2/distutils/fancy_getopt.pyi | 4 ++-- stdlib/@python2/email/mime/application.pyi | 4 ++-- stdlib/@python2/imaplib.pyi | 4 ++-- stdlib/@python2/inspect.pyi | 4 ++-- stdlib/@python2/lib2to3/pgen2/grammar.pyi | 4 ++-- stdlib/@python2/lib2to3/pytree.pyi | 4 ++-- stdlib/@python2/logging/__init__.pyi | 4 ++-- stdlib/@python2/msilib/sequence.pyi | 3 +-- stdlib/@python2/netrc.pyi | 4 ++-- stdlib/@python2/os/__init__.pyi | 3 +-- stdlib/@python2/pickle.pyi | 6 +++--- stdlib/@python2/pkgutil.pyi | 4 ++-- stdlib/@python2/pyexpat/__init__.pyi | 4 ++-- stdlib/@python2/sndhdr.pyi | 4 ++-- stdlib/@python2/socket.pyi | 4 ++-- stdlib/@python2/sre_parse.pyi | 6 +++--- stdlib/@python2/trace.pyi | 4 ++-- stdlib/@python2/traceback.pyi | 4 ++-- stdlib/_socket.pyi | 4 ++-- stdlib/_thread.pyi | 6 ++---- stdlib/calendar.pyi | 4 ++-- stdlib/cgitb.pyi | 4 ++-- stdlib/copyreg.pyi | 4 ++-- stdlib/ctypes/__init__.pyi | 17 ++--------------- stdlib/distutils/ccompiler.pyi | 4 ++-- stdlib/distutils/fancy_getopt.pyi | 4 ++-- stdlib/email/message.pyi | 6 +++--- stdlib/email/mime/application.pyi | 4 ++-- stdlib/email/mime/audio.pyi | 4 ++-- stdlib/email/mime/base.pyi | 4 ++-- stdlib/email/mime/image.pyi | 4 ++-- stdlib/email/mime/multipart.pyi | 4 ++-- stdlib/email/utils.pyi | 6 +++--- stdlib/grp.pyi | 4 ++-- stdlib/imaplib.pyi | 4 ++-- stdlib/lib2to3/pgen2/grammar.pyi | 3 +-- stdlib/lib2to3/pytree.pyi | 4 ++-- stdlib/logging/__init__.pyi | 6 +++--- stdlib/msilib/sequence.pyi | 3 +-- stdlib/netrc.pyi | 3 +-- stdlib/pickle.pyi | 6 +++--- stdlib/pyexpat/__init__.pyi | 4 ++-- stdlib/smtplib.pyi | 4 ++-- stdlib/sre_parse.pyi | 8 ++++---- stdlib/ssl.pyi | 2 +- stdlib/tkinter/font.pyi | 20 ++++++++------------ stdlib/trace.pyi | 4 ++-- stdlib/tracemalloc.pyi | 4 ++-- stdlib/xmlrpc/server.pyi | 4 ++-- stubs/Pillow/PIL/Image.pyi | 2 +- 55 files changed, 116 insertions(+), 141 deletions(-) diff --git a/stdlib/@python2/calendar.pyi b/stdlib/@python2/calendar.pyi index f21e6406a..f14b0735f 100644 --- a/stdlib/@python2/calendar.pyi +++ b/stdlib/@python2/calendar.pyi @@ -1,8 +1,8 @@ import datetime from time import struct_time -from typing import Any, Iterable, Optional, Sequence +from typing import Any, Iterable, Sequence -_LocaleType = tuple[Optional[str], Optional[str]] +_LocaleType = tuple[str | None, str | None] class IllegalMonthError(ValueError): def __init__(self, month: int) -> None: ... diff --git a/stdlib/@python2/copy_reg.pyi b/stdlib/@python2/copy_reg.pyi index 5aec88298..2fccfcbf2 100644 --- a/stdlib/@python2/copy_reg.pyi +++ b/stdlib/@python2/copy_reg.pyi @@ -1,7 +1,7 @@ -from typing import Any, Callable, Hashable, Optional, SupportsInt, TypeVar, Union +from typing import Any, Callable, Hashable, SupportsInt, TypeVar, Union _TypeT = TypeVar("_TypeT", bound=type) -_Reduce = Union[tuple[Callable[..., _TypeT], tuple[Any, ...]], tuple[Callable[..., _TypeT], tuple[Any, ...], Optional[Any]]] +_Reduce = Union[tuple[Callable[..., _TypeT], tuple[Any, ...]], tuple[Callable[..., _TypeT], tuple[Any, ...], Any | None]] __all__ = ["pickle", "constructor", "add_extension", "remove_extension", "clear_extension_cache"] diff --git a/stdlib/@python2/copyreg.pyi b/stdlib/@python2/copyreg.pyi index 5aec88298..2fccfcbf2 100644 --- a/stdlib/@python2/copyreg.pyi +++ b/stdlib/@python2/copyreg.pyi @@ -1,7 +1,7 @@ -from typing import Any, Callable, Hashable, Optional, SupportsInt, TypeVar, Union +from typing import Any, Callable, Hashable, SupportsInt, TypeVar, Union _TypeT = TypeVar("_TypeT", bound=type) -_Reduce = Union[tuple[Callable[..., _TypeT], tuple[Any, ...]], tuple[Callable[..., _TypeT], tuple[Any, ...], Optional[Any]]] +_Reduce = Union[tuple[Callable[..., _TypeT], tuple[Any, ...]], tuple[Callable[..., _TypeT], tuple[Any, ...], Any | None]] __all__ = ["pickle", "constructor", "add_extension", "remove_extension", "clear_extension_cache"] diff --git a/stdlib/@python2/ctypes/__init__.pyi b/stdlib/@python2/ctypes/__init__.pyi index 0fc23cb09..18d5cbc77 100644 --- a/stdlib/@python2/ctypes/__init__.pyi +++ b/stdlib/@python2/ctypes/__init__.pyi @@ -9,7 +9,6 @@ from typing import ( Iterable, Iterator, Mapping, - Optional, Sequence, Text, TypeVar, @@ -88,7 +87,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): diff --git a/stdlib/@python2/distutils/ccompiler.pyi b/stdlib/@python2/distutils/ccompiler.pyi index 7c7023ed0..4cdc62ce3 100644 --- a/stdlib/@python2/distutils/ccompiler.pyi +++ b/stdlib/@python2/distutils/ccompiler.pyi @@ -1,6 +1,6 @@ -from typing import Any, Callable, Optional, Union +from typing import Any, Callable, 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] diff --git a/stdlib/@python2/distutils/fancy_getopt.pyi b/stdlib/@python2/distutils/fancy_getopt.pyi index 02301aed6..bf3754aab 100644 --- a/stdlib/@python2/distutils/fancy_getopt.pyi +++ b/stdlib/@python2/distutils/fancy_getopt.pyi @@ -1,6 +1,6 @@ -from typing import Any, Mapping, Optional, overload +from typing import Any, Mapping, overload -_Option = tuple[str, Optional[str], str] +_Option = tuple[str, str | None, str] _GR = tuple[list[str], OptionDummy] def fancy_getopt( diff --git a/stdlib/@python2/email/mime/application.pyi b/stdlib/@python2/email/mime/application.pyi index 308b296c4..cb8c28126 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, Union +from typing import Callable, 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/imaplib.pyi b/stdlib/@python2/imaplib.pyi index fc17ca0aa..72003eb48 100644 --- a/stdlib/@python2/imaplib.pyi +++ b/stdlib/@python2/imaplib.pyi @@ -3,14 +3,14 @@ import time from builtins import list as List # alias to avoid name clashes with `IMAP4.list` from socket import socket as _socket from ssl import SSLSocket -from typing import IO, Any, Callable, Pattern, Text, Union +from typing import IO, Any, Callable, Pattern, Text from typing_extensions import Literal # TODO: Commands should use their actual return types, not this type alias. # E.g. tuple[Literal["OK"], list[bytes]] _CommandResults = tuple[str, list[Any]] -_AnyResponseData = Union[list[None], list[Union[bytes, tuple[bytes, bytes]]]] +_AnyResponseData = list[None] | list[bytes | tuple[bytes, bytes]] class IMAP4: error: type[Exception] = ... diff --git a/stdlib/@python2/inspect.pyi b/stdlib/@python2/inspect.pyi index 06912867c..8ffcc3edc 100644 --- a/stdlib/@python2/inspect.pyi +++ b/stdlib/@python2/inspect.pyi @@ -1,5 +1,5 @@ from types import CodeType, FrameType, FunctionType, MethodType, ModuleType, TracebackType -from typing import Any, AnyStr, Callable, NamedTuple, Optional, Sequence, Union +from typing import Any, AnyStr, Callable, NamedTuple, Sequence, Union # Types and members class EndOfBlock(Exception): ... @@ -106,7 +106,7 @@ class Traceback(NamedTuple): code_context: list[str] | None index: int | None # type: ignore[assignment] -_FrameInfo = tuple[FrameType, str, int, str, Optional[list[str]], Optional[int]] +_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/lib2to3/pgen2/grammar.pyi b/stdlib/@python2/lib2to3/pgen2/grammar.pyi index 32eed63d4..9d05082fc 100644 --- a/stdlib/@python2/lib2to3/pgen2/grammar.pyi +++ b/stdlib/@python2/lib2to3/pgen2/grammar.pyi @@ -1,7 +1,7 @@ from _typeshed import Self, StrPath -from typing import Optional, Text +from typing import Text -_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/pytree.pyi b/stdlib/@python2/lib2to3/pytree.pyi index 29699f651..a3969e60d 100644 --- a/stdlib/@python2/lib2to3/pytree.pyi +++ b/stdlib/@python2/lib2to3/pytree.pyi @@ -1,12 +1,12 @@ from _typeshed import Self from lib2to3.pgen2.grammar import Grammar -from typing import Any, Callable, Iterator, Optional, Text, TypeVar +from typing import Any, Callable, Iterator, Text, TypeVar _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 diff --git a/stdlib/@python2/logging/__init__.pyi b/stdlib/@python2/logging/__init__.pyi index 4e0a9dedf..059906d13 100644 --- a/stdlib/@python2/logging/__init__.pyi +++ b/stdlib/@python2/logging/__init__.pyi @@ -2,9 +2,9 @@ import threading from _typeshed import StrPath, SupportsWrite from time import struct_time from types import FrameType, TracebackType -from typing import IO, Any, Callable, Generic, Mapping, MutableMapping, Optional, Sequence, Text, TypeVar, Union, overload +from typing import IO, Any, Callable, Generic, Mapping, MutableMapping, Sequence, Text, TypeVar, 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 = Union[tuple[Any, ...], Mapping[str, Any]] _FilterType = Filter | Callable[[LogRecord], int] diff --git a/stdlib/@python2/msilib/sequence.pyi b/stdlib/@python2/msilib/sequence.pyi index 87dff7540..30346aba3 100644 --- a/stdlib/@python2/msilib/sequence.pyi +++ b/stdlib/@python2/msilib/sequence.pyi @@ -1,9 +1,8 @@ import sys -from typing import Optional 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/netrc.pyi b/stdlib/@python2/netrc.pyi index 3d92c7b4d..fc5fababa 100644 --- a/stdlib/@python2/netrc.pyi +++ b/stdlib/@python2/netrc.pyi @@ -1,4 +1,4 @@ -from typing import Optional, Text +from typing import Text class NetrcParseError(Exception): filename: str | None @@ -7,7 +7,7 @@ class NetrcParseError(Exception): 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] diff --git a/stdlib/@python2/os/__init__.pyi b/stdlib/@python2/os/__init__.pyi index 2ca9bce24..c2e806ff0 100644 --- a/stdlib/@python2/os/__init__.pyi +++ b/stdlib/@python2/os/__init__.pyi @@ -16,7 +16,6 @@ from typing import ( Sequence, Text, TypeVar, - Union, overload, ) @@ -269,7 +268,7 @@ 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 = 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: ... diff --git a/stdlib/@python2/pickle.pyi b/stdlib/@python2/pickle.pyi index bb9b6614f..c3052f5c3 100644 --- a/stdlib/@python2/pickle.pyi +++ b/stdlib/@python2/pickle.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, Iterator, Optional, Union +from typing import IO, Any, Callable, Iterator, Union HIGHEST_PROTOCOL: int bytes_types: tuple[type[Any], ...] # undocumented @@ -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/pkgutil.pyi b/stdlib/@python2/pkgutil.pyi index 8b54a72ec..aa220bc3a 100644 --- a/stdlib/@python2/pkgutil.pyi +++ b/stdlib/@python2/pkgutil.pyi @@ -1,12 +1,12 @@ from _typeshed import SupportsRead -from typing import IO, Any, Callable, Iterable, Iterator, TypeVar, Union +from typing import IO, Any, Callable, Iterable, Iterator, TypeVar Loader = Any MetaPathFinder = Any PathEntryFinder = Any _PathT = TypeVar("_PathT", bound=Iterable[str]) -_ModuleInfoLike = tuple[Union[MetaPathFinder, PathEntryFinder], str, bool] +_ModuleInfoLike = tuple[MetaPathFinder | PathEntryFinder, str, bool] def extend_path(path: _PathT, name: str) -> _PathT: ... diff --git a/stdlib/@python2/pyexpat/__init__.pyi b/stdlib/@python2/pyexpat/__init__.pyi index 8faaec294..5c58a0a1f 100644 --- a/stdlib/@python2/pyexpat/__init__.pyi +++ b/stdlib/@python2/pyexpat/__init__.pyi @@ -1,7 +1,7 @@ import pyexpat.errors as errors import pyexpat.model as model from _typeshed import SupportsRead -from typing import Any, Callable, Optional, Text +from typing import Any, Callable, Text EXPAT_VERSION: str # undocumented version_info: tuple[int, int, int] # undocumented @@ -19,7 +19,7 @@ XML_PARAM_ENTITY_PARSING_NEVER: int XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE: int XML_PARAM_ENTITY_PARSING_ALWAYS: int -_Model = tuple[int, int, Optional[str], tuple[Any, ...]] +_Model = tuple[int, int, str | None, tuple[Any, ...]] class XMLParserType(object): def Parse(self, __data: Text | bytes, __isfinal: bool = ...) -> int: ... diff --git a/stdlib/@python2/sndhdr.pyi b/stdlib/@python2/sndhdr.pyi index 0213a5d0c..fea65b288 100644 --- a/stdlib/@python2/sndhdr.pyi +++ b/stdlib/@python2/sndhdr.pyi @@ -1,6 +1,6 @@ -from typing import Text, Union +from typing import Text -_SndHeaders = tuple[str, int, int, int, Union[int, str]] +_SndHeaders = tuple[str, int, int, int, int | str] 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 29f4fe125..296a9fa5e 100644 --- a/stdlib/@python2/socket.pyi +++ b/stdlib/@python2/socket.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, BinaryIO, Iterable, Text, Union, overload +from typing import Any, BinaryIO, Iterable, Text, overload # ----- Constants ----- # Some socket families are listed in the "Socket families" section of the docs, @@ -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 diff --git a/stdlib/@python2/sre_parse.pyi b/stdlib/@python2/sre_parse.pyi index 81f14aca6..9929b8041 100644 --- a/stdlib/@python2/sre_parse.pyi +++ b/stdlib/@python2/sre_parse.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Match, Optional, Pattern as _Pattern +from typing import Any, Iterable, Match, Pattern as _Pattern SPECIAL_CHARS: str REPEAT_CHARS: str @@ -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]] @@ -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/trace.pyi b/stdlib/@python2/trace.pyi index aa35754cf..ea9dfba5b 100644 --- a/stdlib/@python2/trace.pyi +++ b/stdlib/@python2/trace.pyi @@ -1,12 +1,12 @@ import types from _typeshed import StrPath -from typing import Any, Callable, Mapping, Optional, Sequence, TypeVar +from typing import Any, Callable, Mapping, Sequence, TypeVar from typing_extensions import ParamSpec _T = TypeVar("_T") _P = ParamSpec("_P") _localtrace = Callable[[types.FrameType, str, Any], Callable[..., Any]] -_fileModuleFunction = tuple[str, Optional[str], str] +_fileModuleFunction = tuple[str, str | None, str] class CoverageResults: def __init__( diff --git a/stdlib/@python2/traceback.pyi b/stdlib/@python2/traceback.pyi index 94c75e5ef..34fc00ed7 100644 --- a/stdlib/@python2/traceback.pyi +++ b/stdlib/@python2/traceback.pyi @@ -1,7 +1,7 @@ from types import FrameType, TracebackType -from typing import IO, Optional +from typing import IO -_PT = tuple[str, int, str, Optional[str]] +_PT = tuple[str, int, str, str | None] def print_tb(tb: TracebackType | None, limit: int | None = ..., file: IO[str] | None = ...) -> None: ... def print_exception( diff --git a/stdlib/_socket.pyi b/stdlib/_socket.pyi index 1395d69da..a8cf16823 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, Union, overload +from typing import Any, SupportsInt, overload if sys.version_info >= (3, 8): from typing import SupportsIndex @@ -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 diff --git a/stdlib/_thread.pyi b/stdlib/_thread.pyi index 744799f1f..be66e6869 100644 --- a/stdlib/_thread.pyi +++ b/stdlib/_thread.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import structseq from threading import Thread from types import TracebackType -from typing import Any, Callable, NoReturn, Optional +from typing import Any, Callable, NoReturn from typing_extensions import final error = RuntimeError @@ -33,9 +33,7 @@ TIMEOUT_MAX: float if sys.version_info >= (3, 8): def get_native_id() -> int: ... # only available on some platforms @final - class _ExceptHookArgs( - structseq[Any], tuple[type[BaseException], Optional[BaseException], Optional[TracebackType], Optional[Thread]] - ): + class _ExceptHookArgs(structseq[Any], tuple[type[BaseException], BaseException | None, TracebackType | None, Thread | None]): @property def exc_type(self) -> type[BaseException]: ... @property diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index 17b59b9bc..7582258b4 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, Optional, Sequence +from typing import Any, Iterable, Sequence from typing_extensions import Literal __all__ = [ @@ -31,7 +31,7 @@ __all__ = [ "weekheader", ] -_LocaleType = tuple[Optional[str], Optional[str]] +_LocaleType = tuple[str | None, str | None] class IllegalMonthError(ValueError): def __init__(self, month: int) -> None: ... diff --git a/stdlib/cgitb.pyi b/stdlib/cgitb.pyi index fb9d69161..2db108ce7 100644 --- a/stdlib/cgitb.pyi +++ b/stdlib/cgitb.pyi @@ -1,8 +1,8 @@ from _typeshed import StrOrBytesPath from types import FrameType, TracebackType -from typing import IO, Any, Callable, Optional +from typing import IO, Any, Callable -_ExcInfo = tuple[Optional[type[BaseException]], Optional[BaseException], Optional[TracebackType]] +_ExcInfo = tuple[type[BaseException] | None, BaseException | None, TracebackType | None] __UNDEF__: object # undocumented sentinel diff --git a/stdlib/copyreg.pyi b/stdlib/copyreg.pyi index 8ac3e87ef..4844a8028 100644 --- a/stdlib/copyreg.pyi +++ b/stdlib/copyreg.pyi @@ -1,7 +1,7 @@ -from typing import Any, Callable, Hashable, Optional, SupportsInt, TypeVar, Union +from typing import Any, Callable, Hashable, SupportsInt, TypeVar, Union _T = TypeVar("_T") -_Reduce = Union[tuple[Callable[..., _T], tuple[Any, ...]], tuple[Callable[..., _T], tuple[Any, ...], Optional[Any]]] +_Reduce = Union[tuple[Callable[..., _T], tuple[Any, ...]], tuple[Callable[..., _T], tuple[Any, ...], Any | None]] __all__ = ["pickle", "constructor", "add_extension", "remove_extension", "clear_extension_cache"] diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index 7513948e6..4a03886e8 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -1,20 +1,7 @@ import sys from _typeshed import ReadableBuffer, Self, WriteableBuffer from abc import abstractmethod -from typing import ( - Any, - Callable, - ClassVar, - Generic, - Iterable, - Iterator, - Mapping, - Optional, - Sequence, - TypeVar, - Union as _UnionT, - overload, -) +from typing import Any, Callable, ClassVar, Generic, Iterable, Iterator, Mapping, Sequence, TypeVar, Union as _UnionT, overload if sys.version_info >= (3, 9): from types import GenericAlias @@ -97,7 +84,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): diff --git a/stdlib/distutils/ccompiler.pyi b/stdlib/distutils/ccompiler.pyi index 7c7023ed0..4cdc62ce3 100644 --- a/stdlib/distutils/ccompiler.pyi +++ b/stdlib/distutils/ccompiler.pyi @@ -1,6 +1,6 @@ -from typing import Any, Callable, Optional, Union +from typing import Any, Callable, 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] diff --git a/stdlib/distutils/fancy_getopt.pyi b/stdlib/distutils/fancy_getopt.pyi index dce8394b6..c2a5bd4c2 100644 --- a/stdlib/distutils/fancy_getopt.pyi +++ b/stdlib/distutils/fancy_getopt.pyi @@ -1,6 +1,6 @@ -from typing import Any, Iterable, Mapping, Optional, overload +from typing import Any, Iterable, Mapping, overload -_Option = tuple[str, Optional[str], str] +_Option = tuple[str, str | None, str] _GR = tuple[list[str], OptionDummy] def fancy_getopt( diff --git a/stdlib/email/message.pyi b/stdlib/email/message.pyi index 42c25c798..b5ae38d23 100644 --- a/stdlib/email/message.pyi +++ b/stdlib/email/message.pyi @@ -4,7 +4,7 @@ from email.errors import MessageDefect from email.policy import Policy # using a type alias ("_HeaderType = Any") breaks mypy, who knows why -from typing import Any, Any as _HeaderType, Generator, Iterator, Optional, Sequence, TypeVar, Union +from typing import Any, Any as _HeaderType, Generator, Iterator, Sequence, TypeVar, Union __all__ = ["Message", "EmailMessage"] @@ -12,8 +12,8 @@ _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]] class Message: policy: Policy # undocumented diff --git a/stdlib/email/mime/application.pyi b/stdlib/email/mime/application.pyi index 978324c03..c0b2a41c5 100644 --- a/stdlib/email/mime/application.pyi +++ b/stdlib/email/mime/application.pyi @@ -1,10 +1,10 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Callable, Optional, Union +from typing import Callable, Union __all__ = ["MIMEApplication"] -_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/email/mime/audio.pyi b/stdlib/email/mime/audio.pyi index aa7b9ceb2..438209a90 100644 --- a/stdlib/email/mime/audio.pyi +++ b/stdlib/email/mime/audio.pyi @@ -1,10 +1,10 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Callable, Optional, Union +from typing import Callable, Union __all__ = ["MIMEAudio"] -_ParamsType = Union[str, None, tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, str | None, str]] class MIMEAudio(MIMENonMultipart): def __init__( diff --git a/stdlib/email/mime/base.pyi b/stdlib/email/mime/base.pyi index faa561fcb..d583f696f 100644 --- a/stdlib/email/mime/base.pyi +++ b/stdlib/email/mime/base.pyi @@ -1,10 +1,10 @@ import email.message from email.policy import Policy -from typing import Optional, Union +from typing import Union __all__ = ["MIMEBase"] -_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: Policy | None = ..., **_params: _ParamsType) -> None: ... diff --git a/stdlib/email/mime/image.pyi b/stdlib/email/mime/image.pyi index 4e767e6aa..a2d1f142b 100644 --- a/stdlib/email/mime/image.pyi +++ b/stdlib/email/mime/image.pyi @@ -1,10 +1,10 @@ from email.mime.nonmultipart import MIMENonMultipart from email.policy import Policy -from typing import Callable, Optional, Union +from typing import Callable, Union __all__ = ["MIMEImage"] -_ParamsType = Union[str, None, tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, str | None, str]] class MIMEImage(MIMENonMultipart): def __init__( diff --git a/stdlib/email/mime/multipart.pyi b/stdlib/email/mime/multipart.pyi index 3b70d5875..255fc9d5d 100644 --- a/stdlib/email/mime/multipart.pyi +++ b/stdlib/email/mime/multipart.pyi @@ -1,11 +1,11 @@ from email.message import Message from email.mime.base import MIMEBase from email.policy import Policy -from typing import Optional, Sequence, Union +from typing import Sequence, Union __all__ = ["MIMEMultipart"] -_ParamsType = Union[str, None, tuple[str, Optional[str], str]] +_ParamsType = Union[str, None, tuple[str, str | None, str]] class MIMEMultipart(MIMEBase): def __init__( diff --git a/stdlib/email/utils.pyi b/stdlib/email/utils.pyi index 2b7f1bab3..0cad7d950 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 Optional, Union, overload +from typing import Union, overload __all__ = [ "collapse_rfc2231_value", @@ -21,8 +21,8 @@ __all__ = [ "unquote", ] -_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: ... diff --git a/stdlib/grp.pyi b/stdlib/grp.pyi index 732c36b3d..5ea7500b3 100644 --- a/stdlib/grp.pyi +++ b/stdlib/grp.pyi @@ -1,11 +1,11 @@ import sys from _typeshed import structseq -from typing import Any, Optional +from typing import Any from typing_extensions import final if sys.platform != "win32": @final - class struct_group(structseq[Any], tuple[str, Optional[str], int, list[str]]): + class struct_group(structseq[Any], tuple[str, str | None, int, list[str]]): @property def gr_name(self) -> str: ... @property diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index e85e7d4ad..ab6490cea 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -5,7 +5,7 @@ from _typeshed import Self from socket import socket as _socket from ssl import SSLContext, SSLSocket from types import TracebackType -from typing import IO, Any, Callable, Pattern, Union +from typing import IO, Any, Callable, Pattern from typing_extensions import Literal __all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", "Int2AP", "ParseFlags", "Time2Internaldate", "IMAP4_SSL"] @@ -14,7 +14,7 @@ __all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", "Int2AP", "ParseFlags" # E.g. Tuple[Literal["OK"], List[bytes]] _CommandResults = tuple[str, list[Any]] -_AnyResponseData = Union[list[None], list[Union[bytes, tuple[bytes, bytes]]]] +_AnyResponseData = list[None] | list[bytes | tuple[bytes, bytes]] _list = list # conflicts with a method named "list" diff --git a/stdlib/lib2to3/pgen2/grammar.pyi b/stdlib/lib2to3/pgen2/grammar.pyi index 3c3b90c52..b5836e1b9 100644 --- a/stdlib/lib2to3/pgen2/grammar.pyi +++ b/stdlib/lib2to3/pgen2/grammar.pyi @@ -1,7 +1,6 @@ from _typeshed import Self, StrPath -from typing import Optional -_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/pytree.pyi b/stdlib/lib2to3/pytree.pyi index ccd347e39..68e5d8ba1 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -1,11 +1,11 @@ from _typeshed import Self from lib2to3.pgen2.grammar import Grammar -from typing import Any, Callable, Iterator, Optional +from typing import Any, Callable, Iterator _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 diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index ac4631e8c..8de4d0d88 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -6,7 +6,7 @@ from io import TextIOWrapper from string import Template from time import struct_time from types import FrameType, TracebackType -from typing import Any, ClassVar, Generic, Optional, Pattern, TextIO, TypeVar, Union, overload +from typing import Any, ClassVar, Generic, Pattern, TextIO, TypeVar, Union, overload from typing_extensions import Literal __all__ = [ @@ -54,9 +54,9 @@ __all__ = [ "raiseExceptions", ] -_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 = Union[tuple[object, ...], Mapping[str, object]] +_ArgsType = tuple[object, ...] | Mapping[str, object] _FilterType = Filter | Callable[[LogRecord], int] _Level = int | str _FormatStyle = Literal["%", "{", "$"] diff --git a/stdlib/msilib/sequence.pyi b/stdlib/msilib/sequence.pyi index 87dff7540..30346aba3 100644 --- a/stdlib/msilib/sequence.pyi +++ b/stdlib/msilib/sequence.pyi @@ -1,9 +1,8 @@ import sys -from typing import Optional 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/netrc.pyi b/stdlib/netrc.pyi index b1c3f5ec5..45f6cfbed 100644 --- a/stdlib/netrc.pyi +++ b/stdlib/netrc.pyi @@ -1,5 +1,4 @@ from _typeshed import StrOrBytesPath -from typing import Optional __all__ = ["netrc", "NetrcParseError"] @@ -10,7 +9,7 @@ class NetrcParseError(Exception): def __init__(self, msg: str, filename: StrOrBytesPath | None = ..., lineno: int | None = ...) -> None: ... # (login, account, password) tuple -_NetrcTuple = tuple[str, Optional[str], Optional[str]] +_NetrcTuple = tuple[str, str | None, str | None] class netrc: hosts: dict[str, _NetrcTuple] diff --git a/stdlib/pickle.pyi b/stdlib/pickle.pyi index 3a9fd9c08..26ee94ca2 100644 --- a/stdlib/pickle.pyi +++ b/stdlib/pickle.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, ClassVar, Iterable, Iterator, Mapping, Optional, Protocol, Union +from typing import Any, Callable, ClassVar, Iterable, Iterator, Mapping, Protocol, Union from typing_extensions import final if sys.version_info >= (3, 8): @@ -227,8 +227,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/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index 5aca55c2b..24c93965b 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -1,7 +1,7 @@ import pyexpat.errors as errors import pyexpat.model as model from _typeshed import SupportsRead -from typing import Any, Callable, Optional +from typing import Any, Callable from typing_extensions import final EXPAT_VERSION: str # undocumented @@ -20,7 +20,7 @@ XML_PARAM_ENTITY_PARSING_NEVER: int XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE: int XML_PARAM_ENTITY_PARSING_ALWAYS: int -_Model = tuple[int, int, Optional[str], tuple[Any, ...]] +_Model = tuple[int, int, str | None, tuple[Any, ...]] @final class XMLParserType: diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index 5bf95d2ee..3136667dc 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -4,7 +4,7 @@ from email.message import Message as _Message from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Pattern, Protocol, Sequence, Union, overload +from typing import Any, Pattern, Protocol, Sequence, overload if sys.version_info >= (3, 7): __all__ = [ @@ -43,7 +43,7 @@ else: _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/sre_parse.pyi b/stdlib/sre_parse.pyi index 8d50b4419..05e71c255 100644 --- a/stdlib/sre_parse.pyi +++ b/stdlib/sre_parse.pyi @@ -1,7 +1,7 @@ import sys from sre_constants import * from sre_constants import _NamedIntConstant as _NIC, error as _Error -from typing import Any, Iterable, Match, Optional, Pattern as _Pattern, overload +from typing import Any, Iterable, Match, Pattern as _Pattern, overload SPECIAL_CHARS: str REPEAT_CHARS: str @@ -37,7 +37,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]] @@ -87,8 +87,8 @@ class Tokenizer: def fix_flags(src: str | bytes, flags: int) -> int: ... -_TemplateType = tuple[list[tuple[int, int]], list[Optional[str]]] -_TemplateByteType = tuple[list[tuple[int, int]], list[Optional[bytes]]] +_TemplateType = tuple[list[tuple[int, int]], list[str | None]] +_TemplateByteType = tuple[list[tuple[int, int]], list[bytes | None]] if sys.version_info >= (3, 8): def parse(str: str, flags: int = ..., state: State | None = ...) -> SubPattern: ... @overload diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index dbf3309c5..b7fe6914d 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, str | None, SSLSocket], int | None] diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index e16f325b5..4b0101b32 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -1,7 +1,7 @@ import _tkinter import sys import tkinter -from typing import Any, Union, overload +from typing import Any, overload from typing_extensions import Literal, TypedDict if sys.version_info >= (3, 9): @@ -12,17 +12,13 @@ ROMAN: Literal["roman"] BOLD: Literal["bold"] ITALIC: Literal["italic"] -_FontDescription = Union[ - # "Helvetica 12" - str, - # A font object constructed in Python - Font, - # ("Helvetica", 12, BOLD) - list[Any], - tuple[Any, ...], - # A font object constructed in Tcl - _tkinter.Tcl_Obj, -] +_FontDescription = ( + str # "Helvetica 12" + | Font # A font object constructed in Python + | list[Any] # ("Helvetica", 12, BOLD) + | tuple[Any, ...] + | _tkinter.Tcl_Obj # A font object constructed in Tcl +) class _FontDict(TypedDict): family: str diff --git a/stdlib/trace.pyi b/stdlib/trace.pyi index 640b01459..612806447 100644 --- a/stdlib/trace.pyi +++ b/stdlib/trace.pyi @@ -1,7 +1,7 @@ import sys import types from _typeshed import StrPath -from typing import Any, Callable, Mapping, Optional, Sequence, TypeVar +from typing import Any, Callable, Mapping, Sequence, TypeVar from typing_extensions import ParamSpec __all__ = ["Trace", "CoverageResults"] @@ -9,7 +9,7 @@ __all__ = ["Trace", "CoverageResults"] _T = TypeVar("_T") _P = ParamSpec("_P") _localtrace = Callable[[types.FrameType, str, Any], Callable[..., Any]] -_fileModuleFunction = tuple[str, Optional[str], str] +_fileModuleFunction = tuple[str, str | None, str] class CoverageResults: def __init__( diff --git a/stdlib/tracemalloc.pyi b/stdlib/tracemalloc.pyi index cebf0f7a8..e2e6800cb 100644 --- a/stdlib/tracemalloc.pyi +++ b/stdlib/tracemalloc.pyi @@ -1,6 +1,6 @@ import sys from _tracemalloc import * -from typing import Any, Optional, Sequence, Union, overload +from typing import Any, Sequence, Union, overload from typing_extensions import SupportsIndex def get_object_traceback(obj: object) -> Traceback | None: ... @@ -61,7 +61,7 @@ class Frame: def __le__(self, other: Frame, NotImplemented: Any = ...) -> bool: ... 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]] diff --git a/stdlib/xmlrpc/server.pyi b/stdlib/xmlrpc/server.pyi index 3675402fb..2ed0b03c7 100644 --- a/stdlib/xmlrpc/server.pyi +++ b/stdlib/xmlrpc/server.pyi @@ -3,11 +3,11 @@ import pydoc import socketserver import sys from datetime import datetime -from typing import Any, Callable, Iterable, Mapping, Pattern, Protocol, Union +from typing import Any, Callable, Iterable, Mapping, Pattern, Protocol from xmlrpc.client import Fault # TODO: Recursive type on tuple, list, dict -_Marshallable = Union[None, bool, int, float, str, bytes, tuple[Any, ...], list[Any], dict[Any, Any], datetime] +_Marshallable = None | bool | int | float | str | bytes | tuple[Any, ...] | list[Any] | dict[Any, Any] | datetime # The dispatch accepts anywhere from 0 to N arguments, no easy way to allow this in mypy class _DispatchArity0(Protocol): diff --git a/stubs/Pillow/PIL/Image.pyi b/stubs/Pillow/PIL/Image.pyi index d084d65ec..fda33b248 100644 --- a/stubs/Pillow/PIL/Image.pyi +++ b/stubs/Pillow/PIL/Image.pyi @@ -22,7 +22,7 @@ _Box = tuple[int, int, int, int] _ConversionMatrix = Union[ tuple[float, float, float, float], tuple[float, float, float, float, float, float, float, float, float, float, float, float], ] -_Color = Union[float, tuple[float, ...]] +_Color = float | tuple[float, ...] class _Writeable(SupportsWrite[bytes], Protocol): def seek(self, __offset: int) -> Any: ...