diff --git a/stdlib/@python2/BaseHTTPServer.pyi b/stdlib/@python2/BaseHTTPServer.pyi index 28fc4de0409b..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, Optional, Tuple, Union +from typing import Any, BinaryIO, Callable, Mapping, Tuple class HTTPServer(SocketServer.TCPServer): server_name: str @@ -27,15 +27,15 @@ 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: ... - def log_request(self, code: Union[int, str] = ..., size: Union[int, str] = ...) -> None: ... + def log_request(self, code: int | str = ..., size: int | str = ...) -> None: ... def log_error(self, format: str, *args: Any) -> None: ... def log_message(self, format: str, *args: Any) -> None: ... def version_string(self) -> str: ... - def date_time_string(self, timestamp: Optional[int] = ...) -> str: ... + def date_time_string(self, timestamp: int | None = ...) -> str: ... def log_date_time_string(self) -> str: ... def address_string(self) -> str: ... diff --git a/stdlib/@python2/ConfigParser.pyi b/stdlib/@python2/ConfigParser.pyi index 05c90ed2c248..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, Optional, Sequence, Tuple, Union +from typing import IO, Any, Dict, List, Sequence, Tuple DEFAULTSECT: str MAX_INTERPOLATION_DEPTH: int @@ -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]]: ... @@ -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/Cookie.pyi b/stdlib/@python2/Cookie.pyi index 91dd93221c73..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): ... @@ -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..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") @@ -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/SimpleHTTPServer.pyi b/stdlib/@python2/SimpleHTTPServer.pyi index 7e62b49e8bc6..758d5bd6d515 100644 --- a/stdlib/@python2/SimpleHTTPServer.pyi +++ b/stdlib/@python2/SimpleHTTPServer.pyi @@ -1,14 +1,14 @@ import BaseHTTPServer from StringIO import StringIO -from typing import IO, Any, AnyStr, Mapping, Optional, Union +from typing import IO, Any, AnyStr, Mapping 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: Union[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: 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 e7f84e7cb7a5..e5a19ffd5e68 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 @@ -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: ... @@ -46,22 +46,22 @@ 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: ... if sys.platform != "win32": class ForkingMixIn: - timeout: Optional[float] # undocumented - active_children: Optional[List[int]] # undocumented + timeout: float | None # undocumented + active_children: List[int] | None # undocumented max_children: int # undocumented def collect_children(self) -> None: ... # undocumented def handle_timeout(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..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 @@ -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 afa07d861a9e..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, - Optional, - Sized, - Tuple, - TypeVar, - Union, - overload, -) +from typing import Any, Container, Dict, Generic, Iterable, Iterator, List, Mapping, Sized, Tuple, TypeVar, overload _KT = TypeVar("_KT") _VT = TypeVar("_VT") @@ -33,9 +18,9 @@ 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: 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..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") @@ -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..f60dbe18f9b1 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, overload _UST = TypeVar("_UST", bound=UserString) _MST = TypeVar("_MST", bound=MutableString) @@ -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: Union[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: Union[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: ... @@ -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..ebe9cdd95038 100644 --- a/stdlib/@python2/__builtin__.pyi +++ b/stdlib/@python2/__builtin__.pyi @@ -26,7 +26,6 @@ from typing import ( MutableSequence, MutableSet, NoReturn, - Optional, Protocol, Reversible, Sequence, @@ -40,7 +39,6 @@ from typing import ( Tuple, Type, TypeVar, - Union, ValuesView, overload, ) @@ -66,9 +64,9 @@ _TT = TypeVar("_TT", bound="type") _TBE = TypeVar("_TBE", bound="BaseException") class object: - __doc__: Optional[str] + __doc__: str | None __dict__: Dict[str, Any] - __slots__: Union[Text, Iterable[Text]] + __slots__: Text | Iterable[Text] __module__: str @property def __class__(self: _T) -> Type[_T]: ... @@ -86,20 +84,20 @@ 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] 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 @@ -137,9 +135,9 @@ class super(object): class int: @overload - def __new__(cls: Type[_T], x: Union[Text, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc] = ...) -> _T: ... + def __new__(cls: Type[_T], x: 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 @@ -167,10 +165,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: ... @@ -201,7 +199,7 @@ class int: def __index__(self) -> int: ... class float: - def __new__(cls: Type[_T], x: Union[SupportsFloat, _SupportsIndex, Text, bytes, bytearray] = ...) -> _T: ... + def __new__(cls: Type[_T], x: SupportsFloat | _SupportsIndex | Text | bytes | bytearray = ...) -> _T: ... def as_integer_ratio(self) -> Tuple[int, int]: ... def hex(self) -> str: ... def is_integer(self) -> bool: ... @@ -253,7 +251,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 @@ -295,9 +293,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: Union[unicode, Tuple[unicode, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... - ) -> 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: ... @@ -323,17 +319,15 @@ 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: Union[unicode, Tuple[unicode, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... - ) -> 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: ... - 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 @@ -353,7 +347,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: ... @@ -369,17 +363,15 @@ 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: Union[Text, Tuple[Text, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... - ) -> 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: 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 +393,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 +403,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,28 +411,26 @@ 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: Union[Text, Tuple[Text, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... - ) -> bool: ... + def startswith(self, __prefix: Text | Tuple[Text, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... @overload def strip(self, __chars: str = ...) -> str: ... @overload 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: ... # 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]: ... @@ -475,11 +465,9 @@ 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: Union[bytes, Tuple[bytes, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... - ) -> 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: 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: ... @@ -493,21 +481,19 @@ 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: Union[bytes, Tuple[bytes, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... - ) -> bool: ... - def strip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... + 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: ... def translate(self, __table: str) -> bytearray: ... @@ -529,15 +515,15 @@ 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 __delitem__(self, i: Union[int, slice]) -> 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: ... # 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: ... @@ -548,9 +534,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: ... @@ -662,7 +648,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,18 +729,18 @@ 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]: ... + 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 __xor__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... - def __ixor__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... + def __isub__(self, s: AbstractSet[_T | None]) -> Set[_T]: ... + def __xor__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... + def __ixor__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... def __le__(self, s: AbstractSet[object]) -> bool: ... def __lt__(self, s: AbstractSet[object]) -> bool: ... def __ge__(self, s: AbstractSet[object]) -> bool: ... @@ -776,9 +762,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: ... @@ -802,15 +788,15 @@ class xrange(Sized, Iterable[int], Reversible[int]): class property(object): def __init__( self, - fget: Optional[Callable[[Any], Any]] = ..., - fset: Optional[Callable[[Any, Any], None]] = ..., - fdel: Optional[Callable[[Any], None]] = ..., - doc: Optional[str] = ..., + fget: Callable[[Any], Any] | None = ..., + fset: Callable[[Any, Any], None] | None = ..., + fdel: Callable[[Any], None] | None = ..., + doc: str | None = ..., ) -> None: ... def getter(self, fget: Callable[[Any], Any]) -> property: ... def setter(self, fset: Callable[[Any, Any], None]) -> property: ... def deleter(self, fdel: Callable[[Any], None]) -> property: ... - def __get__(self, obj: Any, type: Optional[type] = ...) -> Any: ... + def __get__(self, obj: Any, type: type | None = ...) -> Any: ... def __set__(self, obj: Any, value: Any) -> None: ... def __delete__(self, obj: Any) -> None: ... def fget(self) -> Any: ... @@ -829,8 +815,8 @@ 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 bin(__number: Union[int, _SupportsIndex]) -> str: ... +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: ... def cmp(__x: Any, __y: Any) -> int: ... @@ -838,7 +824,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]: ... @@ -846,18 +832,18 @@ _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: 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 @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,26 +853,26 @@ 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) -> 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: ... @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[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... -def issubclass(__cls: type, __class_or_tuple: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... +def isinstance(__obj: object, __class_or_tuple: type | Tuple[type | Tuple[Any, ...], ...]) -> bool: ... +def issubclass(__cls: type, __class_or_tuple: type | Tuple[type | Tuple[Any, ...], ...]) -> bool: ... def len(__obj: Sized) -> int: ... def locals() -> Dict[str, Any]: ... @overload @@ -966,15 +952,13 @@ 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( - *values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[SupportsWrite[Any]] = ... -) -> 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) @@ -1018,12 +1002,12 @@ def round(number: SupportsFloat) -> float: ... def round(number: SupportsFloat, ndigits: int) -> float: ... def setattr(__obj: Any, __name: Text, __value: Any) -> None: ... def sorted( - __iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Optional[Callable[[_T], Any]] = ..., reverse: bool = ... + __iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Callable[[_T], Any] | None = ..., 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 @@ -1052,8 +1036,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: ... @@ -1071,7 +1055,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: ... @@ -1119,10 +1103,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): ... @@ -1181,9 +1165,7 @@ class file(BinaryIO): def next(self) -> str: ... def read(self, n: int = ...) -> str: ... def __enter__(self) -> BinaryIO: ... - def __exit__( - self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ... - ) -> Optional[bool]: ... + 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: ... @@ -1197,4 +1179,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..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 @@ -41,7 +40,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 +55,7 @@ class AugAssign(stmt): value: expr class Print(stmt): - dest: Optional[expr] + dest: expr | None values: typing.List[expr] nl: bool @@ -78,13 +77,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 +96,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 +125,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 +188,7 @@ class GeneratorExp(expr): generators: typing.List[comprehension] class Yield(expr): - value: Optional[expr] + value: expr | None class Compare(expr): left: expr @@ -200,8 +199,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 +281,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 +299,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..e3327a0af4e6 100644 --- a/stdlib/@python2/_bisect.pyi +++ b/stdlib/@python2/_bisect.pyi @@ -1,8 +1,8 @@ -from typing import MutableSequence, Optional, Sequence, TypeVar +from typing import MutableSequence, 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 70f7da857f5a..83601f6621bb 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]] @@ -16,17 +16,17 @@ 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]: ... 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 f97b6d5d6dd1..22ada07d0f24 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 _K = TypeVar("_K") _V = TypeVar("_V") @@ -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: ... @@ -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/_csv.pyi b/stdlib/@python2/_csv.pyi index e194cc625889..ebe44bab67d9 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 @@ -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 d6c286e37d13..32c1f761ac9e 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 = Union[str, bytes, int] @@ -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 bab2acdc84cd..e45a1b5c4a89 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, Optional, Text, Type, TypeVar # TODO recursive type _TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] @@ -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] = ..., + 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: ... - 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: Type[BaseException] | None, 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,22 +63,22 @@ class _RLock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... RLock = _RLock class Condition: - def __init__(self, lock: Union[Lock, _RLock, None] = ...) -> None: ... + def __init__(self, lock: Lock | _RLock | None = ...) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> 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: 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: ... 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/_heapq.pyi b/stdlib/@python2/_heapq.pyi index f02fc470df14..08a8add08e9a 100644 --- a/stdlib/@python2/_heapq.pyi +++ b/stdlib/@python2/_heapq.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Iterable, List, Optional, TypeVar +from typing import Any, Callable, Iterable, List, TypeVar _T = TypeVar("_T") @@ -7,5 +7,5 @@ def heappop(__heap: List[_T]) -> _T: ... def heappush(__heap: List[_T], __item: _T) -> None: ... def heappushpop(__heap: List[_T], __item: _T) -> _T: ... def heapreplace(__heap: List[_T], __item: _T) -> _T: ... -def nlargest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... -def nsmallest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ... +def nlargest(__n: int, __iterable: Iterable[_T], __key: Callable[[_T], Any] | None = ...) -> List[_T]: ... +def nsmallest(__n: int, __iterable: Iterable[_T], __key: Callable[[_T], Any] | None = ...) -> List[_T]: ... diff --git a/stdlib/@python2/_io.pyi b/stdlib/@python2/_io.pyi index 2d825b07bb85..fedbbe137940 100644 --- a/stdlib/@python2/_io.pyi +++ b/stdlib/@python2/_io.pyi @@ -1,6 +1,6 @@ from _typeshed import Self 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 = Union[bytearray, mmap] @@ -16,7 +16,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: ... @@ -29,12 +29,10 @@ 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: Self) -> Self: ... - def __exit__( - self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any] - ) -> Optional[bool]: ... + 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: ... @@ -100,12 +98,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]: ... @@ -114,9 +112,9 @@ 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: Union[None, unicode, bytes] + newlines: None | unicode | bytes encoding: str @property def closed(self) -> bool: ... @@ -137,19 +135,17 @@ 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: Self) -> Self: ... - def __exit__( - self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any] - ) -> Optional[bool]: ... + def __exit__(self, t: Type[BaseException] | None, 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 @@ -166,19 +162,19 @@ 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: ... def open( - file: Union[str, unicode, int], + 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 a8f9c60bbadd..a1030a66160f 100644 --- a/stdlib/@python2/_msi.pyi +++ b/stdlib/@python2/_msi.pyi @@ -1,11 +1,11 @@ import sys -from typing import List, Optional, Union +from typing import List if sys.platform == "win32": # Actual typename View, not exposed by the implementation class _View: - def Execute(self, params: Optional[_Record] = ...) -> None: ... + def Execute(self, params: _Record | None = ...) -> None: ... def GetColumnInfo(self, kind: int) -> _Record: ... def Fetch(self) -> _Record: ... def Modify(self, mode: int, record: _Record) -> None: ... @@ -15,9 +15,9 @@ if sys.platform == "win32": __init__: None # type: ignore # Actual typename Summary, not exposed by the implementation class _Summary: - def GetProperty(self, propid: int) -> Optional[Union[str, bytes]]: ... + def GetProperty(self, propid: int) -> str | bytes | None: ... def GetPropertyCount(self) -> int: ... - def SetProperty(self, propid: int, value: Union[str, bytes]) -> None: ... + def SetProperty(self, propid: int, value: str | bytes) -> None: ... def Persist(self) -> None: ... # Don't exist at runtime __new__: None # type: ignore diff --git a/stdlib/@python2/_osx_support.pyi b/stdlib/@python2/_osx_support.pyi index 5d67d996b30a..1b890d8d8a0a 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 _T = TypeVar("_T") _K = TypeVar("_K") @@ -10,11 +10,11 @@ _UNIVERSAL_CONFIG_VARS: Tuple[str, ...] # undocumented _COMPILER_CONFIG_VARS: Tuple[str, ...] # undocumented _INITPRE: str # undocumented -def _find_executable(executable: str, path: Optional[str] = ...) -> Optional[str]: ... # undocumented -def _read_output(commandstring: str) -> Optional[str]: ... # undocumented +def _find_executable(executable: str, path: str | None = ...) -> str | None: ... # undocumented +def _read_output(commandstring: str) -> str | None: ... # undocumented def _find_build_tool(toolname: str) -> str: ... # undocumented -_SYSTEM_VERSION: Optional[str] # undocumented +_SYSTEM_VERSION: str | None # undocumented def _get_system_version() -> str: ... # undocumented def _remove_original_values(_config_vars: Dict[str, str]) -> None: ... # undocumented @@ -30,4 +30,4 @@ def customize_config_vars(_config_vars: Dict[str, str]) -> Dict[str, str]: ... def customize_compiler(_config_vars: Dict[str, str]) -> Dict[str, str]: ... def get_platform_osx( _config_vars: Dict[str, str], osname: _T, release: _K, machine: _V -) -> Tuple[Union[str, _T], Union[str, _K], Union[str, _V]]: ... +) -> Tuple[str | _T, str | _K, str | _V]: ... diff --git a/stdlib/@python2/_sha256.pyi b/stdlib/@python2/_sha256.pyi index b6eb47d4bc83..746432094bf2 100644 --- a/stdlib/@python2/_sha256.pyi +++ b/stdlib/@python2/_sha256.pyi @@ -1,11 +1,9 @@ -from typing import Optional - class sha224(object): name: str 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 +14,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..90e2aee1542f 100644 --- a/stdlib/@python2/_sha512.pyi +++ b/stdlib/@python2/_sha512.pyi @@ -1,11 +1,9 @@ -from typing import Optional - class sha384(object): name: str 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 +14,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 61c0def50587..c505384c5226 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, overload AF_APPLETALK: int AF_ASH: int @@ -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 settimeout(self, value: Optional[float]) -> None: ... + def setsockopt(self, level: int, option: int, value: int | str) -> 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 263f1da05632..3bacc097451e 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, overload CODESIZE: int MAGIC: int @@ -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 @@ -30,12 +30,12 @@ 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: ... - 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..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 @@ -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: 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/_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..6a5d2531ca72 100644 --- a/stdlib/@python2/_typeshed/xml.pyi +++ b/stdlib/@python2/_typeshed/xml.pyi @@ -1,10 +1,10 @@ # 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 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..ccc51fecb8da 100644 --- a/stdlib/@python2/_warnings.pyi +++ b/stdlib/@python2/_warnings.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Tuple, Type, Union, overload +from typing import Any, Dict, List, Tuple, Type, overload default_action: str once_registry: Dict[Any, Any] @@ -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 @@ -15,9 +15,9 @@ def warn_explicit( category: Type[Warning], filename: str, lineno: int, - module: Optional[str] = ..., - registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., + module: str | None = ..., + registry: Dict[str | Tuple[str, Type[Warning], int], int] | None = ..., + module_globals: Dict[str, Any] | None = ..., ) -> None: ... @overload def warn_explicit( @@ -25,7 +25,7 @@ def warn_explicit( category: Any, filename: str, lineno: int, - module: Optional[str] = ..., - registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ..., - module_globals: Optional[Dict[str, Any]] = ..., + module: str | None = ..., + registry: Dict[str | Tuple[str, Type[Warning], int], int] | None = ..., + module_globals: Dict[str, Any] | None = ..., ) -> None: ... diff --git a/stdlib/@python2/_weakref.pyi b/stdlib/@python2/_weakref.pyi index e8882b6f18b8..a283d4cb60d3 100644 --- a/stdlib/@python2/_weakref.pyi +++ b/stdlib/@python2/_weakref.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Generic, List, Optional, TypeVar, overload +from typing import Any, Callable, Generic, List, TypeVar, overload _C = TypeVar("_C", bound=Callable[..., Any]) _T = TypeVar("_T") @@ -10,8 +10,8 @@ class ProxyType(Generic[_T]): # "weakproxy" def __getattr__(self, attr: str) -> Any: ... class ReferenceType(Generic[_T]): - def __init__(self, o: _T, callback: Optional[Callable[[ReferenceType[_T]], Any]] = ...) -> None: ... - def __call__(self) -> Optional[_T]: ... + def __init__(self, o: _T, callback: Callable[[ReferenceType[_T]], Any] | None = ...) -> None: ... + def __call__(self) -> _T | None: ... def __hash__(self) -> int: ... ref = ReferenceType @@ -19,8 +19,8 @@ ref = ReferenceType def getweakrefcount(__object: Any) -> int: ... def getweakrefs(object: Any) -> List[Any]: ... @overload -def proxy(object: _C, callback: Optional[Callable[[_C], Any]] = ...) -> CallableProxyType[_C]: ... +def proxy(object: _C, callback: Callable[[_C], Any] | None = ...) -> CallableProxyType[_C]: ... # Return CallableProxyType if object is callable, ProxyType otherwise @overload -def proxy(object: _T, callback: Optional[Callable[[_T], Any]] = ...) -> Any: ... +def proxy(object: _T, callback: Callable[[_T], Any] | None = ...) -> Any: ... diff --git a/stdlib/@python2/_weakrefset.pyi b/stdlib/@python2/_weakrefset.pyi index 99fa3e31166a..f2cde7d67e52 100644 --- a/stdlib/@python2/_weakrefset.pyi +++ b/stdlib/@python2/_weakrefset.pyi @@ -1,11 +1,11 @@ -from typing import Any, Generic, Iterable, Iterator, MutableSet, Optional, TypeVar, Union +from typing import Any, Generic, Iterable, Iterator, MutableSet, TypeVar _S = TypeVar("_S") _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: ... @@ -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..7297626ac8b3 100644 --- a/stdlib/@python2/_winreg.pyi +++ b/stdlib/@python2/_winreg.pyi @@ -1,12 +1,12 @@ from types import TracebackType -from typing import Any, Optional, Tuple, Type, Union +from typing import Any, Tuple, Type, Union _KeyType = Union[HKEYType, int] def CloseKey(__hkey: _KeyType) -> None: ... -def ConnectRegistry(__computer_name: Optional[str], __key: _KeyType) -> HKEYType: ... -def CreateKey(__key: _KeyType, __sub_key: Optional[str]) -> HKEYType: ... -def CreateKeyEx(key: _KeyType, sub_key: Optional[str], reserved: int = ..., access: int = ...) -> HKEYType: ... +def ConnectRegistry(__computer_name: str | None, __key: _KeyType) -> HKEYType: ... +def CreateKey(__key: _KeyType, __sub_key: str | None) -> HKEYType: ... +def CreateKeyEx(key: _KeyType, sub_key: str | None, reserved: int = ..., access: int = ...) -> HKEYType: ... def DeleteKey(__key: _KeyType, __sub_key: str) -> None: ... def DeleteKeyEx(key: _KeyType, sub_key: str, access: int = ..., reserved: int = ...) -> None: ... def DeleteValue(__key: _KeyType, __value: str) -> None: ... @@ -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: Union[str, int] + __key: _KeyType, __value_name: str | None, __reserved: Any, __type: int, __value: str | int ) -> None: ... # reserved is ignored def DisableReflectionKey(__key: _KeyType) -> None: ... def EnableReflectionKey(__key: _KeyType) -> None: ... @@ -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: 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 4349b11c1f1c..42f20b7466a1 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): ... @@ -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: ... @@ -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 a3b5528c4a31..4d77f6582c5f 100644 --- a/stdlib/@python2/argparse.pyi +++ b/stdlib/@python2/argparse.pyi @@ -7,7 +7,6 @@ from typing import ( Iterable, List, NoReturn, - Optional, Pattern, Protocol, Sequence, @@ -34,9 +33,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 +44,7 @@ class _AttributeHolder: # undocumented class _ActionsContainer: - description: Optional[_Text] + description: _Text | None prefix_chars: _Text argument_default: Any conflict_handler: _Text @@ -58,9 +57,7 @@ class _ActionsContainer: _defaults: Dict[str, Any] _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 - ) -> 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: ... @@ -68,16 +65,16 @@ class _ActionsContainer: def add_argument( self, *name_or_flags: Text, - action: Union[Text, Type[Action]] = ..., - nargs: Union[int, Text] = ..., + action: Text | Type[Action] = ..., + nargs: int | Text = ..., const: Any = ..., default: Any = ..., - type: Union[Callable[[Text], _T], Callable[[str], _T], FileType] = ..., + type: Callable[[Text], _T] | Callable[[str], _T] | FileType = ..., choices: Iterable[_T] = ..., required: bool = ..., - help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., - dest: Optional[Text] = ..., + help: Text | None = ..., + metavar: Text | Tuple[Text, ...] | None = ..., + dest: Text | None = ..., version: Text = ..., **kwargs: Any, ) -> Action: ... @@ -88,7 +85,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: ... @@ -99,26 +96,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 = ..., @@ -126,11 +123,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 @@ -139,24 +136,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 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: Optional[Namespace] = ... + 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: 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,14 +162,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[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) -> 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 @@ -189,23 +186,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 +214,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,33 +225,29 @@ class ArgumentDefaultsHelpFormatter(HelpFormatter): ... class Action(_AttributeHolder): option_strings: Sequence[_Text] dest: _Text - nargs: Optional[Union[int, _Text]] + nargs: int | _Text | None const: Any default: Any - type: Union[Callable[[str], Any], FileType, None] - choices: Optional[Iterable[Any]] + type: Callable[[str], Any] | FileType | None + choices: Iterable[Any] | None required: bool - help: Optional[_Text] - metavar: Optional[Union[_Text, Tuple[_Text, ...]]] + help: _Text | None + metavar: _Text | Tuple[_Text, ...] | None def __init__( self, option_strings: Sequence[Text], dest: Text, - nargs: Optional[Union[int, Text]] = ..., - const: Optional[_T] = ..., - default: Union[_T, str, None] = ..., - type: Optional[Union[Callable[[Text], _T], Callable[[str], _T], FileType]] = ..., - choices: Optional[Iterable[_T]] = ..., + nargs: int | Text | None = ..., + const: _T | None = ..., + default: _T | str | None = ..., + type: Callable[[Text], _T] | Callable[[str], _T] | FileType | None = ..., + choices: Iterable[_T] | None = ..., required: bool = ..., - help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., + help: Text | None = ..., + metavar: Text | Tuple[Text, ...] | None = ..., ) -> None: ... def __call__( - self, - parser: ArgumentParser, - namespace: Namespace, - values: Union[Text, Sequence[Any], None], - option_string: Optional[Text] = ..., + self, parser: ArgumentParser, namespace: Namespace, values: Text | Sequence[Any] | None, option_string: Text | None = ... ) -> None: ... class Namespace(_AttributeHolder): @@ -267,15 +260,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 +289,20 @@ class _StoreConstAction(Action): const: Any, default: Any = ..., required: bool = ..., - help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., + help: Text | None = ..., + metavar: Text | Tuple[Text, ...] | None = ..., ) -> 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,32 +317,27 @@ class _AppendConstAction(Action): const: Any, default: Any = ..., required: bool = ..., - help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., + help: Text | None = ..., + metavar: Text | Tuple[Text, ...] | None = ..., ) -> 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] = ..., - dest: Text = ..., - default: Text = ..., - help: Text = ..., + self, option_strings: Sequence[Text], version: Text | None = ..., dest: Text = ..., default: Text = ..., help: Text = ... ) -> None: ... # undocumented @@ -366,8 +354,8 @@ class _SubParsersAction(Action): prog: Text, parser_class: Type[ArgumentParser], dest: Text = ..., - help: Optional[Text] = ..., - metavar: Optional[Union[Text, Tuple[Text, ...]]] = ..., + help: Text | None = ..., + metavar: Text | Tuple[Text, ...] | None = ..., ) -> None: ... # TODO: Type keyword args properly. def add_parser(self, name: Text, **kwargs: Any) -> ArgumentParser: ... @@ -380,4 +368,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/array.pyi b/stdlib/@python2/array.pyi index a93742f85412..39670fe734fc 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: ... @@ -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..ec370e1a6c08 100644 --- a/stdlib/@python2/ast.pyi +++ b/stdlib/@python2/ast.pyi @@ -4,12 +4,12 @@ # 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 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: ... @@ -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: @@ -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 464eb42bad52..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 Optional, Sequence, Tuple, Union +from typing import Sequence, Tuple class simple_producer: def __init__(self, data: bytes, buffer_size: int = ...) -> None: ... @@ -10,13 +10,13 @@ class simple_producer: class async_chat(asyncore.dispatcher): ac_in_buffer_size: int ac_out_buffer_size: int - def __init__(self, sock: Optional[socket.socket] = ..., map: Optional[asyncore._maptype] = ...) -> None: ... + def __init__(self, sock: socket.socket | None = ..., map: asyncore._maptype | None = ...) -> None: ... @abstractmethod def collect_incoming_data(self, data: bytes) -> None: ... @abstractmethod def found_terminator(self) -> None: ... - def set_terminator(self, term: Union[bytes, int, None]) -> None: ... - def get_terminator(self) -> Union[bytes, int, None]: ... + def set_terminator(self, term: bytes | int | None) -> None: ... + def get_terminator(self) -> bytes | int | None: ... def handle_read(self) -> None: ... def handle_write(self) -> None: ... def handle_close(self) -> None: ... @@ -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 5183e3471e85..95acf9b706d3 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, Optional, Tuple, overload # cyclic dependence with asynchat _maptype = Dict[int, Any] @@ -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,19 +30,19 @@ 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: ... def listen(self, num: int) -> None: ... - def bind(self, addr: Union[Tuple[Any, ...], str]) -> None: ... - def connect(self, address: Union[Tuple[Any, ...], str]) -> None: ... - def accept(self) -> Optional[Tuple[SocketType, Any]]: ... + def bind(self, addr: Tuple[Any, ...] | str) -> None: ... + def connect(self, address: Tuple[Any, ...] | str) -> None: ... + def accept(self) -> Tuple[SocketType, Any] | None: ... def send(self, data: bytes) -> int: ... def recv(self, buffer_size: int) -> bytes: ... def close(self) -> None: ... @@ -83,21 +83,21 @@ 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: 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): - 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 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..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], ...]] @@ -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 05c3ec319f38..00856aafddbe 100644 --- a/stdlib/@python2/base64.pyi +++ b/stdlib/@python2/base64.pyi @@ -1,16 +1,16 @@ -from typing import IO, Optional, Union +from typing import IO, Union _encodable = Union[bytes, unicode] _decodable = Union[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 9d76b3afde22..5bee9dadb928 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 _T = TypeVar("_T") _TraceDispatch = Callable[[FrameType, str, Any], Any] # TODO: Recursive type @@ -11,16 +11,16 @@ class BdbQuit(Exception): ... class Bdb: - skip: Optional[Set[str]] + skip: Set[str] | None breaks: Dict[str, List[int]] fncache: Dict[str, str] - frame_returning: Optional[FrameType] - botframe: Optional[FrameType] + frame_returning: FrameType | None + botframe: FrameType | None quitting: bool - stopframe: Optional[FrameType] - returnframe: Optional[FrameType] + stopframe: FrameType | None + returnframe: FrameType | None stoplineno: int - def __init__(self, skip: Optional[Iterable[str]] = ...) -> None: ... + def __init__(self, skip: Iterable[str] | None = ...) -> None: ... def canonic(self, filename: str) -> str: ... def reset(self) -> None: ... def trace_dispatch(self, frame: FrameType, event: str, arg: Any) -> _TraceDispatch: ... @@ -31,21 +31,21 @@ class Bdb: def is_skipped_module(self, module_name: str) -> bool: ... def stop_here(self, frame: FrameType) -> bool: ... def break_here(self, frame: FrameType) -> bool: ... - def do_clear(self, arg: Any) -> Optional[bool]: ... + def do_clear(self, arg: Any) -> bool | None: ... def break_anywhere(self, frame: FrameType) -> bool: ... def user_call(self, frame: FrameType, argument_list: None) -> None: ... def user_line(self, frame: FrameType) -> None: ... def user_return(self, frame: FrameType, return_value: Any) -> None: ... def user_exception(self, frame: FrameType, exc_info: _ExcInfo) -> None: ... - def set_until(self, frame: FrameType, lineno: Optional[int] = ...) -> None: ... + def set_until(self, frame: FrameType, lineno: int | None = ...) -> None: ... def set_step(self) -> None: ... def set_next(self, frame: FrameType) -> None: ... def set_return(self, frame: FrameType) -> None: ... - def set_trace(self, frame: Optional[FrameType] = ...) -> None: ... + def set_trace(self, frame: FrameType | None = ...) -> None: ... def set_continue(self) -> None: ... def set_quit(self) -> None: ... def set_break( - self, filename: str, lineno: int, temporary: bool = ..., cond: Optional[str] = ..., funcname: Optional[str] = ... + self, filename: str, lineno: int, temporary: bool = ..., cond: str | None = ..., funcname: str | None = ... ) -> None: ... def clear_break(self, filename: str, lineno: int) -> None: ... def clear_bpbynumber(self, arg: SupportsInt) -> None: ... @@ -56,43 +56,39 @@ class Bdb: def get_breaks(self, filename: str, lineno: int) -> List[Breakpoint]: ... def get_file_breaks(self, filename: str) -> List[Breakpoint]: ... def get_all_breaks(self) -> List[Breakpoint]: ... - def get_stack(self, f: Optional[FrameType], t: Optional[TracebackType]) -> Tuple[List[Tuple[FrameType, int]], int]: ... + def get_stack(self, f: FrameType | None, t: TracebackType | None) -> Tuple[List[Tuple[FrameType, int]], int]: ... def format_stack_entry(self, frame_lineno: int, lprefix: str = ...) -> str: ... - def run( - self, cmd: Union[str, CodeType], globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ... - ) -> 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]] - ) -> None: ... - def runcall(self, __func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ... + 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 runcall(self, __func: Callable[..., _T], *args: Any, **kwds: Any) -> _T | None: ... class Breakpoint: next: int = ... bplist: Dict[Tuple[str, int], List[Breakpoint]] = ... - bpbynumber: List[Optional[Breakpoint]] = ... + bpbynumber: List[Breakpoint | None] = ... - funcname: Optional[str] - func_first_executable_line: Optional[int] + funcname: str | None + func_first_executable_line: int | None file: str line: int temporary: bool - cond: Optional[str] + cond: str | None enabled: bool ignore: int hits: int number: int def __init__( - self, file: str, line: int, temporary: bool = ..., cond: Optional[str] = ..., funcname: Optional[str] = ... + self, file: str, line: int, temporary: bool = ..., cond: str | None = ..., funcname: str | None = ... ) -> None: ... def deleteMe(self) -> None: ... def enable(self) -> None: ... def disable(self) -> None: ... - def bpprint(self, out: Optional[IO[str]] = ...) -> None: ... + def bpprint(self, out: IO[str] | None = ...) -> None: ... def bpformat(self) -> str: ... def __str__(self) -> str: ... def checkfuncname(b: Breakpoint, frame: FrameType) -> bool: ... -def effective(file: str, line: int, frame: FrameType) -> Union[Tuple[Breakpoint, bool], Tuple[None, None]]: ... +def effective(file: str, line: int, frame: FrameType) -> Tuple[Breakpoint, bool] | Tuple[None, None]: ... def set_trace() -> None: ... diff --git a/stdlib/@python2/builtins.pyi b/stdlib/@python2/builtins.pyi index 0b2c89e8d80c..ebe9cdd95038 100644 --- a/stdlib/@python2/builtins.pyi +++ b/stdlib/@python2/builtins.pyi @@ -26,7 +26,6 @@ from typing import ( MutableSequence, MutableSet, NoReturn, - Optional, Protocol, Reversible, Sequence, @@ -40,7 +39,6 @@ from typing import ( Tuple, Type, TypeVar, - Union, ValuesView, overload, ) @@ -66,9 +64,9 @@ _TT = TypeVar("_TT", bound="type") _TBE = TypeVar("_TBE", bound="BaseException") class object: - __doc__: Optional[str] + __doc__: str | None __dict__: Dict[str, Any] - __slots__: Union[Text, Iterable[Text]] + __slots__: Text | Iterable[Text] __module__: str @property def __class__(self: _T) -> Type[_T]: ... @@ -86,20 +84,20 @@ 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] 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 @@ -137,9 +135,9 @@ class super(object): class int: @overload - def __new__(cls: Type[_T], x: Union[Text, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc] = ...) -> _T: ... + def __new__(cls: Type[_T], x: 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 @@ -167,10 +165,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: ... @@ -201,7 +199,7 @@ class int: def __index__(self) -> int: ... class float: - def __new__(cls: Type[_T], x: Union[SupportsFloat, _SupportsIndex, Text, bytes, bytearray] = ...) -> _T: ... + def __new__(cls: Type[_T], x: SupportsFloat | _SupportsIndex | Text | bytes | bytearray = ...) -> _T: ... def as_integer_ratio(self) -> Tuple[int, int]: ... def hex(self) -> str: ... def is_integer(self) -> bool: ... @@ -253,7 +251,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 @@ -295,9 +293,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: Union[unicode, Tuple[unicode, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... - ) -> 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: ... @@ -323,17 +319,15 @@ 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: Union[unicode, Tuple[unicode, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... - ) -> 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: ... - 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 @@ -353,7 +347,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: ... @@ -369,17 +363,15 @@ 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: Union[Text, Tuple[Text, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... - ) -> 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: 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 +393,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 +403,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,28 +411,26 @@ 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: Union[Text, Tuple[Text, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... - ) -> bool: ... + def startswith(self, __prefix: Text | Tuple[Text, ...], __start: int | None = ..., __end: int | None = ...) -> bool: ... @overload def strip(self, __chars: str = ...) -> str: ... @overload 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: ... # 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]: ... @@ -475,11 +465,9 @@ 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: Union[bytes, Tuple[bytes, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... - ) -> 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: 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: ... @@ -493,21 +481,19 @@ 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: Union[bytes, Tuple[bytes, ...]], __start: Optional[int] = ..., __end: Optional[int] = ... - ) -> bool: ... - def strip(self, __bytes: Optional[bytes] = ...) -> bytearray: ... + 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: ... def translate(self, __table: str) -> bytearray: ... @@ -529,15 +515,15 @@ 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 __delitem__(self, i: Union[int, slice]) -> 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: ... # 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: ... @@ -548,9 +534,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: ... @@ -662,7 +648,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,18 +729,18 @@ 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]: ... + 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 __xor__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... - def __ixor__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ... + def __isub__(self, s: AbstractSet[_T | None]) -> Set[_T]: ... + def __xor__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... + def __ixor__(self, s: AbstractSet[_S]) -> Set[_T | _S]: ... def __le__(self, s: AbstractSet[object]) -> bool: ... def __lt__(self, s: AbstractSet[object]) -> bool: ... def __ge__(self, s: AbstractSet[object]) -> bool: ... @@ -776,9 +762,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: ... @@ -802,15 +788,15 @@ class xrange(Sized, Iterable[int], Reversible[int]): class property(object): def __init__( self, - fget: Optional[Callable[[Any], Any]] = ..., - fset: Optional[Callable[[Any, Any], None]] = ..., - fdel: Optional[Callable[[Any], None]] = ..., - doc: Optional[str] = ..., + fget: Callable[[Any], Any] | None = ..., + fset: Callable[[Any, Any], None] | None = ..., + fdel: Callable[[Any], None] | None = ..., + doc: str | None = ..., ) -> None: ... def getter(self, fget: Callable[[Any], Any]) -> property: ... def setter(self, fset: Callable[[Any, Any], None]) -> property: ... def deleter(self, fdel: Callable[[Any], None]) -> property: ... - def __get__(self, obj: Any, type: Optional[type] = ...) -> Any: ... + def __get__(self, obj: Any, type: type | None = ...) -> Any: ... def __set__(self, obj: Any, value: Any) -> None: ... def __delete__(self, obj: Any) -> None: ... def fget(self) -> Any: ... @@ -829,8 +815,8 @@ 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 bin(__number: Union[int, _SupportsIndex]) -> str: ... +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: ... def cmp(__x: Any, __y: Any) -> int: ... @@ -838,7 +824,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]: ... @@ -846,18 +832,18 @@ _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: 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 @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,26 +853,26 @@ 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) -> 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: ... @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[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... -def issubclass(__cls: type, __class_or_tuple: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... +def isinstance(__obj: object, __class_or_tuple: type | Tuple[type | Tuple[Any, ...], ...]) -> bool: ... +def issubclass(__cls: type, __class_or_tuple: type | Tuple[type | Tuple[Any, ...], ...]) -> bool: ... def len(__obj: Sized) -> int: ... def locals() -> Dict[str, Any]: ... @overload @@ -966,15 +952,13 @@ 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( - *values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[SupportsWrite[Any]] = ... -) -> 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) @@ -1018,12 +1002,12 @@ def round(number: SupportsFloat) -> float: ... def round(number: SupportsFloat, ndigits: int) -> float: ... def setattr(__obj: Any, __name: Text, __value: Any) -> None: ... def sorted( - __iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Optional[Callable[[_T], Any]] = ..., reverse: bool = ... + __iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Callable[[_T], Any] | None = ..., 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 @@ -1052,8 +1036,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: ... @@ -1071,7 +1055,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: ... @@ -1119,10 +1103,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): ... @@ -1181,9 +1165,7 @@ class file(BinaryIO): def next(self) -> str: ... def read(self, n: int = ...) -> str: ... def __enter__(self) -> BinaryIO: ... - def __exit__( - self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ... - ) -> Optional[bool]: ... + 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: ... @@ -1197,4 +1179,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 d3c0baded59a..81ee6f6ce26a 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 = Union[Text, IO[bytes]] @@ -11,10 +11,8 @@ 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 = ... - ) -> None: ... - def read(self, size: Optional[int] = ...) -> bytes: ... + 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 def readinto(self, b: WriteableBuffer) -> int: ... diff --git a/stdlib/@python2/cProfile.pyi b/stdlib/@python2/cProfile.pyi index 0cc2e94986fc..1257b0cc92eb 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 +from typing import Any, Callable, Dict, Text, Tuple, TypeVar -def run(statement: str, filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ... +def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( - statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: Optional[str] = ..., sort: Union[str, int] = ... + statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: str | None = ..., sort: str | int = ... ) -> None: ... _SelfT = TypeVar("_SelfT", bound=Profile) @@ -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..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, Optional, 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. @@ -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,12 +34,12 @@ 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: ... - 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/calendar.pyi b/stdlib/@python2/calendar.pyi index 1a8cb1657f1b..ce765210dc1e 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, Optional, Sequence, Tuple _LocaleType = Tuple[Optional[str], Optional[str]] @@ -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: ... @@ -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/cgi.pyi b/stdlib/@python2/cgi.pyi index c3519bba9b20..674748242ebb 100644 --- a/stdlib/@python2/cgi.pyi +++ b/stdlib/@python2/cgi.pyi @@ -1,12 +1,12 @@ 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 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] @@ -43,28 +43,28 @@ 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] - file: Optional[IO[bytes]] + filename: str | None + file: IO[bytes] | None type: str type_options: dict[str, str] innerboundary: bytes length: int done: int - list: Optional[List[Any]] - value: Union[None, bytes, List[Any]] + list: List[Any] | None + value: None | bytes | List[Any] def __init__( self, fp: IO[Any] = ..., diff --git a/stdlib/@python2/cgitb.pyi b/stdlib/@python2/cgitb.pyi index 017840dc472c..daa0233ee69a 100644 --- a/stdlib/@python2/cgitb.pyi +++ b/stdlib/@python2/cgitb.pyi @@ -7,26 +7,19 @@ 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: ... class Hook: # undocumented def __init__( - self, - display: int = ..., - logdir: Optional[Text] = ..., - context: int = ..., - file: Optional[IO[str]] = ..., - format: str = ..., + self, display: int = ..., logdir: Text | None = ..., context: int = ..., file: IO[str] | None = ..., format: str = ... ) -> None: ... - def __call__( - self, etype: Optional[Type[BaseException]], evalue: Optional[BaseException], etb: Optional[TracebackType] - ) -> None: ... - def handle(self, info: Optional[_ExcInfo] = ...) -> 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: 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..ffccba84ec16 100644 --- a/stdlib/@python2/cmd.pyi +++ b/stdlib/@python2/cmd.pyi @@ -1,11 +1,11 @@ -from typing import IO, Any, Callable, List, Optional, Tuple +from typing import IO, Any, Callable, List, Tuple class Cmd: prompt: str identchars: str ruler: str lastcmd: str - intro: Optional[Any] + intro: Any | None doc_leader: str doc_header: str misc_header: str @@ -16,24 +16,24 @@ class Cmd: stdout: IO[str] cmdqueue: List[str] completekey: str - def __init__(self, completekey: str = ..., stdin: Optional[IO[str]] = ..., stdout: Optional[IO[str]] = ...) -> None: ... - old_completer: Optional[Callable[[str, int], Optional[str]]] - def cmdloop(self, intro: Optional[Any] = ...) -> None: ... + def __init__(self, completekey: str = ..., stdin: IO[str] | None = ..., stdout: IO[str] | None = ...) -> None: ... + old_completer: Callable[[str, int], str | None] | None + def cmdloop(self, intro: Any | None = ...) -> None: ... def precmd(self, line: str) -> str: ... def postcmd(self, stop: bool, line: str) -> bool: ... def preloop(self) -> None: ... def postloop(self) -> None: ... - def parseline(self, line: str) -> Tuple[Optional[str], Optional[str], str]: ... + def parseline(self, line: str) -> Tuple[str | None, str | None, str]: ... def onecmd(self, line: str) -> bool: ... def emptyline(self) -> bool: ... def default(self, line: str) -> bool: ... def completedefault(self, *ignored: Any) -> List[str]: ... def completenames(self, text: str, *ignored: Any) -> List[str]: ... - completion_matches: Optional[List[str]] - def complete(self, text: str, state: int) -> Optional[List[str]]: ... + completion_matches: List[str] | None + def complete(self, text: str, state: int) -> List[str] | None: ... def get_names(self) -> List[str]: ... # Only the first element of args matters. def complete_help(self, *args: Any) -> List[str]: ... - def do_help(self, arg: str) -> Optional[bool]: ... - def print_topics(self, header: str, cmds: Optional[List[str]], cmdlen: Any, maxcol: int) -> None: ... - def columnize(self, list: Optional[List[str]], displaywidth: int = ...) -> None: ... + def do_help(self, arg: str) -> bool | None: ... + def print_topics(self, header: str, cmds: List[str] | None, cmdlen: Any, maxcol: int) -> None: ... + def columnize(self, list: List[str] | None, displaywidth: int = ...) -> None: ... diff --git a/stdlib/@python2/code.pyi b/stdlib/@python2/code.pyi index ea882c9de68e..ae8dfc91a32b 100644 --- a/stdlib/@python2/code.pyi +++ b/stdlib/@python2/code.pyi @@ -1,22 +1,22 @@ from types import CodeType -from typing import Any, Callable, Mapping, Optional +from typing import Any, Callable, Mapping 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: 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 __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: Optional[str] = ..., readfunc: Optional[Callable[[str], str]] = ..., local: Optional[Mapping[str, Any]] = ... + banner: str | None = ..., readfunc: Callable[[str], str] | None = ..., local: Mapping[str, Any] | 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/@python2/codecs.pyi b/stdlib/@python2/codecs.pyi index 8bacab771b0d..a7835106336d 100644 --- a/stdlib/@python2/codecs.pyi +++ b/stdlib/@python2/codecs.pyi @@ -9,7 +9,6 @@ from typing import ( Iterable, Iterator, List, - Optional, Protocol, Text, TextIO, @@ -83,9 +82,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 +104,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,13 +119,11 @@ 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 = ... -) -> 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]: ... @@ -144,13 +141,13 @@ BOM_UTF32_LE: bytes # It is expected that different actions be taken depending on which of the # three subclasses of `UnicodeError` is actually ...ed. However, the Union # is still needed for at least one of the cases. -def register_error(__errors: str, __handler: Callable[[UnicodeError], Tuple[Union[str, bytes], int]]) -> None: ... -def lookup_error(__name: str) -> Callable[[UnicodeError], Tuple[Union[str, bytes], int]]: ... -def strict_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ... -def replace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ... -def ignore_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ... -def xmlcharrefreplace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ... -def backslashreplace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ... +def register_error(__errors: str, __handler: Callable[[UnicodeError], Tuple[str | bytes, int]]) -> None: ... +def lookup_error(__name: str) -> Callable[[UnicodeError], Tuple[str | bytes, int]]: ... +def strict_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ... +def replace_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ... +def ignore_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ... +def xmlcharrefreplace_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ... +def backslashreplace_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ... class Codec: # These are sort of @abstractmethod but sort of not. @@ -165,8 +162,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 @@ -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: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] - ) -> 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,13 +209,11 @@ 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] - ) -> 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: ... @@ -231,8 +224,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 @@ -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: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] - ) -> 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__. @@ -253,7 +244,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 +262,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: ... @@ -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: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] - ) -> 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: ... @@ -291,7 +280,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..8ed5710c9891 100644 --- a/stdlib/@python2/codeop.pyi +++ b/stdlib/@python2/codeop.pyi @@ -1,7 +1,6 @@ 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 +10,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 f6f75cb076c2..5a2f73aed7ce 100644 --- a/stdlib/@python2/collections.pyi +++ b/stdlib/@python2/collections.pyi @@ -16,14 +16,12 @@ from typing import ( MutableMapping as MutableMapping, MutableSequence as MutableSequence, MutableSet as MutableSet, - Optional, Reversible, Sequence as Sequence, Sized as Sized, Tuple, Type, TypeVar, - Union, ValuesView as ValuesView, overload, ) @@ -37,16 +35,13 @@ _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]]], - 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]): 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 +72,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 @@ -90,7 +85,7 @@ class Counter(Dict[_T, int], Generic[_T]): @overload def update(self, __m: Mapping[_T, int], **kwargs: int) -> None: ... @overload - def update(self, __m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: int) -> None: ... + def update(self, __m: Iterable[_T] | Iterable[Tuple[_T, int]], **kwargs: int) -> None: ... @overload def update(self, **kwargs: int) -> None: ... def __add__(self, other: Counter[_T]) -> Counter[_T]: ... @@ -112,18 +107,16 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]): @overload def __init__(self, **kwargs: _VT) -> None: ... @overload - def __init__(self, default_factory: Optional[Callable[[], _VT]]) -> None: ... + def __init__(self, default_factory: Callable[[], _VT] | None) -> None: ... @overload - def __init__(self, default_factory: Optional[Callable[[], _VT]], **kwargs: _VT) -> None: ... + def __init__(self, default_factory: Callable[[], _VT] | None, **kwargs: _VT) -> None: ... @overload - def __init__(self, default_factory: Optional[Callable[[], _VT]], map: Mapping[_KT, _VT]) -> None: ... + def __init__(self, default_factory: Callable[[], _VT] | None, map: Mapping[_KT, _VT]) -> None: ... @overload - def __init__(self, default_factory: Optional[Callable[[], _VT]], map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... + def __init__(self, default_factory: Callable[[], _VT] | None, map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... @overload - def __init__(self, default_factory: Optional[Callable[[], _VT]], iterable: Iterable[Tuple[_KT, _VT]]) -> None: ... + def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[Tuple[_KT, _VT]]) -> None: ... @overload - def __init__( - self, default_factory: Optional[Callable[[], _VT]], iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT - ) -> None: ... + def __init__(self, default_factory: Callable[[], _VT] | None, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... def __missing__(self, key: _KT) -> _VT: ... def copy(self: _S) -> _S: ... diff --git a/stdlib/@python2/compileall.pyi b/stdlib/@python2/compileall.pyi index 5ae1d6f7f7c1..ef22929c4c19 100644 --- a/stdlib/@python2/compileall.pyi +++ b/stdlib/@python2/compileall.pyi @@ -1,15 +1,10 @@ -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( - dir: Text, - maxlevels: int = ..., - ddir: Optional[Text] = ..., - force: bool = ..., - rx: Optional[Pattern[Any]] = ..., - quiet: int = ..., + dir: Text, maxlevels: int = ..., ddir: Text | None = ..., force: bool = ..., rx: Pattern[Any] | None = ..., 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: Pattern[Any] | None = ..., quiet: int = ... ) -> int: ... def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ...) -> int: ... diff --git a/stdlib/@python2/cookielib.pyi b/stdlib/@python2/cookielib.pyi index 7405ba91c0ff..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 @@ -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.pyi b/stdlib/@python2/copy.pyi index b51c79c66c6a..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") @@ -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/copy_reg.pyi b/stdlib/@python2/copy_reg.pyi index ea07ba410b6d..91b099888bab 100644 --- a/stdlib/@python2/copy_reg.pyi +++ b/stdlib/@python2/copy_reg.pyi @@ -7,8 +7,8 @@ __all__: List[str] def pickle( ob_type: _TypeT, - pickle_function: Callable[[_TypeT], Union[str, _Reduce[_TypeT]]], - constructor_ob: Optional[Callable[[_Reduce[_TypeT]], _TypeT]] = ..., + pickle_function: Callable[[_TypeT], str | _Reduce[_TypeT]], + constructor_ob: Callable[[_Reduce[_TypeT]], _TypeT] | None = ..., ) -> None: ... def constructor(object: Callable[[_Reduce[_TypeT]], _TypeT]) -> None: ... def add_extension(module: Hashable, name: Hashable, code: SupportsInt) -> None: ... diff --git a/stdlib/@python2/copyreg.pyi b/stdlib/@python2/copyreg.pyi index ea07ba410b6d..91b099888bab 100644 --- a/stdlib/@python2/copyreg.pyi +++ b/stdlib/@python2/copyreg.pyi @@ -7,8 +7,8 @@ __all__: List[str] def pickle( ob_type: _TypeT, - pickle_function: Callable[[_TypeT], Union[str, _Reduce[_TypeT]]], - constructor_ob: Optional[Callable[[_Reduce[_TypeT]], _TypeT]] = ..., + pickle_function: Callable[[_TypeT], str | _Reduce[_TypeT]], + constructor_ob: Callable[[_Reduce[_TypeT]], _TypeT] | None = ..., ) -> None: ... def constructor(object: Callable[[_Reduce[_TypeT]], _TypeT]) -> None: ... def add_extension(module: Hashable, name: Hashable, code: SupportsInt) -> None: ... diff --git a/stdlib/@python2/csv.pyi b/stdlib/@python2/csv.pyi index 944c04065ae0..886de6210ca9 100644 --- a/stdlib/@python2/csv.pyi +++ b/stdlib/@python2/csv.pyi @@ -24,7 +24,6 @@ from typing import ( Iterator, List, Mapping, - Optional, Sequence, Text, Type, @@ -46,9 +45,9 @@ class excel_tab(excel): delimiter: str class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): - fieldnames: Optional[Sequence[_T]] - restkey: Optional[str] - restval: Optional[str] + fieldnames: Sequence[_T] | None + restkey: str | None + restval: str | None reader: _reader dialect: _DialectLike line_num: int @@ -57,8 +56,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, @@ -67,9 +66,9 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): def __init__( self: DictReader[str], f: Iterable[Text], - fieldnames: Optional[Sequence[str]] = ..., - restkey: Optional[str] = ..., - restval: Optional[str] = ..., + fieldnames: Sequence[str] | None = ..., + restkey: str | None = ..., + restval: str | None = ..., dialect: _DialectLike = ..., *args: Any, **kwds: Any, @@ -79,14 +78,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 +98,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..149e9f281647 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: ... @@ -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 @@ -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: ... @@ -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: ... @@ -203,7 +203,7 @@ class c_char(_SimpleCData[bytes]): def __init__(self, value: _UnionT[int, bytes] = ...) -> None: ... class c_char_p(_PointerLike, _SimpleCData[Optional[bytes]]): - def __init__(self, value: Optional[_UnionT[int, bytes]] = ...) -> None: ... + 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[Optional[int]]): ... class c_wchar(_SimpleCData[Text]): ... class c_wchar_p(_PointerLike, _SimpleCData[Optional[Text]]): - 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/ctypes/util.pyi b/stdlib/@python2/ctypes/util.pyi index 20914c70a05c..c0274f5e539b 100644 --- a/stdlib/@python2/ctypes/util.pyi +++ b/stdlib/@python2/ctypes/util.pyi @@ -1,7 +1,6 @@ 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/curses/ascii.pyi b/stdlib/@python2/curses/ascii.pyi index 10bab853adcf..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) @@ -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..578a579fda38 100644 --- a/stdlib/@python2/curses/textpad.pyi +++ b/stdlib/@python2/curses/textpad.pyi @@ -1,11 +1,11 @@ from _curses import _CursesWindow -from typing import Callable, Optional, Union +from typing import Callable def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> None: ... class Textbox: stripspaces: bool def __init__(self, win: _CursesWindow, insert_mode: bool = ...) -> None: ... - def edit(self, validate: Optional[Callable[[int], int]] = ...) -> str: ... - def do_command(self, ch: Union[str, int]) -> None: ... + def edit(self, validate: Callable[[int], int] | None = ...) -> str: ... + def do_command(self, ch: str | int) -> None: ... def gather(self) -> str: ... diff --git a/stdlib/@python2/datetime.pyi b/stdlib/@python2/datetime.pyi index d1b0d6437825..8b19a3d316f2 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") @@ -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 @@ -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: Optional[_tzinfo] = ..., + cls: Type[_S], hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: _tzinfo | None = ... ) -> _S: ... @property def hour(self) -> int: ... @@ -76,7 +71,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 +80,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 +147,7 @@ class datetime(date): minute: int = ..., second: int = ..., microsecond: int = ..., - tzinfo: Optional[_tzinfo] = ..., + tzinfo: _tzinfo | None = ..., ) -> _S: ... @property def year(self) -> int: ... @@ -169,9 +164,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 +200,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 edce1ea02861..95f6d9cf0363 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 = Union[str, bytes] @@ -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: 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 0b8ee50a79b7..fb5e2da5fa2c 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 = Union[str, bytes] _ValueType = Union[str, bytes] @@ -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: 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 8f13a2988488..0e9339bf81f9 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 = Union[str, bytes] @@ -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,12 +20,12 @@ 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: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... @overload - def get(self, k: _KeyType) -> Optional[bytes]: ... + def get(self, k: _KeyType) -> bytes | None: ... @overload - def get(self, k: _KeyType, default: Union[bytes, _T]) -> Union[bytes, _T]: ... + def get(self, k: _KeyType, default: bytes | _T) -> bytes | _T: ... def keys(self) -> List[bytes]: ... def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ... # Don't exist at runtime diff --git a/stdlib/@python2/dbm/ndbm.pyi b/stdlib/@python2/dbm/ndbm.pyi index 020131543e13..28f4dd8e4e59 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 = Union[str, bytes] @@ -19,12 +19,12 @@ 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: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... @overload - def get(self, k: _KeyType) -> Optional[bytes]: ... + def get(self, k: _KeyType) -> bytes | None: ... @overload - def get(self, k: _KeyType, default: Union[bytes, _T]) -> Union[bytes, _T]: ... + def get(self, k: _KeyType, default: bytes | _T) -> bytes | _T: ... def keys(self) -> List[bytes]: ... def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ... # Don't exist at runtime diff --git a/stdlib/@python2/decimal.pyi b/stdlib/@python2/decimal.pyi index bee33d9c7af0..915bddadb584 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 = Union[Decimal, int] _DecimalNew = Union[Decimal, float, Text, Tuple[int, Sequence[int], int]] @@ -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: Type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... _TrapType = Type[DecimalException] @@ -161,15 +161,15 @@ class Context(object): flags: Dict[_TrapType, bool] def __init__( self, - prec: Optional[int] = ..., - rounding: Optional[str] = ..., - traps: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., - flags: Union[None, Dict[_TrapType, bool], Container[_TrapType]] = ..., - Emin: Optional[int] = ..., - Emax: Optional[int] = ..., - capitals: Optional[int] = ..., - _clamp: Optional[int] = ..., - _ignored_flags: Optional[List[_TrapType]] = ..., + prec: int | None = ..., + rounding: str | None = ..., + traps: None | Dict[_TrapType, bool] | Container[_TrapType] = ..., + flags: None | Dict[_TrapType, bool] | Container[_TrapType] = ..., + Emin: int | None = ..., + Emax: int | None = ..., + capitals: int | None = ..., + _clamp: int | None = ..., + _ignored_flags: List[_TrapType] | None = ..., ) -> None: ... def clear_flags(self) -> None: ... def copy(self) -> Context: ... @@ -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..41ffc6a286d1 100644 --- a/stdlib/@python2/difflib.pyi +++ b/stdlib/@python2/difflib.pyi @@ -7,7 +7,6 @@ from typing import ( Iterator, List, NamedTuple, - Optional, Sequence, Text, Tuple, @@ -30,7 +29,7 @@ class Match(NamedTuple): class SequenceMatcher(Generic[_T]): def __init__( - self, isjunk: Optional[Callable[[_T], bool]] = ..., a: Sequence[_T] = ..., b: Sequence[_T] = ..., autojunk: bool = ... + self, isjunk: Callable[[_T], bool] | None = ..., a: Sequence[_T] = ..., b: Sequence[_T] = ..., autojunk: bool = ... ) -> None: ... def set_seqs(self, a: Sequence[_T], b: Sequence[_T]) -> None: ... def set_seq1(self, a: Sequence[_T]) -> None: ... @@ -54,7 +53,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 +79,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/dircache.pyi b/stdlib/@python2/dircache.pyi index fd906f6f2ae1..366909d87133 100644 --- a/stdlib/@python2/dircache.pyi +++ b/stdlib/@python2/dircache.pyi @@ -1,8 +1,8 @@ -from typing import List, MutableSequence, Text, Union +from typing import List, MutableSequence, Text def reset() -> None: ... 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: MutableSequence[str] | MutableSequence[Text] | MutableSequence[str | Text]) -> None: ... diff --git a/stdlib/@python2/distutils/archive_util.pyi b/stdlib/@python2/distutils/archive_util.pyi index 0e94d3818ae4..dd2cbda73fc6 100644 --- a/stdlib/@python2/distutils/archive_util.pyi +++ b/stdlib/@python2/distutils/archive_util.pyi @@ -1,12 +1,5 @@ -from typing import Optional - def make_archive( - base_name: str, - format: str, - root_dir: Optional[str] = ..., - base_dir: Optional[str] = ..., - 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: 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 831311d2cb52..b0539bf9e5dc 100644 --- a/stdlib/@python2/distutils/ccompiler.pyi +++ b/stdlib/@python2/distutils/ccompiler.pyi @@ -6,9 +6,9 @@ def gen_lib_options( compiler: CCompiler, library_dirs: List[str], runtime_library_dirs: List[str], libraries: List[str] ) -> List[str]: ... def gen_preprocess_options(macros: List[_Macro], include_dirs: List[str]) -> List[str]: ... -def get_default_compiler(osname: Optional[str] = ..., platform: Optional[str] = ...) -> str: ... +def get_default_compiler(osname: str | None = ..., platform: str | None = ...) -> str: ... def new_compiler( - plat: Optional[str] = ..., compiler: Optional[str] = ..., verbose: int = ..., dry_run: int = ..., force: int = ... + plat: str | None = ..., compiler: str | None = ..., verbose: int = ..., dry_run: int = ..., force: int = ... ) -> CCompiler: ... def show_compilers() -> None: ... @@ -16,7 +16,7 @@ class CCompiler: dry_run: bool force: bool verbose: bool - output_dir: Optional[str] + output_dir: str | None macros: List[_Macro] include_dirs: List[str] libraries: List[str] @@ -32,19 +32,19 @@ class CCompiler: def set_library_dirs(self, dirs: List[str]) -> None: ... def add_runtime_library_dir(self, dir: str) -> None: ... def set_runtime_library_dirs(self, dirs: List[str]) -> None: ... - def define_macro(self, name: str, value: Optional[str] = ...) -> None: ... + def define_macro(self, name: str, value: str | None = ...) -> None: ... def undefine_macro(self, name: str) -> None: ... def add_link_object(self, object: str) -> None: ... def set_link_objects(self, objects: List[str]) -> None: ... - def detect_language(self, sources: Union[str, List[str]]) -> Optional[str]: ... - def find_library_file(self, dirs: List[str], lib: str, debug: bool = ...) -> Optional[str]: ... + def detect_language(self, sources: str | List[str]) -> str | None: ... + def find_library_file(self, dirs: List[str], lib: str, debug: bool = ...) -> str | None: ... def has_function( self, funcname: str, - includes: Optional[List[str]] = ..., - include_dirs: Optional[List[str]] = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., + includes: List[str] | None = ..., + include_dirs: List[str] | None = ..., + libraries: List[str] | None = ..., + library_dirs: List[str] | None = ..., ) -> bool: ... def library_dir_option(self, dir: str) -> str: ... def library_option(self, lib: str) -> str: ... @@ -53,95 +53,95 @@ class CCompiler: def compile( self, sources: List[str], - output_dir: Optional[str] = ..., - macros: Optional[_Macro] = ..., - include_dirs: Optional[List[str]] = ..., + output_dir: str | None = ..., + macros: _Macro | None = ..., + include_dirs: List[str] | None = ..., debug: bool = ..., - extra_preargs: Optional[List[str]] = ..., - extra_postargs: Optional[List[str]] = ..., - depends: Optional[List[str]] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., + depends: List[str] | None = ..., ) -> List[str]: ... def create_static_lib( self, objects: List[str], output_libname: str, - output_dir: Optional[str] = ..., + output_dir: str | None = ..., debug: bool = ..., - target_lang: Optional[str] = ..., + target_lang: str | None = ..., ) -> None: ... def link( self, target_desc: str, objects: List[str], output_filename: str, - output_dir: Optional[str] = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., - export_symbols: Optional[List[str]] = ..., + output_dir: str | None = ..., + libraries: List[str] | None = ..., + library_dirs: List[str] | None = ..., + runtime_library_dirs: List[str] | None = ..., + export_symbols: List[str] | None = ..., debug: bool = ..., - extra_preargs: Optional[List[str]] = ..., - extra_postargs: Optional[List[str]] = ..., - build_temp: Optional[str] = ..., - target_lang: Optional[str] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., + build_temp: str | None = ..., + target_lang: str | None = ..., ) -> None: ... def link_executable( self, objects: List[str], output_progname: str, - output_dir: Optional[str] = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., + output_dir: str | None = ..., + libraries: List[str] | None = ..., + library_dirs: List[str] | None = ..., + runtime_library_dirs: List[str] | None = ..., debug: bool = ..., - extra_preargs: Optional[List[str]] = ..., - extra_postargs: Optional[List[str]] = ..., - target_lang: Optional[str] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., + target_lang: str | None = ..., ) -> None: ... def link_shared_lib( self, objects: List[str], output_libname: str, - output_dir: Optional[str] = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., - export_symbols: Optional[List[str]] = ..., + output_dir: str | None = ..., + libraries: List[str] | None = ..., + library_dirs: List[str] | None = ..., + runtime_library_dirs: List[str] | None = ..., + export_symbols: List[str] | None = ..., debug: bool = ..., - extra_preargs: Optional[List[str]] = ..., - extra_postargs: Optional[List[str]] = ..., - build_temp: Optional[str] = ..., - target_lang: Optional[str] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., + build_temp: str | None = ..., + target_lang: str | None = ..., ) -> None: ... def link_shared_object( self, objects: List[str], output_filename: str, - output_dir: Optional[str] = ..., - libraries: Optional[List[str]] = ..., - library_dirs: Optional[List[str]] = ..., - runtime_library_dirs: Optional[List[str]] = ..., - export_symbols: Optional[List[str]] = ..., + output_dir: str | None = ..., + libraries: List[str] | None = ..., + library_dirs: List[str] | None = ..., + runtime_library_dirs: List[str] | None = ..., + export_symbols: List[str] | None = ..., debug: bool = ..., - extra_preargs: Optional[List[str]] = ..., - extra_postargs: Optional[List[str]] = ..., - build_temp: Optional[str] = ..., - target_lang: Optional[str] = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., + build_temp: str | None = ..., + target_lang: str | None = ..., ) -> None: ... def preprocess( self, source: str, - output_file: Optional[str] = ..., - macros: Optional[List[_Macro]] = ..., - include_dirs: Optional[List[str]] = ..., - extra_preargs: Optional[List[str]] = ..., - extra_postargs: Optional[List[str]] = ..., + output_file: str | None = ..., + macros: List[_Macro] | None = ..., + include_dirs: List[str] | None = ..., + extra_preargs: List[str] | None = ..., + extra_postargs: List[str] | None = ..., ) -> None: ... def executable_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ... def library_filename(self, libname: str, lib_type: str = ..., strip_dir: int = ..., output_dir: str = ...) -> str: ... def object_filenames(self, source_filenames: List[str], strip_dir: int = ..., output_dir: str = ...) -> List[str]: ... def shared_object_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ... - def execute(self, func: Callable[..., None], args: Tuple[Any, ...], msg: Optional[str] = ..., level: int = ...) -> None: ... + def execute(self, func: Callable[..., None], args: Tuple[Any, ...], msg: str | None = ..., level: int = ...) -> None: ... def spawn(self, cmd: List[str]) -> None: ... def mkpath(self, name: str, mode: int = ...) -> None: ... def move_file(self, src: str, dst: str) -> str: ... diff --git a/stdlib/@python2/distutils/cmd.pyi b/stdlib/@python2/distutils/cmd.pyi index b888c189f932..d4e90bf69970 100644 --- a/stdlib/@python2/distutils/cmd.pyi +++ b/stdlib/@python2/distutils/cmd.pyi @@ -1,9 +1,9 @@ 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, Text, Tuple class Command: - sub_commands: List[Tuple[str, Optional[Callable[[Command], bool]]]] + sub_commands: List[Tuple[str, Callable[[Command], bool] | None]] def __init__(self, dist: Distribution) -> None: ... @abstractmethod def initialize_options(self) -> None: ... @@ -13,18 +13,18 @@ class Command: def run(self) -> None: ... def announce(self, msg: 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(self, option: str, default: str | None = ...) -> None: ... + def ensure_string_list(self, option: str | List[str]) -> None: ... def ensure_filename(self, option: str) -> None: ... def ensure_dirname(self, option: str) -> None: ... def get_command_name(self) -> str: ... def set_undefined_options(self, src_cmd: 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: ... - 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,18 +50,18 @@ class Command: self, base_name: str, format: str, - root_dir: Optional[str] = ..., - base_dir: Optional[str] = ..., - owner: Optional[str] = ..., - group: Optional[str] = ..., + root_dir: str | None = ..., + base_dir: str | None = ..., + owner: str | None = ..., + group: str | None = ..., ) -> str: ... def make_file( self, - infiles: Union[str, List[str], Tuple[str]], + infiles: str | List[str] | Tuple[str], outfile: str, func: Callable[..., Any], args: List[Any], - exec_msg: Optional[str] = ..., - skip_msg: Optional[str] = ..., + exec_msg: str | None = ..., + skip_msg: str | None = ..., level: Any = ..., ) -> None: ... # level is not used diff --git a/stdlib/@python2/distutils/command/config.pyi b/stdlib/@python2/distutils/command/config.pyi index 6b57a64b48b1..d0fd762e83b2 100644 --- a/stdlib/@python2/distutils/command/config.pyi +++ b/stdlib/@python2/distutils/command/config.pyi @@ -3,19 +3,19 @@ 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 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[Union[str, CCompiler]] = ... - cc: Optional[str] = ... - include_dirs: Optional[Sequence[str]] = ... - libraries: Optional[Sequence[str]] = ... - library_dirs: Optional[Sequence[str]] = ... + user_options: Sequence[Tuple[str, str | None, str]] = ... + compiler: str | CCompiler | None = ... + cc: str | None = ... + include_dirs: Sequence[str] | None = ... + libraries: Sequence[str] | None = ... + library_dirs: Sequence[str] | None = ... noisy: int = ... dump_source: int = ... temp_files: Sequence[str] = ... @@ -24,64 +24,60 @@ class config(Command): def run(self) -> None: ... def try_cpp( self, - body: Optional[str] = ..., - headers: Optional[Sequence[str]] = ..., - include_dirs: Optional[Sequence[str]] = ..., + body: str | None = ..., + headers: Sequence[str] | None = ..., + include_dirs: Sequence[str] | None = ..., lang: str = ..., ) -> bool: ... def search_cpp( self, - pattern: Union[Pattern[str], str], - body: Optional[str] = ..., - headers: Optional[Sequence[str]] = ..., - include_dirs: Optional[Sequence[str]] = ..., + pattern: Pattern[str] | str, + body: str | None = ..., + 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]] = ..., - lang: str = ..., + self, header: str, include_dirs: Sequence[str] | None = ..., library_dirs: Sequence[str] | None = ..., 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..2824236735f0 100644 --- a/stdlib/@python2/distutils/command/install.pyi +++ b/stdlib/@python2/distutils/command/install.pyi @@ -1,12 +1,12 @@ from distutils.cmd import Command -from typing import Optional, Text +from typing import 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..bf3d0737f244 100644 --- a/stdlib/@python2/distutils/command/install_egg_info.pyi +++ b/stdlib/@python2/distutils/command/install_egg_info.pyi @@ -1,9 +1,9 @@ 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] - 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/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 e60507e0b65a..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 @@ -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/core.pyi b/stdlib/@python2/distutils/core.pyi index 9a3fa70fd381..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, Optional, Tuple, Type, Union +from typing import Any, List, Mapping, Tuple, Type def setup( *, @@ -25,8 +25,8 @@ def setup( script_args: List[str] = ..., options: Mapping[str, Any] = ..., license: str = ..., - keywords: Union[List[str], str] = ..., - platforms: Union[List[str], str] = ..., + keywords: List[str] | str = ..., + platforms: List[str] | str = ..., cmdclass: Mapping[str, Type[Command]] = ..., data_files: List[Tuple[str, List[str]]] = ..., package_dir: Mapping[str, str] = ..., @@ -45,4 +45,4 @@ def setup( fullname: str = ..., **attrs: Any, ) -> None: ... -def run_setup(script_name: str, script_args: Optional[List[str]] = ..., stop_after: str = ...) -> Distribution: ... +def run_setup(script_name: str, script_args: List[str] | None = ..., stop_after: str = ...) -> Distribution: ... diff --git a/stdlib/@python2/distutils/dist.pyi b/stdlib/@python2/distutils/dist.pyi index 685423bda6da..adba8f093569 100644 --- a/stdlib/@python2/distutils/dist.pyi +++ b/stdlib/@python2/distutils/dist.pyi @@ -1,9 +1,9 @@ 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]] - 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 get_command_obj(self, command: str, create: bool = ...) -> Optional[Command]: ... + 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/extension.pyi b/stdlib/@python2/distutils/extension.pyi index 02c1f55617b3..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__( @@ -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 8eb4c416fa28..d0e3309c2d77 100644 --- a/stdlib/@python2/distutils/fancy_getopt.pyi +++ b/stdlib/@python2/distutils/fancy_getopt.pyi @@ -1,21 +1,21 @@ -from typing import Any, List, Mapping, Optional, Tuple, Union, overload +from typing import Any, List, Mapping, Optional, Tuple, overload _Option = Tuple[str, Optional[str], str] _GR = Tuple[List[str], OptionDummy] def fancy_getopt( - options: List[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: Optional[List[str]] -) -> Union[List[str], _GR]: ... + options: List[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: List[str] | None +) -> List[str] | _GR: ... def wrap_text(text: str, width: int) -> List[str]: ... class FancyGetopt: - def __init__(self, option_table: Optional[List[_Option]] = ...) -> None: ... + def __init__(self, option_table: List[_Option] | None = ...) -> None: ... # TODO kinda wrong, `getopt(object=object())` is invalid @overload - def getopt(self, args: Optional[List[str]] = ...) -> _GR: ... + def getopt(self, args: List[str] | None = ...) -> _GR: ... @overload - def getopt(self, args: Optional[List[str]], object: Any) -> List[str]: ... + def getopt(self, args: List[str] | None, object: Any) -> List[str]: ... def get_option_order(self) -> List[Tuple[str, str]]: ... - def generate_help(self, header: Optional[str] = ...) -> List[str]: ... + def generate_help(self, header: str | None = ...) -> List[str]: ... class OptionDummy: ... diff --git a/stdlib/@python2/distutils/file_util.pyi b/stdlib/@python2/distutils/file_util.pyi index 018339733df0..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, @@ -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..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: 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 9061db75ccf1..7d9fe7d34de3 100644 --- a/stdlib/@python2/distutils/sysconfig.pyi +++ b/stdlib/@python2/distutils/sysconfig.pyi @@ -1,14 +1,14 @@ from distutils.ccompiler import CCompiler -from typing import Mapping, Optional, Union +from typing import Mapping PREFIX: str EXEC_PREFIX: str -def get_config_var(name: str) -> Union[int, str, None]: ... -def get_config_vars(*args: str) -> Mapping[str, Union[int, str]]: ... +def get_config_var(name: str) -> int | str | None: ... +def get_config_vars(*args: str) -> Mapping[str, int | str]: ... def get_config_h_filename() -> str: ... def get_makefile_filename() -> str: ... -def get_python_inc(plat_specific: bool = ..., prefix: Optional[str] = ...) -> str: ... -def get_python_lib(plat_specific: bool = ..., standard_lib: bool = ..., prefix: Optional[str] = ...) -> str: ... +def get_python_inc(plat_specific: bool = ..., prefix: str | None = ...) -> str: ... +def get_python_lib(plat_specific: bool = ..., standard_lib: bool = ..., prefix: str | None = ...) -> str: ... def customize_compiler(compiler: CCompiler) -> None: ... def set_python_build() -> None: ... diff --git a/stdlib/@python2/distutils/text_file.pyi b/stdlib/@python2/distutils/text_file.pyi index 9872a1f25751..26ba5a6fabb6 100644 --- a/stdlib/@python2/distutils/text_file.pyi +++ b/stdlib/@python2/distutils/text_file.pyi @@ -1,10 +1,10 @@ -from typing import IO, List, Optional, Tuple, Union +from typing import IO, List, Tuple class TextFile: def __init__( self, - filename: Optional[str] = ..., - file: Optional[IO[str]] = ..., + filename: str | None = ..., + file: IO[str] | None = ..., *, strip_comments: bool = ..., lstrip_ws: bool = ..., @@ -15,7 +15,7 @@ class TextFile: ) -> None: ... def open(self, filename: str) -> None: ... def close(self) -> None: ... - def warn(self, msg: str, line: Union[List[int], Tuple[int, int], int] = ...) -> None: ... - def readline(self) -> Optional[str]: ... + def warn(self, msg: str, line: List[int] | Tuple[int, int] | int = ...) -> None: ... + 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..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: ... @@ -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 f55d01d1a172..dd0969b8635f 100644 --- a/stdlib/@python2/distutils/version.pyi +++ b/stdlib/@python2/distutils/version.pyi @@ -1,33 +1,33 @@ from abc import abstractmethod -from typing import Optional, Pattern, Text, Tuple, TypeVar, Union +from typing import Pattern, Text, Tuple, TypeVar _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 def __str__(self) -> str: ... @abstractmethod - def __cmp__(self: _T, other: Union[_T, str]) -> bool: ... + def __cmp__(self: _T, other: _T | str) -> bool: ... class StrictVersion(Version): version_re: Pattern[str] version: Tuple[int, int, int] - prerelease: Optional[Tuple[Text, int]] - def __init__(self, vstring: Optional[Text] = ...) -> None: ... + prerelease: Tuple[Text, int] | None + def __init__(self, vstring: Text | None = ...) -> 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], ...] - def __init__(self, vstring: Optional[Text] = ...) -> None: ... + version: Tuple[Text | int, ...] + def __init__(self, vstring: Text | None = ...) -> 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..6c3b922244f4 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, Tuple, Type class TestResults(NamedTuple): failed: int @@ -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,10 +39,10 @@ class Example: self, source: str, want: str, - exc_msg: Optional[str] = ..., + exc_msg: str | None = ..., lineno: int = ..., indent: int = ..., - options: Optional[Dict[int, bool]] = ..., + options: Dict[int, bool] | None = ..., ) -> None: ... def __hash__(self) -> int: ... @@ -50,26 +50,24 @@ class DocTest: examples: List[Example] globs: Dict[str, Any] name: str - filename: Optional[str] - lineno: Optional[int] - docstring: Optional[str] + filename: str | None + lineno: int | None + docstring: str | None def __init__( self, examples: List[Example], globs: Dict[str, Any], name: str, - filename: Optional[str], - lineno: Optional[int], - docstring: Optional[str], + filename: str | None, + lineno: int | None, + docstring: str | None, ) -> None: ... def __hash__(self) -> int: ... def __lt__(self, other: DocTest) -> bool: ... class DocTestParser: - def parse(self, string: str, name: str = ...) -> List[Union[str, Example]]: ... - def get_doctest( - self, string: str, globs: Dict[str, Any], name: str, filename: Optional[str], lineno: Optional[int] - ) -> DocTest: ... + 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_examples(self, string: str, name: str = ...) -> List[Example]: ... class DocTestFinder: @@ -79,10 +77,10 @@ class DocTestFinder: def find( self, obj: object, - name: Optional[str] = ..., - module: Union[None, bool, types.ModuleType] = ..., - globs: Optional[Dict[str, Any]] = ..., - extraglobs: Optional[Dict[str, Any]] = ..., + name: str | None = ..., + module: None | bool | types.ModuleType = ..., + globs: Dict[str, Any] | None = ..., + extraglobs: Dict[str, Any] | None = ..., ) -> List[DocTest]: ... _Out = Callable[[str], Any] @@ -95,15 +93,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,40 +122,35 @@ class UnexpectedException(Exception): class DebugRunner(DocTestRunner): ... -master: Optional[DocTestRunner] +master: DocTestRunner | None def testmod( - m: Optional[types.ModuleType] = ..., - name: Optional[str] = ..., - globs: Optional[Dict[str, Any]] = ..., - verbose: Optional[bool] = ..., + m: types.ModuleType | None = ..., + name: str | None = ..., + globs: Dict[str, Any] | None = ..., + verbose: bool | None = ..., report: bool = ..., optionflags: int = ..., - extraglobs: Optional[Dict[str, Any]] = ..., + extraglobs: Dict[str, Any] | None = ..., raise_on_error: bool = ..., exclude_empty: bool = ..., ) -> TestResults: ... def testfile( filename: str, module_relative: bool = ..., - name: Optional[str] = ..., - package: Union[None, str, types.ModuleType] = ..., - globs: Optional[Dict[str, Any]] = ..., - verbose: Optional[bool] = ..., + name: str | None = ..., + package: None | str | types.ModuleType = ..., + globs: Dict[str, Any] | None = ..., + verbose: bool | None = ..., report: bool = ..., optionflags: int = ..., - extraglobs: Optional[Dict[str, Any]] = ..., + extraglobs: Dict[str, Any] | None = ..., raise_on_error: bool = ..., parser: DocTestParser = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., ) -> TestResults: ... def run_docstring_examples( - f: object, - globs: Dict[str, Any], - verbose: bool = ..., - name: str = ..., - compileflags: Optional[int] = ..., - 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: ... @@ -166,9 +159,9 @@ class DocTestCase(unittest.TestCase): self, test: DocTest, optionflags: int = ..., - setUp: Optional[Callable[[DocTest], Any]] = ..., - tearDown: Optional[Callable[[DocTest], Any]] = ..., - checker: Optional[OutputChecker] = ..., + setUp: Callable[[DocTest], Any] | None = ..., + tearDown: Callable[[DocTest], Any] | None = ..., + checker: OutputChecker | None = ..., ) -> None: ... def setUp(self) -> None: ... def tearDown(self) -> None: ... @@ -188,10 +181,10 @@ class SkipDocTestCase(DocTestCase): _DocTestSuite = unittest.TestSuite def DocTestSuite( - module: Union[None, str, types.ModuleType] = ..., - globs: Optional[Dict[str, Any]] = ..., - extraglobs: Optional[Dict[str, Any]] = ..., - test_finder: Optional[DocTestFinder] = ..., + module: None | str | types.ModuleType = ..., + globs: Dict[str, Any] | None = ..., + extraglobs: Dict[str, Any] | None = ..., + test_finder: DocTestFinder | None = ..., **options: Any, ) -> _DocTestSuite: ... @@ -202,15 +195,15 @@ class DocFileCase(DocTestCase): def DocFileTest( path: str, module_relative: bool = ..., - package: Union[None, str, types.ModuleType] = ..., - globs: Optional[Dict[str, Any]] = ..., + package: None | str | types.ModuleType = ..., + globs: Dict[str, Any] | None = ..., parser: DocTestParser = ..., - encoding: Optional[str] = ..., + encoding: str | None = ..., **options: Any, ) -> DocFileCase: ... def DocFileSuite(*paths: str, **kw: Any) -> _DocTestSuite: ... def script_from_examples(s: str) -> str: ... -def testsource(module: Union[None, str, types.ModuleType], name: str) -> str: ... -def debug_src(src: str, pm: bool = ..., globs: Optional[Dict[str, Any]] = ...) -> None: ... -def debug_script(src: str, pm: bool = ..., globs: Optional[Dict[str, Any]] = ...) -> None: ... -def debug(module: Union[None, str, types.ModuleType], name: str, pm: bool = ...) -> None: ... +def testsource(module: None | str | types.ModuleType, name: str) -> str: ... +def debug_src(src: str, pm: bool = ..., globs: Dict[str, Any] | None = ...) -> None: ... +def debug_script(src: str, pm: bool = ..., globs: Dict[str, Any] | None = ...) -> None: ... +def debug(module: None | str | types.ModuleType, name: str, pm: bool = ...) -> None: ... diff --git a/stdlib/@python2/dummy_thread.pyi b/stdlib/@python2/dummy_thread.pyi index 28041002a708..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: ... @@ -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..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): ... @@ -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/utils.pyi b/stdlib/@python2/email/utils.pyi index 257e4b1c947a..0d185134c9d7 100644 --- a/stdlib/@python2/email/utils.pyi +++ b/stdlib/@python2/email/utils.pyi @@ -5,17 +5,17 @@ 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): ... -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..60946e7cf35a 100644 --- a/stdlib/@python2/ensurepip/__init__.pyi +++ b/stdlib/@python2/ensurepip/__init__.pyi @@ -1,8 +1,6 @@ -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/fcntl.pyi b/stdlib/@python2/fcntl.pyi index 200e2249280c..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 @@ -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..0be5596c2bdb 100644 --- a/stdlib/@python2/filecmp.pyi +++ b/stdlib/@python2/filecmp.pyi @@ -1,15 +1,15 @@ -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 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]): 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/fileinput.pyi b/stdlib/@python2/fileinput.pyi index 1e1f8dace600..316643fcf15f 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 +from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Text 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/formatter.pyi b/stdlib/@python2/formatter.pyi index 31c45592a215..da165f2d55e3 100644 --- a/stdlib/@python2/formatter.pyi +++ b/stdlib/@python2/formatter.pyi @@ -1,37 +1,37 @@ -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] _StylesType = Tuple[Any, ...] class NullFormatter: - writer: Optional[NullWriter] - def __init__(self, writer: Optional[NullWriter] = ...) -> None: ... + writer: NullWriter | None + def __init__(self, writer: NullWriter | None = ...) -> None: ... def end_paragraph(self, blankline: int) -> None: ... def add_line_break(self) -> None: ... def add_hor_rule(self, *args: Any, **kw: Any) -> None: ... - def add_label_data(self, format: str, counter: int, blankline: Optional[int] = ...) -> None: ... + def add_label_data(self, format: str, counter: int, blankline: int | None = ...) -> None: ... def add_flowing_data(self, data: str) -> None: ... def add_literal_data(self, data: str) -> None: ... def flush_softspace(self) -> None: ... - def push_alignment(self, align: Optional[str]) -> None: ... + def push_alignment(self, align: str | None) -> None: ... def pop_alignment(self) -> None: ... def push_font(self, x: _FontType) -> None: ... def pop_font(self) -> None: ... def push_margin(self, margin: int) -> None: ... def pop_margin(self) -> None: ... - def set_spacing(self, spacing: Optional[str]) -> None: ... + def set_spacing(self, spacing: str | None) -> None: ... def push_style(self, *styles: _StylesType) -> None: ... def pop_style(self, n: int = ...) -> None: ... def assert_line_data(self, flag: int = ...) -> None: ... class AbstractFormatter: writer: NullWriter - align: Optional[str] - align_stack: List[Optional[str]] + align: str | None + align_stack: List[str | None] font_stack: List[_FontType] margin_stack: List[int] - spacing: Optional[str] + spacing: str | None style_stack: Any nospace: int softspace: int @@ -43,20 +43,20 @@ class AbstractFormatter: def end_paragraph(self, blankline: int) -> None: ... def add_line_break(self) -> None: ... def add_hor_rule(self, *args: Any, **kw: Any) -> None: ... - def add_label_data(self, format: str, counter: int, blankline: Optional[int] = ...) -> None: ... + def add_label_data(self, format: str, counter: int, blankline: int | None = ...) -> None: ... def format_counter(self, format: Iterable[str], counter: int) -> str: ... def format_letter(self, case: str, counter: int) -> str: ... def format_roman(self, case: str, counter: int) -> str: ... def add_flowing_data(self, data: str) -> None: ... def add_literal_data(self, data: str) -> None: ... def flush_softspace(self) -> None: ... - def push_alignment(self, align: Optional[str]) -> None: ... + def push_alignment(self, align: str | None) -> None: ... def pop_alignment(self) -> None: ... def push_font(self, font: _FontType) -> None: ... def pop_font(self) -> None: ... def push_margin(self, margin: int) -> None: ... def pop_margin(self) -> None: ... - def set_spacing(self, spacing: Optional[str]) -> None: ... + def set_spacing(self, spacing: str | None) -> None: ... def push_style(self, *styles: _StylesType) -> None: ... def pop_style(self, n: int = ...) -> None: ... def assert_line_data(self, flag: int = ...) -> None: ... @@ -64,10 +64,10 @@ class AbstractFormatter: class NullWriter: def __init__(self) -> None: ... def flush(self) -> None: ... - def new_alignment(self, align: Optional[str]) -> None: ... + def new_alignment(self, align: str | None) -> None: ... def new_font(self, font: _FontType) -> None: ... def new_margin(self, margin: int, level: int) -> None: ... - def new_spacing(self, spacing: Optional[str]) -> None: ... + def new_spacing(self, spacing: str | None) -> None: ... def new_styles(self, styles: Tuple[Any, ...]) -> None: ... def send_paragraph(self, blankline: int) -> None: ... def send_line_break(self) -> None: ... @@ -77,10 +77,10 @@ class NullWriter: def send_literal_data(self, data: str) -> None: ... class AbstractWriter(NullWriter): - def new_alignment(self, align: Optional[str]) -> None: ... + def new_alignment(self, align: str | None) -> None: ... def new_font(self, font: _FontType) -> None: ... def new_margin(self, margin: int, level: int) -> None: ... - def new_spacing(self, spacing: Optional[str]) -> None: ... + def new_spacing(self, spacing: str | None) -> None: ... def new_styles(self, styles: Tuple[Any, ...]) -> None: ... def send_paragraph(self, blankline: int) -> None: ... def send_line_break(self) -> None: ... @@ -92,7 +92,7 @@ class AbstractWriter(NullWriter): class DumbWriter(NullWriter): file: IO[str] maxcol: int - def __init__(self, file: Optional[IO[str]] = ..., maxcol: int = ...) -> None: ... + def __init__(self, file: IO[str] | None = ..., maxcol: int = ...) -> None: ... def reset(self) -> None: ... def send_paragraph(self, blankline: int) -> None: ... def send_line_break(self) -> None: ... @@ -100,4 +100,4 @@ class DumbWriter(NullWriter): def send_literal_data(self, data: str) -> None: ... def send_flowing_data(self, data: str) -> None: ... -def test(file: Optional[str] = ...) -> None: ... +def test(file: str | None = ...) -> None: ... diff --git a/stdlib/@python2/fractions.pyi b/stdlib/@python2/fractions.pyi index bb60014b398e..872e20ede688 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 = Union[int, float, Decimal, Real] @@ -18,14 +18,10 @@ def gcd(a: Integral, b: Integral) -> Integral: ... class Fraction(Rational): @overload def __new__( - cls: Type[_T], - numerator: Union[int, Rational] = ..., - denominator: Optional[Union[int, Rational]] = ..., - *, - _normalize: bool = ..., + cls: Type[_T], numerator: int | Rational = ..., denominator: int | Rational | None = ..., *, _normalize: bool = ... ) -> _T: ... @overload - def __new__(cls: Type[_T], __value: Union[float, Decimal, str], *, _normalize: bool = ...) -> _T: ... + def __new__(cls: Type[_T], __value: float | Decimal | str, *, _normalize: bool = ...) -> _T: ... @classmethod def from_float(cls, f: float) -> Fraction: ... @classmethod @@ -36,97 +32,97 @@ 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 - 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/ftplib.pyi b/stdlib/@python2/ftplib.pyi index bdb975fbc21e..0931a9d171cd 100644 --- a/stdlib/@python2/ftplib.pyi +++ b/stdlib/@python2/ftplib.pyi @@ -1,7 +1,7 @@ from _typeshed import SupportsRead, SupportsReadline from socket import socket from ssl import SSLContext -from typing import Any, BinaryIO, Callable, List, Optional, Text, Tuple, Type, TypeVar, Union +from typing import Any, BinaryIO, Callable, List, Text, Tuple, Type, TypeVar, Union from typing_extensions import Literal _T = TypeVar("_T") @@ -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: ... @@ -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: ... @@ -61,29 +61,29 @@ 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, cmd: Text, fp: SupportsRead[bytes], blocksize: int = ..., - callback: Optional[Callable[[bytes], Any]] = ..., - rest: Optional[_IntOrStr] = ..., + callback: Callable[[bytes], Any] | None = ..., + 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: ... + def retrlines(self, cmd: Text, callback: Callable[[str], Any] | None = ...) -> str: ... + def storlines(self, cmd: Text, fp: SupportsReadline[bytes], callback: Callable[[bytes], Any] | None = ...) -> str: ... def acct(self, password: Text) -> str: ... def nlst(self, *args: Text) -> List[str]: ... # Technically only the last arg can be a Callable but ... - def dir(self, *args: Union[str, Callable[[str], None]]) -> None: ... + def dir(self, *args: str | Callable[[str], None]) -> None: ... def 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]] = ..., + source_address: Tuple[str, int] | None = ..., ) -> None: ... ssl_version: int - keyfile: Optional[str] - certfile: Optional[str] + keyfile: str | None + certfile: str | None context: SSLContext def login(self, user: 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/genericpath.pyi b/stdlib/@python2/genericpath.pyi index f1d3538cd1a4..ba29db4692bb 100644 --- a/stdlib/@python2/genericpath.pyi +++ b/stdlib/@python2/genericpath.pyi @@ -6,7 +6,7 @@ from typing_extensions import Literal # Iterable[T], so that Union[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 0930fe63813e..a91234f6b2d3 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 def bindtextdomain(domain: str, localedir: str = ...) -> str: ... def bind_textdomain_codeset(domain: str, codeset: str = ...) -> str: ... @@ -18,14 +18,14 @@ 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]: ... - 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 = ... -) -> Optional[Union[str, List[str]]]: ... + domain: str, localedir: str | None = ..., languages: Sequence[str] | None = ..., all: Any = ... +) -> str | List[str] | None: ... def translation( domain: str, - localedir: Optional[str] = ..., - languages: Optional[Sequence[str]] = ..., - class_: Optional[Type[NullTranslations]] = ..., + localedir: str | None = ..., + languages: Sequence[str] | None = ..., + class_: Type[NullTranslations] | None = ..., 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/glob.pyi b/stdlib/@python2/glob.pyi index 2804d74a6a3f..f5a389a0ddfa 100644 --- a/stdlib/@python2/glob.pyi +++ b/stdlib/@python2/glob.pyi @@ -1,7 +1,7 @@ -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]: ... -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/grp.pyi b/stdlib/@python2/grp.pyi index 8447f21736bb..63898b26bf17 100644 --- a/stdlib/@python2/grp.pyi +++ b/stdlib/@python2/grp.pyi @@ -1,8 +1,8 @@ -from typing import List, NamedTuple, Optional +from typing import List, NamedTuple 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/heapq.pyi b/stdlib/@python2/heapq.pyi index 8bdb3d23b9ba..78ce6fd03928 100644 --- a/stdlib/@python2/heapq.pyi +++ b/stdlib/@python2/heapq.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsLessThan -from typing import Callable, Iterable, List, Optional, TypeVar +from typing import Callable, Iterable, List, TypeVar _T = TypeVar("_T") @@ -10,6 +10,6 @@ def heappushpop(heap: List[_T], item: _T) -> _T: ... def heapify(x: List[_T]) -> None: ... def heapreplace(heap: List[_T], item: _T) -> _T: ... def merge(*iterables: Iterable[_T]) -> Iterable[_T]: ... -def nlargest(n: int, iterable: Iterable[_T], key: Optional[Callable[[_T], SupportsLessThan]] = ...) -> List[_T]: ... -def nsmallest(n: int, iterable: Iterable[_T], key: Optional[Callable[[_T], SupportsLessThan]] = ...) -> List[_T]: ... +def nlargest(n: int, iterable: Iterable[_T], key: Callable[[_T], SupportsLessThan] | None = ...) -> List[_T]: ... +def nsmallest(n: int, iterable: Iterable[_T], key: Callable[[_T], SupportsLessThan] | None = ...) -> List[_T]: ... def _heapify_max(__x: List[_T]) -> None: ... # undocumented diff --git a/stdlib/@python2/hmac.pyi b/stdlib/@python2/hmac.pyi index 7550163b6707..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 @@ -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..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: ... @@ -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 73063629295a..c4346851bdac 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. @@ -18,9 +18,9 @@ class IMAP4: mustquote: Pattern[Text] = ... debug: int = ... state: str = ... - literal: Optional[Text] = ... - tagged_commands: Dict[bytes, Optional[List[bytes]]] - untagged_responses: Dict[str, List[Union[bytes, Tuple[bytes, bytes]]]] + literal: Text | None = ... + tagged_commands: Dict[bytes, List[bytes] | None] + untagged_responses: Dict[str, List[bytes | Tuple[bytes, bytes]]] continuation_response: str = ... is_readonly: bool = ... tagnum: int = ... @@ -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: ... @@ -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: ... @@ -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/imghdr.pyi b/stdlib/@python2/imghdr.pyi index 4a6c3f39eb27..d60cafa4c78f 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: ... @@ -8,8 +8,8 @@ class _ReadableBinary(Protocol): _File = Union[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/imp.pyi b/stdlib/@python2/imp.pyi index 3cd37648b968..128bd900e996 100644 --- a/stdlib/@python2/imp.pyi +++ b/stdlib/@python2/imp.pyi @@ -1,5 +1,5 @@ import types -from typing import IO, Any, Iterable, List, Optional, Tuple +from typing import IO, Any, Iterable, List, Tuple C_BUILTIN: int C_EXTENSION: int @@ -13,7 +13,7 @@ PY_SOURCE: int SEARCH_ERROR: int def acquire_lock() -> None: ... -def find_module(name: str, path: Iterable[str] = ...) -> Optional[Tuple[IO[Any], str, Tuple[str, str, int]]]: ... +def find_module(name: str, path: Iterable[str] = ...) -> Tuple[IO[Any], str, Tuple[str, str, int]] | None: ... def get_magic() -> str: ... def get_suffixes() -> List[Tuple[str, str, int]]: ... def init_builtin(name: str) -> types.ModuleType: ... diff --git a/stdlib/@python2/importlib.pyi b/stdlib/@python2/importlib.pyi index 8bb179a4bd9a..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: 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 8e95a92cac10..c6118ea8aebb 100644 --- a/stdlib/@python2/inspect.pyi +++ b/stdlib/@python2/inspect.pyi @@ -29,9 +29,9 @@ class ModuleInfo(NamedTuple): mode: str 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 getmodulename(path: AnyStr) -> Optional[AnyStr]: ... +def getmembers(object: object, predicate: Callable[[Any], bool] | None = ...) -> List[Tuple[str, Any]]: ... +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,35 +55,35 @@ _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: ... -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]]]: ... +def getclasstree(classes: List[type], unique: bool = ...) -> List[Tuple[type, Tuple[type, ...]] | List[Any]]: ... 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[Union[str, List[Any]]] - varargs: Optional[str] - keywords: Optional[str] + args: List[str | List[Any]] + varargs: str | None + keywords: str | None def getargs(co: CodeType) -> Arguments: ... def getargspec(func: object) -> ArgSpec: ... @@ -103,13 +103,13 @@ class Traceback(NamedTuple): filename: str lineno: int function: str - code_context: Optional[List[str]] - index: Optional[int] # type: ignore + code_context: List[str] | None + index: int | None # type: ignore _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/io.pyi b/stdlib/@python2/io.pyi index 1e29cc67369f..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 ( @@ -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/itertools.pyi b/stdlib/@python2/itertools.pyi index 63c38980ce79..12996d44628b 100644 --- a/stdlib/@python2/itertools.pyi +++ b/stdlib/@python2/itertools.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Generic, Iterable, Iterator, Optional, Sequence, Tuple, TypeVar, overload +from typing import Any, Callable, Generic, Iterable, Iterator, Sequence, Tuple, TypeVar, overload _T = TypeVar("_T") _S = TypeVar("_S") @@ -21,16 +21,16 @@ class chain(Iterator[_T], Generic[_T]): def compress(data: Iterable[_T], selectors: Iterable[Any]) -> Iterator[_T]: ... def dropwhile(predicate: Callable[[_T], Any], iterable: Iterable[_T]) -> Iterator[_T]: ... -def ifilter(predicate: Optional[Callable[[_T], Any]], iterable: Iterable[_T]) -> Iterator[_T]: ... -def ifilterfalse(predicate: Optional[Callable[[_T], Any]], iterable: Iterable[_T]) -> Iterator[_T]: ... +def ifilter(predicate: Callable[[_T], Any] | None, iterable: Iterable[_T]) -> Iterator[_T]: ... +def ifilterfalse(predicate: Callable[[_T], Any] | None, iterable: Iterable[_T]) -> Iterator[_T]: ... @overload def groupby(iterable: Iterable[_T], key: None = ...) -> Iterator[Tuple[_T, Iterator[_T]]]: ... @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 2d38e6b47bb8..bfbddb2a6835 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, Text, Tuple, Type def dumps( obj: Any, @@ -7,56 +7,56 @@ def dumps( ensure_ascii: bool = ..., check_circular: bool = ..., allow_nan: bool = ..., - cls: Optional[Type[JSONEncoder]] = ..., - indent: Optional[int] = ..., - separators: Optional[Tuple[str, str]] = ..., + cls: Type[JSONEncoder] | None = ..., + indent: int | None = ..., + separators: Tuple[str, str] | None = ..., encoding: str = ..., - default: Optional[Callable[[Any], Any]] = ..., + default: Callable[[Any], Any] | None = ..., sort_keys: bool = ..., **kwds: Any, ) -> str: ... def dump( obj: Any, - fp: Union[IO[str], IO[Text]], + fp: IO[str] | IO[Text], skipkeys: bool = ..., ensure_ascii: bool = ..., check_circular: bool = ..., allow_nan: bool = ..., - cls: Optional[Type[JSONEncoder]] = ..., - indent: Optional[int] = ..., - separators: Optional[Tuple[str, str]] = ..., + cls: Type[JSONEncoder] | None = ..., + indent: int | None = ..., + separators: Tuple[str, str] | None = ..., encoding: str = ..., - default: Optional[Callable[[Any], Any]] = ..., + default: Callable[[Any], Any] | None = ..., sort_keys: bool = ..., **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]] = ..., - parse_float: Optional[Callable[[str], Any]] = ..., - parse_int: Optional[Callable[[str], Any]] = ..., - parse_constant: Optional[Callable[[str], Any]] = ..., - object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ..., + cls: Type[JSONDecoder] | None = ..., + object_hook: Callable[[Dict[Any, Any]], Any] | None = ..., + parse_float: Callable[[str], Any] | None = ..., + parse_int: Callable[[str], Any] | None = ..., + parse_constant: Callable[[str], Any] | None = ..., + object_pairs_hook: Callable[[List[Tuple[Any, Any]]], Any] | None = ..., **kwds: Any, ) -> Any: ... def load( - fp: SupportsRead[Union[Text, bytes]], - encoding: Optional[str] = ..., - cls: Optional[Type[JSONDecoder]] = ..., - object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ..., - parse_float: Optional[Callable[[str], Any]] = ..., - parse_int: Optional[Callable[[str], Any]] = ..., - parse_constant: Optional[Callable[[str], Any]] = ..., - object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ..., + fp: SupportsRead[Text | bytes], + encoding: str | None = ..., + cls: Type[JSONDecoder] | None = ..., + object_hook: Callable[[Dict[Any, Any]], Any] | None = ..., + parse_float: Callable[[str], Any] | None = ..., + parse_int: Callable[[str], Any] | None = ..., + parse_constant: Callable[[str], Any] | None = ..., + object_pairs_hook: Callable[[List[Tuple[Any, Any]]], Any] | None = ..., **kwds: Any, ) -> Any: ... 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 @@ -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,9 +83,9 @@ class JSONEncoder(object): check_circular: bool = ..., allow_nan: bool = ..., sort_keys: bool = ..., - indent: Optional[int] = ..., - separators: Tuple[Union[Text, bytes], Union[Text, bytes]] = ..., - encoding: Union[Text, bytes] = ..., + indent: int | None = ..., + 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/pgen2/driver.pyi b/stdlib/@python2/lib2to3/pgen2/driver.pyi index 841b0e4b1cb3..f36e3dd0a10c 100644 --- a/stdlib/@python2/lib2to3/pgen2/driver.pyi +++ b/stdlib/@python2/lib2to3/pgen2/driver.pyi @@ -2,19 +2,19 @@ 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 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/parse.pyi b/stdlib/@python2/lib2to3/pgen2/parse.pyi index b7018cba9c1d..eed165db551c 100644 --- a/stdlib/@python2/lib2to3/pgen2/parse.pyi +++ b/stdlib/@python2/lib2to3/pgen2/parse.pyi @@ -1,26 +1,26 @@ 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] 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..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): ... @@ -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: ... @@ -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 48d11f84f201..27c64853329e 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 @@ -24,14 +24,14 @@ class Base: def clone(self: _P) -> _P: ... def post_order(self) -> Iterator[_NL]: ... def pre_order(self) -> Iterator[_NL]: ... - def replace(self, new: Union[_NL, List[_NL]]) -> None: ... + def replace(self, new: _NL | List[_NL]) -> None: ... def get_lineno(self) -> int: ... def changed(self) -> None: ... - def remove(self) -> Optional[int]: ... + def remove(self) -> int | None: ... @property - def next_sibling(self) -> Optional[_NL]: ... + def next_sibling(self) -> _NL | None: ... @property - def prev_sibling(self) -> Optional[_NL]: ... + def prev_sibling(self) -> _NL | None: ... def leaves(self) -> Iterator[Leaf]: ... def depth(self) -> int: ... def get_suffix(self) -> Text: ... @@ -44,9 +44,9 @@ class Node(Base): self, type: int, children: List[_NL], - context: Optional[Any] = ..., - prefix: Optional[Text] = ..., - fixers_applied: Optional[List[Any]] = ..., + context: Any | None = ..., + prefix: Text | None = ..., + fixers_applied: List[Any] | None = ..., ) -> None: ... def set_child(self, i: int, child: _NL) -> None: ... def insert_child(self, i: int, child: _NL) -> None: ... @@ -58,38 +58,33 @@ class Leaf(Base): value: Text fixers_applied: List[Any] def __init__( - self, - type: int, - value: Text, - context: Optional[_Context] = ..., - prefix: Optional[Text] = ..., - 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: ... 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..8628a0c58adc 100644 --- a/stdlib/@python2/linecache.pyi +++ b/stdlib/@python2/linecache.pyi @@ -1,9 +1,9 @@ -from typing import Any, Dict, List, Optional, Text +from typing import Any, Dict, List, 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 eb73dfcb62a2..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, Optional, Sequence, Tuple, Union +from typing import Any, Callable, Dict, Iterable, List, Mapping, Sequence, Tuple CODESET: int D_T_FMT: int @@ -74,19 +74,19 @@ CHAR_MAX: int class Error(Exception): ... -def setlocale(category: int, locale: Union[_str, Iterable[_str], None] = ...) -> _str: ... -def localeconv() -> Mapping[_str, Union[int, _str, List[int]]]: ... +def setlocale(category: int, locale: _str | Iterable[_str] | None = ...) -> _str: ... +def localeconv() -> Mapping[_str, int | _str | List[int]]: ... def nl_langinfo(__key: int) -> _str: ... -def getdefaultlocale(envvars: Tuple[_str, ...] = ...) -> Tuple[Optional[_str], Optional[_str]]: ... +def getdefaultlocale(envvars: Tuple[_str, ...] = ...) -> Tuple[_str | None, _str | None]: ... def getlocale(category: int = ...) -> Sequence[_str]: ... def getpreferredencoding(do_setlocale: bool = ...) -> _str: ... def normalize(localename: _str) -> _str: ... def resetlocale(category: int = ...) -> None: ... def strcoll(string1: _str, string2: _str) -> int: ... def strxfrm(string: _str) -> _str: ... -def format(percent: _str, value: Union[float, Decimal], grouping: bool = ..., monetary: bool = ..., *additional: Any) -> _str: ... +def format(percent: _str, value: float | Decimal, grouping: bool = ..., monetary: bool = ..., *additional: Any) -> _str: ... 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 242132c820d5..9cca9b51f753 100644 --- a/stdlib/@python2/logging/__init__.pyi +++ b/stdlib/@python2/logging/__init__.pyi @@ -14,11 +14,11 @@ raiseExceptions: bool logThreads: bool logMultiprocessing: bool logProcesses: bool -_srcfile: Optional[str] +_srcfile: str | None 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 @@ -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: Optional[_ExcInfoType] = ..., 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: ... @@ -78,9 +78,9 @@ class Logger(Filterer): lno: int, msg: Any, args: _ArgsType, - exc_info: Optional[_SysExcInfoType], - func: Optional[str] = ..., - extra: Optional[Mapping[str, Any]] = ..., + exc_info: _SysExcInfoType | None, + func: str | None = ..., + extra: Mapping[str, Any] | None = ..., ) -> LogRecord: ... CRITICAL: int @@ -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: ... @@ -165,66 +165,62 @@ 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: ... @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: ... -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 critical( - msg: Any, *args: Any, exc_info: _ExcInfoType = ..., extra: Optional[Dict[str, Any]] = ..., **kwargs: Any -) -> None: ... -def exception( - 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: 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: 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 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: ... @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 @@ -233,14 +229,14 @@ 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 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/config.pyi b/stdlib/@python2/logging/config.pyi index 3d8817b7736f..03707bb98f55 100644 --- a/stdlib/@python2/logging/config.pyi +++ b/stdlib/@python2/logging/config.pyi @@ -1,12 +1,10 @@ from _typeshed import StrPath from threading import Thread -from typing import IO, Any, Dict, Optional, Union +from typing import IO, Any, Dict _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 = ... -) -> 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 ed7e6d74dd17..174c7bde3d68 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 DEFAULT_TCP_LOGGING_PORT: int DEFAULT_UDP_LOGGING_PORT: int @@ -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: ... @@ -90,14 +90,12 @@ 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: Union[Tuple[str, int], str] = ..., facility: int = ..., socktype: Optional[SocketKind] = ... - ) -> None: ... - def encodePriority(self, facility: Union[int, str], priority: Union[int, str]) -> int: ... + 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: ... 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: ... @@ -107,12 +105,12 @@ 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, - credentials: Optional[Tuple[str, str]] = ..., - secure: Union[Tuple[str], Tuple[str, str], None] = ..., + credentials: Tuple[str, str] | None = ..., + secure: Tuple[str] | Tuple[str, str] | None = ..., ) -> None: ... def getSubject(self, record: LogRecord) -> str: ... @@ -122,7 +120,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..bcb882e23eef 100644 --- a/stdlib/@python2/macpath.pyi +++ b/stdlib/@python2/macpath.pyi @@ -27,9 +27,9 @@ 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: Optional[str] +altsep: str | None def basename(s: AnyStr) -> AnyStr: ... def dirname(s: AnyStr) -> AnyStr: ... diff --git a/stdlib/@python2/macurl2path.pyi b/stdlib/@python2/macurl2path.pyi index 025820b44e89..6aac6dfeace5 100644 --- a/stdlib/@python2/macurl2path.pyi +++ b/stdlib/@python2/macurl2path.pyi @@ -1,5 +1,3 @@ -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..18a66fa964c4 100644 --- a/stdlib/@python2/mailbox.pyi +++ b/stdlib/@python2/mailbox.pyi @@ -11,7 +11,6 @@ from typing import ( Iterator, List, Mapping, - Optional, Protocol, Sequence, Text, @@ -37,18 +36,18 @@ linesep: bytes class Mailbox(Generic[_MessageT]): - _path: Union[bytes, str] # undocumented - _factory: Optional[Callable[[IO[Any]], _MessageT]] # undocumented - def __init__(self, path: Text, factory: Optional[Callable[[IO[Any]], _MessageT]] = ..., create: bool = ...) -> None: ... + _path: bytes | str # undocumented + _factory: Callable[[IO[Any]], _MessageT] | None # undocumented + def __init__(self, path: Text, factory: Callable[[IO[Any]], _MessageT] | None = ..., create: bool = ...) -> None: ... def add(self, message: _MessageData) -> str: ... def remove(self, key: str) -> None: ... def __delitem__(self, key: str) -> None: ... def discard(self, key: str) -> None: ... def __setitem__(self, key: str, message: _MessageData) -> None: ... @overload - def get(self, key: str, default: None = ...) -> Optional[_MessageT]: ... + def get(self, key: str, default: None = ...) -> _MessageT | None: ... @overload - def get(self, key: str, default: _T) -> Union[_MessageT, _T]: ... + def get(self, key: str, default: _T) -> _MessageT | _T: ... def __getitem__(self, key: str) -> _MessageT: ... def get_message(self, key: str) -> _MessageT: ... def get_string(self, key: str) -> str: ... @@ -66,11 +65,11 @@ class Mailbox(Generic[_MessageT]): def __len__(self) -> int: ... def clear(self) -> None: ... @overload - def pop(self, key: str, default: None = ...) -> Optional[_MessageT]: ... + def pop(self, key: str, default: None = ...) -> _MessageT | None: ... @overload - def pop(self, key: str, default: _T = ...) -> Union[_MessageT, _T]: ... + def pop(self, key: str, default: _T = ...) -> _MessageT | _T: ... def popitem(self) -> Tuple[str, _MessageT]: ... - def update(self, arg: Optional[Union[_HasIteritems, _HasItems, Iterable[Tuple[str, _MessageData]]]] = ...) -> None: ... + def update(self, arg: _HasIteritems | _HasItems | Iterable[Tuple[str, _MessageData]] | None = ...) -> None: ... def flush(self) -> None: ... def lock(self) -> None: ... def unlock(self) -> None: ... @@ -79,16 +78,14 @@ class Mailbox(Generic[_MessageT]): class Maildir(Mailbox[MaildirMessage]): colon: str - def __init__( - self, dirname: Text, factory: Optional[Callable[[IO[Any]], MaildirMessage]] = ..., create: bool = ... - ) -> None: ... + def __init__(self, dirname: Text, factory: Callable[[IO[Any]], MaildirMessage] | None = ..., create: bool = ...) -> None: ... def get_file(self, key: str) -> _ProxyFile[bytes]: ... def list_folders(self) -> List[str]: ... def get_folder(self, folder: Text) -> Maildir: ... 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]): ... @@ -98,13 +95,13 @@ class _mboxMMDF(_singlefileMailbox[_MessageT]): def get_string(self, key: str, from_: bool = ...) -> str: ... class mbox(_mboxMMDF[mboxMessage]): - def __init__(self, path: Text, factory: Optional[Callable[[IO[Any]], mboxMessage]] = ..., create: bool = ...) -> None: ... + def __init__(self, path: Text, factory: Callable[[IO[Any]], mboxMessage] | None = ..., create: bool = ...) -> None: ... class MMDF(_mboxMMDF[MMDFMessage]): - def __init__(self, path: Text, factory: Optional[Callable[[IO[Any]], MMDFMessage]] = ..., create: bool = ...) -> None: ... + def __init__(self, path: Text, factory: Callable[[IO[Any]], MMDFMessage] | None = ..., create: bool = ...) -> None: ... class MH(Mailbox[MHMessage]): - def __init__(self, path: Text, factory: Optional[Callable[[IO[Any]], MHMessage]] = ..., create: bool = ...) -> None: ... + def __init__(self, path: Text, factory: Callable[[IO[Any]], MHMessage] | None = ..., create: bool = ...) -> None: ... def get_file(self, key: str) -> _ProxyFile[bytes]: ... def list_folders(self) -> List[str]: ... def get_folder(self, folder: Text) -> MH: ... @@ -115,12 +112,12 @@ class MH(Mailbox[MHMessage]): def pack(self) -> None: ... class Babyl(_singlefileMailbox[BabylMessage]): - def __init__(self, path: Text, factory: Optional[Callable[[IO[Any]], BabylMessage]] = ..., create: bool = ...) -> None: ... + def __init__(self, path: Text, factory: Callable[[IO[Any]], BabylMessage] | None = ..., create: bool = ...) -> None: ... def get_file(self, key: str) -> IO[bytes]: ... def get_labels(self) -> List[str]: ... class Message(email.message.Message): - def __init__(self, message: Optional[_MessageData] = ...) -> None: ... + def __init__(self, message: _MessageData | None = ...) -> None: ... class MaildirMessage(Message): def get_subdir(self) -> str: ... @@ -136,9 +133,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]]] = ... - ) -> 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: ... @@ -164,19 +159,17 @@ 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] - ) -> 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: ... @@ -185,7 +178,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 a65cc3a329d3..b29854f3c744 100644 --- a/stdlib/@python2/mailcap.pyi +++ b/stdlib/@python2/mailcap.pyi @@ -1,8 +1,8 @@ -from typing import Dict, List, Mapping, Optional, Sequence, Tuple, Union +from typing import Dict, List, Mapping, Sequence, Tuple, Union _Cap = Dict[str, Union[str, int]] 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..a9661dab56ad 100644 --- a/stdlib/@python2/mimetypes.pyi +++ b/stdlib/@python2/mimetypes.pyi @@ -1,11 +1,11 @@ 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[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 init(files: Optional[Sequence[str]] = ...) -> None: ... -def read_mime_types(file: str) -> Optional[Dict[str, str]]: ... +def guess_extension(type: str, strict: bool = ...) -> str | None: ... +def init(files: Sequence[str] | None = ...) -> None: ... +def read_mime_types(file: str) -> Dict[str, str] | None: ... def add_type(type: str, ext: str, strict: bool = ...) -> None: ... inited: bool @@ -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 750d0829cb8f..44369e6c051d 100644 --- a/stdlib/@python2/mmap.pyi +++ b/stdlib/@python2/mmap.pyi @@ -1,5 +1,5 @@ import sys -from typing import NoReturn, Optional, Sequence, Union +from typing import NoReturn, Sequence ACCESS_DEFAULT: int ACCESS_READ: int @@ -25,9 +25,7 @@ if sys.platform != "win32": class mmap(Sequence[bytes]): if sys.platform == "win32": - def __init__( - self, fileno: int, length: int, tagname: Optional[str] = ..., 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 = ... @@ -47,7 +45,7 @@ class mmap(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 __getslice__(self, i: Optional[int], j: Optional[int]) -> bytes: ... - def __delitem__(self, index: Union[int, slice]) -> NoReturn: ... - def __setitem__(self, index: Union[int, slice], object: bytes) -> None: ... + def __getitem__(self, index: int | slice) -> bytes: ... + def __getslice__(self, i: int | None, j: int | None) -> bytes: ... + def __delitem__(self, index: int | slice) -> NoReturn: ... + def __setitem__(self, index: int | slice, object: bytes) -> None: ... diff --git a/stdlib/@python2/modulefinder.pyi b/stdlib/@python2/modulefinder.pyi index 6fb953242b72..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 @@ -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: @@ -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,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: List[str] | None = ..., level: int = ... + ) -> Module | None: ... # undocumented + def determine_parent(self, caller: Module | None, level: int = ...) -> Module | None: ... # undocumented def find_head_package(self, parent: Module, name: str) -> Tuple[Module, str]: ... # undocumented def load_tail(self, q: Module, tail: str) -> Module: ... # undocumented def ensure_fromlist(self, m: Module, fromlist: Iterable[str], recursive: int = ...) -> None: ... # undocumented def find_all_submodules(self, m: Module) -> Iterable[str]: ... # undocumented - def import_module(self, partname: str, fqname: str, parent: Module) -> Optional[Module]: ... # undocumented + def import_module(self, partname: str, fqname: str, parent: Module) -> Module | None: ... # undocumented def load_module(self, fqname: str, fp: IO[str], pathname: str, file_info: Tuple[str, str, str]) -> Module: ... # undocumented def scan_code(self, co: CodeType, m: Module) -> None: ... # undocumented def load_package(self, fqname: str, pathname: str) -> Module: ... # undocumented def add_module(self, fqname: str) -> Module: ... # undocumented def find_module( - self, name: str, path: Optional[str], parent: Optional[Module] = ... - ) -> Tuple[Optional[IO[Any]], Optional[str], Tuple[str, str, int]]: ... # undocumented + self, name: str, path: str | None, parent: Module | None = ... + ) -> Tuple[IO[Any] | None, str | None, Tuple[str, str, int]]: ... # undocumented def report(self) -> None: ... def any_missing(self) -> List[str]: ... # undocumented def any_missing_maybe(self) -> Tuple[List[str], List[str]]: ... # undocumented diff --git a/stdlib/@python2/msilib/__init__.pyi b/stdlib/@python2/msilib/__init__.pyi index c783493f315e..fa6757696845 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 from typing_extensions import Literal if sys.platform == "win32": @@ -31,10 +31,10 @@ if sys.platform == "win32": def create(self, db: _Database) -> None: ... class _Unspecified: ... def change_sequence( - seq: Sequence[Tuple[str, Optional[str], int]], + seq: Sequence[Tuple[str, str | None, int]], action: str, - seqno: Union[int, Type[_Unspecified]] = ..., - cond: Union[str, Type[_Unspecified]] = ..., + seqno: int | Type[_Unspecified] = ..., + cond: str | Type[_Unspecified] = ..., ) -> None: ... def add_data(db: _Database, table: str, values: Iterable[Tuple[Any, ...]]) -> None: ... def add_stream(db: _Database, name: str, path: str) -> None: ... @@ -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,21 +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] = ... - ) -> str: ... - def glob(self, pattern: str, exclude: Optional[Container[str]] = ...) -> List[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: @@ -108,8 +106,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 +116,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 +124,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,38 +156,20 @@ 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, - name: str, - x: int, - y: int, - w: int, - h: int, - attr: int, - prop: Optional[str], - text: Optional[str], - next: Optional[str], + 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: Optional[str], - text: Optional[str], - next: Optional[str], + 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 10b65088cf80..d59e9767c3de 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 @@ -92,6 +92,4 @@ 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] - ] + _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/msilib/text.pyi b/stdlib/@python2/msilib/text.pyi index e338b8b5ba3d..4ae8ee68184b 100644 --- a/stdlib/@python2/msilib/text.pyi +++ b/stdlib/@python2/msilib/text.pyi @@ -1,9 +1,9 @@ import sys -from typing import List, Optional, Tuple +from typing import List, 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..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): ... @@ -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] = ..., - initializer: Optional[Callable[..., Any]] = ..., + processes: int | None = ..., + initializer: Callable[..., Any] | None = ..., 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..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] @@ -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/dummy/connection.pyi b/stdlib/@python2/multiprocessing/dummy/connection.pyi index 73789028611e..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] @@ -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 b20618ca0291..be9747e89c2f 100644 --- a/stdlib/@python2/multiprocessing/pool.pyi +++ b/stdlib/@python2/multiprocessing/pool.pyi @@ -1,26 +1,26 @@ -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) 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] = ..., - initializer: Optional[Callable[..., None]] = ..., + processes: int | None = ..., + initializer: Callable[..., None] | 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( @@ -28,19 +28,19 @@ 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: 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] = ..., - callback: Optional[Callable[..., None]] = ..., + chunksize: int | None = ..., + callback: Callable[..., None] | 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: Callable[..., Any] | None = ..., initargs: Iterable[Any] = ... ) -> None: ... diff --git a/stdlib/@python2/multiprocessing/process.pyi b/stdlib/@python2/multiprocessing/process.pyi index 9ab9628e0e32..2cb691342580 100644 --- a/stdlib/@python2/multiprocessing/process.pyi +++ b/stdlib/@python2/multiprocessing/process.pyi @@ -1,16 +1,14 @@ -from typing import Any, Optional +from typing import Any def current_process(): ... def active_children(): ... class Process: - def __init__( - self, group: Optional[Any] = ..., target: Optional[Any] = ..., name: Optional[Any] = ..., 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): ... - 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..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 @@ -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..3033c2f78955 100644 --- a/stdlib/@python2/netrc.pyi +++ b/stdlib/@python2/netrc.pyi @@ -1,10 +1,10 @@ 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]] @@ -12,5 +12,5 @@ _NetrcTuple = Tuple[str, Optional[str], Optional[str]] 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 21b33f55d051..56545d3b88b4 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] @@ -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: ... @@ -52,11 +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 newnews( - self, group: str, date: Union[datetime.date, datetime.datetime], *, file: _File = ... - ) -> Tuple[str, List[str]]: ... - def list(self, group_pattern: Optional[str] = ..., *, 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: 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]]: ... def group(self, name: str) -> Tuple[str, int, int, int, str]: ... @@ -71,16 +69,16 @@ class _NNTPBase: def xhdr(self, hdr: str, str: Any, *, file: _File = ...) -> Tuple[str, List[str]]: ... def xover(self, start: int, end: int, *, file: _File = ...) -> Tuple[str, List[Tuple[int, Dict[str, str]]]]: ... def over( - self, message_spec: Union[None, str, List[Any], Tuple[Any, ...]], *, file: _File = ... + self, message_spec: None | str | List[Any] | Tuple[Any, ...], *, file: _File = ... ) -> Tuple[str, List[Tuple[int, Dict[str, str]]]]: ... def xgtitle(self, group: str, *, file: _File = ...) -> Tuple[str, List[Tuple[str, str]]]: ... def xpath(self, id: Any) -> Tuple[str, str]: ... def date(self) -> Tuple[str, datetime.datetime]: ... - def post(self, data: Union[bytes, Iterable[bytes]]) -> str: ... - def ihave(self, message_id: Any, data: Union[bytes, Iterable[bytes]]) -> str: ... + def post(self, data: bytes | Iterable[bytes]) -> str: ... + def ihave(self, message_id: Any, data: bytes | Iterable[bytes]) -> str: ... def quit(self) -> str: ... - def login(self, user: Optional[str] = ..., password: Optional[str] = ..., usenetrc: bool = ...) -> None: ... - def starttls(self, context: Optional[ssl.SSLContext] = ...) -> None: ... + def login(self, user: str | None = ..., password: str | None = ..., usenetrc: bool = ...) -> None: ... + def starttls(self, context: ssl.SSLContext | None = ...) -> None: ... class NNTP(_NNTPBase): port: int @@ -89,9 +87,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 +100,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..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") @@ -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..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 @@ -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 62ae8ef8a8bf..08a926e301b3 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, Sequence, Tuple, Type, Union, overload # See https://groups.google.com/forum/#!topic/python-ideas/gA1gdj3RZ5g _Text = Union[str, unicode] @@ -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: ... @@ -79,7 +79,7 @@ class Option: ACTIONS: Tuple[_Text, ...] ALWAYS_TYPED_ACTIONS: Tuple[_Text, ...] ATTRS: List[_Text] - CHECK_METHODS: Optional[List[Callable[..., Any]]] + CHECK_METHODS: List[Callable[..., Any]] | None CONST_ACTIONS: Tuple[_Text, ...] STORE_ACTIONS: Tuple[_Text, ...] TYPED_ACTIONS: Tuple[_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: ... + 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: ... 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,12 +148,12 @@ 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: ... 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: ... @@ -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]] + largs: List[_Text] | None option_groups: List[OptionGroup] option_list: List[Option] process_default_values: Any - prog: Optional[_Text] - rargs: Optional[List[Any]] + prog: _Text | None + rargs: List[Any] | None 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] = ..., - option_list: Optional[Iterable[Option]] = ..., + usage: _Text | None = ..., + option_list: Iterable[Option] | None = ..., 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,22 +209,20 @@ 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] = ... - ) -> 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 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: ... 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 3b4f9698dd14..1955c07020de 100644 --- a/stdlib/@python2/os/__init__.pyi +++ b/stdlib/@python2/os/__init__.pyi @@ -15,7 +15,6 @@ from typing import ( MutableMapping, NamedTuple, NoReturn, - Optional, Sequence, Text, Tuple, @@ -77,7 +76,7 @@ sep: str if sys.platform == "win32": altsep: str else: - altsep: Optional[str] + altsep: str | None extsep: str pathsep: str defpath: str @@ -185,11 +184,11 @@ 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) -> 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 +200,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: ... @@ -231,7 +230,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 @@ -239,7 +238,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,21 +253,21 @@ 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( - top: AnyStr, topdown: bool = ..., onerror: Optional[Callable[[OSError], Any]] = ..., followlinks: bool = ... + top: AnyStr, topdown: bool = ..., onerror: Callable[[OSError], Any] | None = ..., followlinks: bool = ... ) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... 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. @@ -293,24 +292,24 @@ 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]: ... 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 - 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 +321,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) -> str | None: ... 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/os/path.pyi b/stdlib/@python2/os/path.pyi index 124385f1301d..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") @@ -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..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") @@ -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 ba04e4d28fab..6d3a6d5c5903 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 _T = TypeVar("_T") @@ -9,12 +9,12 @@ line_prefix: str # undocumented class Restart(Exception): ... -def run(statement: str, globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ...) -> None: ... -def runeval(expression: str, globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ...) -> Any: ... +def run(statement: str, globals: Dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> None: ... +def runeval(expression: str, globals: Dict[str, Any] | None = ..., locals: Mapping[str, Any] | None = ...) -> Any: ... def runctx(statement: str, globals: Dict[str, Any], locals: Mapping[str, Any]) -> None: ... -def runcall(func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ... +def runcall(func: Callable[..., _T], *args: Any, **kwds: Any) -> _T | None: ... 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,64 +30,60 @@ class Pdb(Bdb, Cmd): commands_doprompt: Dict[int, bool] commands_silent: Dict[int, bool] commands_defining: bool - commands_bnum: Optional[int] - lineno: Optional[int] + commands_bnum: int | None + lineno: int | None stack: List[Tuple[FrameType, int]] curindex: int - curframe: Optional[FrameType] + curframe: FrameType | None curframe_locals: Mapping[str, Any] def __init__( - self, - completekey: str = ..., - stdin: Optional[IO[str]] = ..., - stdout: Optional[IO[str]] = ..., - skip: Optional[Iterable[str]] = ..., + self, completekey: str = ..., stdin: IO[str] | None = ..., stdout: IO[str] | None = ..., skip: Iterable[str] | None = ... ) -> None: ... def forget(self) -> None: ... - def setup(self, f: Optional[FrameType], tb: Optional[TracebackType]) -> None: ... + def setup(self, f: FrameType | None, tb: TracebackType | None) -> None: ... def execRcLines(self) -> None: ... def bp_commands(self, frame: FrameType) -> bool: ... - def interaction(self, frame: Optional[FrameType], traceback: Optional[TracebackType]) -> None: ... + def interaction(self, frame: FrameType | None, traceback: TracebackType | None) -> None: ... def displayhook(self, obj: object) -> None: ... def handle_command_def(self, line: str) -> bool: ... def defaultFile(self) -> str: ... - def lineinfo(self, identifier: str) -> Union[Tuple[None, None, None], Tuple[str, str, int]]: ... + def lineinfo(self, identifier: str) -> Tuple[None, None, None] | Tuple[str, str, int]: ... def checkline(self, filename: str, lineno: int) -> int: ... def _getval(self, arg: str) -> object: ... def print_stack_trace(self) -> None: ... def print_stack_entry(self, frame_lineno: Tuple[FrameType, int], prompt_prefix: str = ...) -> None: ... - def lookupmodule(self, filename: str) -> Optional[str]: ... + def lookupmodule(self, filename: str) -> str | None: ... def _runscript(self, filename: str) -> None: ... - def do_commands(self, arg: str) -> Optional[bool]: ... - def do_break(self, arg: str, temporary: bool = ...) -> Optional[bool]: ... - def do_tbreak(self, arg: str) -> Optional[bool]: ... - def do_enable(self, arg: str) -> Optional[bool]: ... - def do_disable(self, arg: str) -> Optional[bool]: ... - def do_condition(self, arg: str) -> Optional[bool]: ... - def do_ignore(self, arg: str) -> Optional[bool]: ... - def do_clear(self, arg: str) -> Optional[bool]: ... - def do_where(self, arg: str) -> Optional[bool]: ... - def do_up(self, arg: str) -> Optional[bool]: ... - def do_down(self, arg: str) -> Optional[bool]: ... - def do_until(self, arg: str) -> Optional[bool]: ... - def do_step(self, arg: str) -> Optional[bool]: ... - def do_next(self, arg: str) -> Optional[bool]: ... - def do_run(self, arg: str) -> Optional[bool]: ... - def do_return(self, arg: str) -> Optional[bool]: ... - def do_continue(self, arg: str) -> Optional[bool]: ... - def do_jump(self, arg: str) -> Optional[bool]: ... - def do_debug(self, arg: str) -> Optional[bool]: ... - def do_quit(self, arg: str) -> Optional[bool]: ... - def do_EOF(self, arg: str) -> Optional[bool]: ... - def do_args(self, arg: str) -> Optional[bool]: ... - def do_retval(self, arg: str) -> Optional[bool]: ... - def do_p(self, arg: str) -> Optional[bool]: ... - def do_pp(self, arg: str) -> Optional[bool]: ... - def do_list(self, arg: str) -> Optional[bool]: ... - def do_whatis(self, arg: str) -> Optional[bool]: ... - def do_alias(self, arg: str) -> Optional[bool]: ... - def do_unalias(self, arg: str) -> Optional[bool]: ... - def do_help(self, arg: str) -> Optional[bool]: ... + def do_commands(self, arg: str) -> bool | None: ... + def do_break(self, arg: str, temporary: bool = ...) -> bool | None: ... + def do_tbreak(self, arg: str) -> bool | None: ... + def do_enable(self, arg: str) -> bool | None: ... + def do_disable(self, arg: str) -> bool | None: ... + def do_condition(self, arg: str) -> bool | None: ... + def do_ignore(self, arg: str) -> bool | None: ... + def do_clear(self, arg: str) -> bool | None: ... + def do_where(self, arg: str) -> bool | None: ... + def do_up(self, arg: str) -> bool | None: ... + def do_down(self, arg: str) -> bool | None: ... + def do_until(self, arg: str) -> bool | None: ... + def do_step(self, arg: str) -> bool | None: ... + def do_next(self, arg: str) -> bool | None: ... + def do_run(self, arg: str) -> bool | None: ... + def do_return(self, arg: str) -> bool | None: ... + def do_continue(self, arg: str) -> bool | None: ... + def do_jump(self, arg: str) -> bool | None: ... + def do_debug(self, arg: str) -> bool | None: ... + def do_quit(self, arg: str) -> bool | None: ... + def do_EOF(self, arg: str) -> bool | None: ... + def do_args(self, arg: str) -> bool | None: ... + def do_retval(self, arg: str) -> bool | None: ... + def do_p(self, arg: str) -> bool | None: ... + def do_pp(self, arg: str) -> bool | None: ... + def do_list(self, arg: str) -> bool | None: ... + def do_whatis(self, arg: str) -> bool | None: ... + def do_alias(self, arg: str) -> bool | None: ... + def do_unalias(self, arg: str) -> bool | None: ... + def do_help(self, arg: str) -> bool | None: ... do_b = do_break do_cl = do_clear do_w = do_where @@ -161,7 +157,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 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 154aaf174f5d..14ec0fdff03a 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 _Reader = Callable[[IO[bytes]], Any] @@ -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 @@ -77,9 +77,9 @@ long4: ArgumentDescriptor class StackObject(object): name: str - obtype: Union[Type[Any], Tuple[Type[Any], ...]] + obtype: Type[Any] | Tuple[Type[Any], ...] doc: str - def __init__(self, name: str, obtype: Union[Type[Any], Tuple[Type[Any], ...]], doc: str) -> None: ... + def __init__(self, name: str, obtype: Type[Any] | Tuple[Type[Any], ...], doc: str) -> None: ... pyint: StackObject pylong: StackObject @@ -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,11 +117,8 @@ class OpcodeInfo(object): opcodes: List[OpcodeInfo] -def genops(pickle: Union[bytes, IO[bytes]]) -> Iterator[Tuple[OpcodeInfo, Optional[Any], Optional[int]]]: ... -def optimize(p: Union[bytes, IO[bytes]]) -> bytes: ... +def genops(pickle: bytes | IO[bytes]) -> Iterator[Tuple[OpcodeInfo, Any | None, int | None]]: ... +def optimize(p: bytes | IO[bytes]) -> bytes: ... def dis( - pickle: Union[bytes, IO[bytes]], - out: Optional[IO[str]] = ..., - memo: Optional[MutableMapping[int, Any]] = ..., - indentlevel: int = ..., + pickle: bytes | IO[bytes], 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 5fefef39bd6b..fd42af916cfe 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, Tuple, Union Loader = Any MetaPathFinder = Any @@ -10,18 +10,18 @@ _ModuleInfoLike = Tuple[Union[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[Union[MetaPathFinder, PathEntryFinder]]: ... -def iter_modules(path: Optional[Iterable[str]] = ..., prefix: str = ...) -> Iterator[_ModuleInfoLike]: ... +def iter_importers(fullname: str = ...) -> Iterator[MetaPathFinder | PathEntryFinder]: ... +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: Callable[[str], None] | 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..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 @@ -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/plistlib.pyi b/stdlib/@python2/plistlib.pyi index 23115812ad69..d815e3c35404 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 = Union[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/popen2.pyi b/stdlib/@python2/popen2.pyi index b37a71085bf4..0efee4e6d271 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 _T = TypeVar("_T") @@ -8,10 +8,10 @@ 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 = ...) -> Union[int, _T]: ... + def poll(self, _deadstate: _T = ...) -> int | _T: ... def wait(self) -> int: ... class Popen4(Popen3): diff --git a/stdlib/@python2/poplib.pyi b/stdlib/@python2/poplib.pyi index 603093d419a2..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] @@ -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/posix.pyi b/stdlib/@python2/posix.pyi index ae79286ec50d..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, Optional, Sequence, Tuple, TypeVar, Union +from typing import IO, AnyStr, Dict, List, Mapping, NamedTuple, Sequence, Tuple, TypeVar error = OSError @@ -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: ... @@ -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/posixpath.pyi b/stdlib/@python2/posixpath.pyi index 07bd9653efd9..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") @@ -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..407a9afb8e47 100644 --- a/stdlib/@python2/pprint.pyi +++ b/stdlib/@python2/pprint.pyi @@ -1,17 +1,15 @@ -from typing import IO, Any, Dict, Optional, Tuple +from typing import IO, Any, Dict, 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: IO[str] | None = ..., indent: int = ..., width: int = ..., depth: int | None = ... ) -> None: ... def isreadable(object: object) -> bool: ... def isrecursive(object: object) -> bool: ... def saferepr(object: object) -> str: ... class PrettyPrinter: - def __init__( - self, indent: int = ..., width: int = ..., depth: Optional[int] = ..., stream: Optional[IO[str]] = ... - ) -> 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/profile.pyi b/stdlib/@python2/profile.pyi index e799c6b36e2f..08e9b906dd0d 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 +from typing import Any, Callable, Dict, Text, Tuple, TypeVar -def run(statement: str, filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ... +def run(statement: str, filename: str | None = ..., sort: str | int = ...) -> None: ... def runctx( - statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: Optional[str] = ..., sort: Union[str, int] = ... + statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: str | None = ..., sort: str | int = ... ) -> None: ... _SelfT = TypeVar("_SelfT", bound=Profile) @@ -12,11 +12,11 @@ _Label = Tuple[str, int, str] class Profile: bias: int stats: dict[_Label, tuple[int, int, int, int, dict[_Label, tuple[int, int, int, int]]]] # undocumented - def __init__(self, timer: Optional[Callable[[], float]] = ..., bias: Optional[int] = ...) -> None: ... + def __init__(self, timer: Callable[[], float] | None = ..., bias: int | None = ...) -> None: ... def set_cmd(self, cmd: str) -> None: ... def simulate_call(self, name: str) -> None: ... def simulate_cmd_complete(self) -> None: ... - def print_stats(self, sort: Union[str, int] = ...) -> None: ... + def print_stats(self, sort: str | int = ...) -> None: ... def dump_stats(self, file: Text) -> None: ... def create_stats(self) -> None: ... def snapshot_stats(self) -> None: ... diff --git a/stdlib/@python2/pstats.pyi b/stdlib/@python2/pstats.pyi index d1404dc7c01a..cecd1e84e305 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 = Union[str, float, int] _T = TypeVar("_T", bound=Stats) @@ -9,14 +9,14 @@ class Stats: sort_arg_dict_default: Dict[str, Tuple[Any, str]] def __init__( self: _T, - __arg: Union[None, str, Text, Profile, _cProfile] = ..., - *args: Union[None, str, Text, Profile, _cProfile, _T], - stream: Optional[IO[Any]] = ..., + __arg: None | str | Text | Profile | _cProfile = ..., + *args: None | str | Text | Profile | _cProfile | _T, + 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: ... + def init(self, arg: None | str | Text | Profile | _cProfile) -> None: ... + def load_stats(self, arg: None | str | Text | Profile | _cProfile) -> None: ... def get_top_level_stats(self) -> None: ... - def add(self: _T, *arg_list: Union[None, str, Text, Profile, _cProfile, _T]) -> _T: ... + def add(self: _T, *arg_list: None | str | Text | Profile | _cProfile | _T) -> _T: ... def dump_stats(self, filename: Text) -> None: ... def get_sort_arg_defs(self) -> Dict[str, Tuple[Tuple[Tuple[int, int], ...], str]]: ... @overload diff --git a/stdlib/@python2/pty.pyi b/stdlib/@python2/pty.pyi index 93983690fff4..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] @@ -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/py_compile.pyi b/stdlib/@python2/py_compile.pyi index 94a8ace8e69a..44905b43da33 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 = Union[bytes, Text] @@ -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: Optional[_EitherStr] = ..., dfile: Optional[_EitherStr] = ..., doraise: bool = ... -) -> None: ... -def main(args: Optional[List[Text]] = ...) -> int: ... +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/pyclbr.pyi b/stdlib/@python2/pyclbr.pyi index 855a2963c453..893079901665 100644 --- a/stdlib/@python2/pyclbr.pyi +++ b/stdlib/@python2/pyclbr.pyi @@ -1,13 +1,13 @@ -from typing import Dict, List, Optional, Sequence, Union +from typing import Dict, List, Sequence class Class: module: str name: str - super: Optional[List[Union[Class, str]]] + super: List[Class | str] | None methods: Dict[str, int] file: int lineno: int - def __init__(self, module: str, name: str, super: Optional[List[Union[Class, str]]], file: str, lineno: int) -> None: ... + def __init__(self, module: str, name: str, super: List[Class | str] | None, file: str, lineno: int) -> None: ... class Function: module: str @@ -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, Union[Class, Function, List[str]]]: ... +def readmodule(module: str, path: Sequence[str] | None = ...) -> Dict[str, Class]: ... +def readmodule_ex(module: str, path: Sequence[str] | None = ...) -> Dict[str, Class | Function | List[str]]: ... diff --git a/stdlib/@python2/pydoc.pyi b/stdlib/@python2/pydoc.pyi index 857ed5a82c63..dee0c4710b39 100644 --- a/stdlib/@python2/pydoc.pyi +++ b/stdlib/@python2/pydoc.pyi @@ -15,7 +15,6 @@ from typing import ( Text, Tuple, Type, - Union, ) from repr import Repr @@ -37,17 +36,17 @@ def replace(text: AnyStr, *pairs: AnyStr) -> AnyStr: ... def cram(text: str, maxlen: int) -> str: ... def stripid(text: str) -> str: ... def allmethods(cl: type) -> MutableMapping[str, MethodType]: ... -def visiblename(name: str, all: Optional[Container[str]] = ..., obj: Optional[object] = ...) -> bool: ... +def visiblename(name: str, all: Container[str] | None = ..., obj: object | None = ...) -> bool: ... def classify_class_attrs(object: object) -> List[Tuple[str, str, type, str]]: ... def ispackage(path: str) -> bool: ... -def source_synopsis(file: IO[AnyStr]) -> Optional[AnyStr]: ... -def synopsis(filename: str, cache: MutableMapping[str, Tuple[int, str]] = ...) -> Optional[str]: ... +def source_synopsis(file: IO[AnyStr]) -> AnyStr | None: ... +def synopsis(filename: str, cache: MutableMapping[str, Tuple[int, str]] = ...) -> str | None: ... class ErrorDuringImport(Exception): filename: str - exc: Optional[Type[BaseException]] - value: Optional[BaseException] - tb: Optional[TracebackType] + exc: Type[BaseException] | None + value: BaseException | None + tb: TracebackType | None def __init__(self, filename: str, exc_info: _Exc_Info) -> None: ... def importfile(path: str) -> ModuleType: ... @@ -55,15 +54,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 +92,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: ... @@ -107,20 +106,20 @@ class HTMLDoc(Doc): def markup( self, text: str, - escape: Optional[Callable[[str], str]] = ..., + escape: Callable[[str], str] | None = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., methods: Mapping[str, str] = ..., ) -> str: ... def formattree( - self, tree: List[Union[Tuple[type, Tuple[type, ...]], List[Any]]], modname: str, parent: Optional[type] = ... + self, tree: List[Tuple[type, Tuple[type, ...]] | List[Any]], modname: str, parent: type | None = ... ) -> str: ... - def docmodule(self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., *ignored: Any) -> str: ... + def docmodule(self, object: object, name: str | None = ..., mod: str | None = ..., *ignored: Any) -> str: ... def docclass( self, object: object, - name: Optional[str] = ..., - mod: Optional[str] = ..., + name: str | None = ..., + mod: str | None = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., *ignored: Any, @@ -129,22 +128,22 @@ class HTMLDoc(Doc): def docroutine( self, object: object, - name: Optional[str] = ..., - mod: Optional[str] = ..., + name: str | None = ..., + mod: str | None = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., methods: Mapping[str, str] = ..., - cl: Optional[type] = ..., + cl: type | None = ..., *ignored: Any, ) -> str: ... def docproperty( - self, object: object, name: Optional[str] = ..., mod: Optional[str] = ..., cl: Optional[Any] = ..., *ignored: Any + self, object: object, name: str | None = ..., mod: str | None = ..., cl: Any | None = ..., *ignored: Any ) -> str: ... - def docother(self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., *ignored: Any) -> str: ... + def docother(self, object: object, name: str | None = ..., mod: Any | None = ..., *ignored: Any) -> str: ... def docdata( - self, object: object, name: Optional[str] = ..., mod: Optional[Any] = ..., cl: Optional[Any] = ..., *ignored: Any + self, object: object, name: str | None = ..., mod: Any | None = ..., cl: Any | None = ..., *ignored: Any ) -> str: ... - def index(self, dir: str, shadowed: Optional[MutableMapping[str, bool]] = ...) -> str: ... + def index(self, dir: str, shadowed: MutableMapping[str, bool] | None = ...) -> str: ... def filelink(self, url: str, path: str) -> str: ... class TextRepr(Repr): @@ -165,32 +164,28 @@ class TextDoc(Doc): def indent(self, text: str, prefix: str = ...) -> str: ... def section(self, title: str, contents: str) -> str: ... def formattree( - self, - tree: List[Union[Tuple[type, Tuple[type, ...]], List[Any]]], - modname: str, - parent: Optional[type] = ..., - prefix: str = ..., + self, tree: List[Tuple[type, Tuple[type, ...]] | List[Any]], modname: str, parent: type | None = ..., prefix: str = ... ) -> str: ... - def docmodule(self, object: object, name: 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: ... @@ -209,22 +204,20 @@ 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 doc( - thing: Union[str, object], title: str = ..., forceload: bool = ..., output: Optional[SupportsWrite[str]] = ... -) -> None: ... -def writedoc(thing: Union[str, object], forceload: bool = ...) -> None: ... -def writedocs(dir: str, pkgpath: str = ..., done: Optional[Any] = ...) -> None: ... +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 writedoc(thing: str | object, forceload: bool = ...) -> None: ... +def writedocs(dir: str, pkgpath: str = ..., done: Any | None = ...) -> None: ... class Helper: - keywords: Dict[str, Union[str, Tuple[str, str]]] + keywords: Dict[str, str | Tuple[str, str]] symbols: Dict[str, str] - topics: Dict[str, Union[str, Tuple[str, ...]]] - def __init__(self, input: Optional[IO[str]] = ..., output: Optional[IO[str]] = ...) -> None: ... + topics: Dict[str, str | Tuple[str, ...]] + def __init__(self, input: IO[str] | None = ..., output: IO[str] | None = ...) -> None: ... input: IO[str] output: IO[str] - def __call__(self, request: Union[str, Helper, object] = ...) -> None: ... + def __call__(self, request: str | Helper | object = ...) -> None: ... def interact(self) -> None: ... def getline(self, prompt: str) -> str: ... def help(self, request: Any) -> None: ... @@ -252,14 +245,14 @@ class ModuleScanner: quit: bool def run( self, - callback: Callable[[Optional[str], str, str], None], - key: Optional[Any] = ..., - completer: Optional[Callable[[], None]] = ..., - onerror: Optional[Callable[[str], None]] = ..., + callback: Callable[[str | None, str, str], None], + key: Any | None = ..., + completer: Callable[[], None] | None = ..., + onerror: Callable[[str], None] | None = ..., ) -> None: ... def apropos(key: str) -> None: ... def ispath(x: Any) -> bool: ... def cli() -> None: ... -def serve(port: int, callback: Optional[Callable[[Any], None]] = ..., completer: Optional[Callable[[], None]] = ...) -> None: ... +def serve(port: int, callback: Callable[[Any], None] | None = ..., completer: Callable[[], None] | None = ...) -> None: ... def gui() -> None: ... diff --git a/stdlib/@python2/pyexpat/__init__.pyi b/stdlib/@python2/pyexpat/__init__.pyi index 65f6b0e9f7de..bd73f850b559 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, Dict, List, Optional, Text, Tuple, Union +from typing import Any, Callable, Dict, List, Optional, Text, Tuple EXPAT_VERSION: str # undocumented version_info: Tuple[int, int, int] # undocumented @@ -22,12 +22,12 @@ XML_PARAM_ENTITY_PARSING_ALWAYS: int _Model = Tuple[int, int, Optional[str], Tuple[Any, ...]] class XMLParserType(object): - def Parse(self, __data: Union[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]: ... - 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,37 +43,33 @@ class XMLParserType(object): CurrentByteIndex: int CurrentColumnNumber: int CurrentLineNumber: int - XmlDeclHandler: Optional[Callable[[str, Optional[str], int], Any]] - StartDoctypeDeclHandler: Optional[Callable[[str, Optional[str], Optional[str], bool], Any]] - EndDoctypeDeclHandler: Optional[Callable[[], Any]] - ElementDeclHandler: Optional[Callable[[str, _Model], Any]] - AttlistDeclHandler: Optional[Callable[[str, str, str, Optional[str], bool], Any]] - StartElementHandler: Optional[ - Union[ - Callable[[str, Dict[str, str]], Any], - Callable[[str, List[str]], Any], - Callable[[str, Union[Dict[str, str]], List[str]], Any], - ] - ] - EndElementHandler: Optional[Callable[[str], Any]] - ProcessingInstructionHandler: Optional[Callable[[str, str], Any]] - CharacterDataHandler: Optional[Callable[[str], Any]] - UnparsedEntityDeclHandler: Optional[Callable[[str, Optional[str], str, Optional[str], str], Any]] - EntityDeclHandler: Optional[Callable[[str, bool, Optional[str], Optional[str], str, Optional[str], Optional[str]], Any]] - NotationDeclHandler: Optional[Callable[[str, Optional[str], str, Optional[str]], Any]] - StartNamespaceDeclHandler: Optional[Callable[[str, str], Any]] - EndNamespaceDeclHandler: Optional[Callable[[str], Any]] - CommentHandler: Optional[Callable[[str], Any]] - StartCdataSectionHandler: Optional[Callable[[], Any]] - EndCdataSectionHandler: Optional[Callable[[], Any]] - DefaultHandler: Optional[Callable[[str], Any]] - DefaultHandlerExpand: Optional[Callable[[str], Any]] - NotStandaloneHandler: Optional[Callable[[], int]] - ExternalEntityRefHandler: Optional[Callable[[str, Optional[str], Optional[str], Optional[str]], int]] + XmlDeclHandler: Callable[[str, str | None, int], Any] | None + StartDoctypeDeclHandler: Callable[[str, str | None, str | None, bool], Any] | None + EndDoctypeDeclHandler: Callable[[], Any] | None + ElementDeclHandler: Callable[[str, _Model], Any] | None + AttlistDeclHandler: Callable[[str, str, str, str | None, bool], Any] | None + StartElementHandler: Callable[[str, Dict[str, str]], Any] | Callable[[str, List[str]], Any] | Callable[ + [str, Dict[str, str], List[str]], Any + ] | None + EndElementHandler: Callable[[str], Any] | None + ProcessingInstructionHandler: Callable[[str, str], Any] | None + CharacterDataHandler: Callable[[str], Any] | None + UnparsedEntityDeclHandler: Callable[[str, str | None, str, str | None, str], Any] | None + EntityDeclHandler: Callable[[str, bool, str | None, str | None, str, str | None, str | None], Any] | None + NotationDeclHandler: Callable[[str, str | None, str, str | None], Any] | None + StartNamespaceDeclHandler: Callable[[str, str], Any] | None + EndNamespaceDeclHandler: Callable[[str], Any] | None + CommentHandler: Callable[[str], Any] | None + StartCdataSectionHandler: Callable[[], Any] | None + EndCdataSectionHandler: Callable[[], Any] | None + DefaultHandler: Callable[[str], Any] | None + DefaultHandlerExpand: Callable[[str], Any] | None + NotStandaloneHandler: Callable[[], int] | None + ExternalEntityRefHandler: Callable[[str, str | None, str | None, str | None], int] | None def ErrorString(__code: int) -> str: ... # intern is undocumented def ParserCreate( - encoding: Optional[Text] = ..., namespace_separator: Optional[Text] = ..., 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 aa770b6b64be..fbe021ce67be 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, overload # ----- re variables and constants ----- DEBUG: int @@ -24,65 +24,59 @@ 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 = ...) -> Match[AnyStr] | None: ... @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 = ...) -> Match[AnyStr] | None: ... @overload -def match(pattern: Union[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: Union[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: 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]: ... +def split(pattern: 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]: ... +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 # 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]]: ... +def finditer(pattern: 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( - pattern: Union[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: Union[Pattern[str], Pattern[unicode]], + pattern: Pattern[str] | Pattern[unicode], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ..., flags: int = ..., ) -> AnyStr: ... @overload -def subn( - pattern: Union[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: 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( - 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 +84,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/readline.pyi b/stdlib/@python2/readline.pyi index 579308f75bc1..fb9b12d9a8e9 100644 --- a/stdlib/@python2/readline.pyi +++ b/stdlib/@python2/readline.pyi @@ -4,12 +4,12 @@ _CompleterT = Optional[Callable[[str, int], Optional[str]]] _CompDispT = Optional[Callable[[str, Sequence[str], int], None]] def parse_and_bind(__string: str) -> None: ... -def read_init_file(__filename: Optional[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: ... @@ -18,8 +18,8 @@ def get_history_item(__index: int) -> str: ... def remove_history_item(__pos: int) -> None: ... def replace_history_item(__pos: int, __line: str) -> None: ... def add_history(__string: str) -> None: ... -def set_startup_hook(__function: Optional[Callable[[], None]] = ...) -> None: ... -def set_pre_input_hook(__function: Optional[Callable[[], None]] = ...) -> None: ... +def set_startup_hook(__function: Callable[[], None] | None = ...) -> None: ... +def set_pre_input_hook(__function: Callable[[], None] | None = ...) -> None: ... def set_completer(__function: _CompleterT = ...) -> None: ... def get_completer() -> _CompleterT: ... def get_completion_type() -> int: ... diff --git a/stdlib/@python2/rfc822.pyi b/stdlib/@python2/rfc822.pyi index f536568b807d..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 @@ -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 a542c45c979b..a61c61eb24f2 100644 --- a/stdlib/@python2/rlcompleter.pyi +++ b/stdlib/@python2/rlcompleter.pyi @@ -1,7 +1,7 @@ -from typing import Any, Dict, Optional, Union +from typing import Any, Dict, Union _Text = Union[str, unicode] class Completer: - def __init__(self, namespace: Optional[Dict[str, Any]] = ...) -> None: ... - def complete(self, text: _Text, state: int) -> Optional[str]: ... + def __init__(self, namespace: Dict[str, Any] | None = ...) -> None: ... + def complete(self, text: _Text, state: int) -> str | None: ... diff --git a/stdlib/@python2/runpy.pyi b/stdlib/@python2/runpy.pyi index 6674af077d5d..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 @@ -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..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 @@ -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: Iterable[kevent] | None, __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/sets.pyi b/stdlib/@python2/sets.pyi index 1ee3e8b26e1b..d2b94ea44bbc 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 = Union[BaseSet[_T], Iterable[_T]] @@ -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/shelve.pyi b/stdlib/@python2/shelve.pyi index 442c3fe3d52e..d9b1a00e58df 100644 --- a/stdlib/@python2/shelve.pyi +++ b/stdlib/@python2/shelve.pyi @@ -1,9 +1,9 @@ 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__( - 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 37c667238f09..89c28fc9be7f 100644 --- a/stdlib/@python2/shlex.pyi +++ b/stdlib/@python2/shlex.pyi @@ -1,14 +1,14 @@ -from typing import IO, Any, List, Optional, Text, TypeVar, Union +from typing import IO, Any, List, Text, TypeVar -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) 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]: ... + 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 ff4467ffc471..4805c8e4cdb7 100644 --- a/stdlib/@python2/shutil.pyi +++ b/stdlib/@python2/shutil.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsRead, SupportsWrite -from typing import Any, AnyStr, Callable, Iterable, List, Optional, Sequence, Set, Text, Tuple, Type, TypeVar, Union +from typing import Any, AnyStr, Callable, Iterable, List, Sequence, Set, Text, Tuple, Type, TypeVar, Union _AnyStr = TypeVar("_AnyStr", str, unicode) _AnyPath = TypeVar("_AnyPath", str, unicode) @@ -17,9 +17,9 @@ def copy(src: Text, dst: Text) -> _PathReturn: ... def copy2(src: Text, dst: Text) -> _PathReturn: ... def ignore_patterns(*patterns: Text) -> Callable[[Any, List[_AnyStr]], Set[_AnyStr]]: ... def copytree( - src: AnyStr, dst: AnyStr, symlinks: bool = ..., ignore: Union[None, Callable[[AnyStr, List[AnyStr]], Iterable[AnyStr]]] = ... + src: AnyStr, dst: AnyStr, symlinks: bool = ..., ignore: None | Callable[[AnyStr, List[AnyStr]], Iterable[AnyStr]] = ... ) -> _PathReturn: ... -def rmtree(path: _AnyPath, ignore_errors: bool = ..., onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ...) -> None: ... +def rmtree(path: _AnyPath, ignore_errors: bool = ..., onerror: Callable[[Any, _AnyPath, Any], Any] | None = ...) -> None: ... _CopyFn = Union[Callable[[str, str], None], Callable[[Text, Text], None]] @@ -27,19 +27,19 @@ 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( name: str, function: Callable[..., Any], - extra_args: Optional[Sequence[Union[Tuple[str, Any], List[Any]]]] = ..., + extra_args: Sequence[Tuple[str, Any] | List[Any]] | None = ..., description: str = ..., ) -> None: ... def unregister_archive_format(name: str) -> None: ... diff --git a/stdlib/@python2/site.pyi b/stdlib/@python2/site.pyi index db7bbefcc794..c77c9397f612 100644 --- a/stdlib/@python2/site.pyi +++ b/stdlib/@python2/site.pyi @@ -1,12 +1,12 @@ -from typing import Iterable, List, Optional +from typing import Iterable, List PREFIXES: List[str] -ENABLE_USER_SITE: Optional[bool] -USER_SITE: Optional[str] -USER_BASE: Optional[str] +ENABLE_USER_SITE: bool | None +USER_SITE: str | None +USER_BASE: str | None def main() -> None: ... -def addsitedir(sitedir: str, known_paths: Optional[Iterable[str]] = ...) -> None: ... -def getsitepackages(prefixes: Optional[Iterable[str]] = ...) -> List[str]: ... +def addsitedir(sitedir: str, known_paths: Iterable[str] | None = ...) -> None: ... +def getsitepackages(prefixes: Iterable[str] | None = ...) -> List[str]: ... def getuserbase() -> str: ... def getusersitepackages() -> str: ... diff --git a/stdlib/@python2/smtpd.pyi b/stdlib/@python2/smtpd.pyi index 33d84ffde4c8..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, Optional, Text, Tuple, Type, Union +from typing import Any, List, Text, Tuple, Type _Address = Tuple[str, int] # (host, port) @@ -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 - ) -> Optional[str]: ... + self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: bytes | str, **kwargs: Any + ) -> str | None: ... class DebuggingServer(SMTPServer): ... class PureProxy(SMTPServer): def process_message( # type: ignore - self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: Union[bytes, str] - ) -> Optional[str]: ... + self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: bytes | str + ) -> str | None: ... class MailmanProxy(PureProxy): def process_message( # type: ignore - self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: Union[bytes, str] - ) -> Optional[str]: ... + self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: bytes | str + ) -> str | None: ... diff --git a/stdlib/@python2/sndhdr.pyi b/stdlib/@python2/sndhdr.pyi index a5ae485c24a2..189529fd21d6 100644 --- a/stdlib/@python2/sndhdr.pyi +++ b/stdlib/@python2/sndhdr.pyi @@ -1,6 +1,6 @@ -from typing import Optional, Text, Tuple, Union +from typing import Text, Tuple, Union _SndHeaders = Tuple[str, int, int, int, Union[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 ea3d47757a77..2bf719dd9faa 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, @@ -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: ... @@ -402,9 +402,9 @@ 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: 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: ... @@ -419,8 +419,8 @@ 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 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: ... if sys.platform == "win32": def share(self, process_id: int) -> bytes: ... def shutdown(self, how: int) -> None: ... @@ -428,16 +428,16 @@ class socket: # ----- Functions ----- def create_connection( - address: Tuple[Optional[str], int], - timeout: Optional[float] = ..., - source_address: Optional[Tuple[Union[bytearray, bytes, Text], int]] = ..., + address: Tuple[str | None, int], + timeout: float | None = ..., + source_address: Tuple[bytearray | bytes | Text, int] | None = ..., ) -> 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: bytearray | bytes | Text | None, + port: str | int | None, family: int = ..., socktype: int = ..., proto: int = ..., @@ -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: ... @@ -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 e89ae080aed0..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, Optional, Protocol, Text, Tuple, Type, TypeVar, Union +from typing import Any, Callable, Generator, Iterable, Iterator, List, Protocol, Text, Tuple, Type, TypeVar _T = TypeVar("_T") @@ -62,17 +62,17 @@ 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] = ..., + 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: ... 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): @@ -106,11 +106,11 @@ 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: ... - 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: ... @@ -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 @@ -143,9 +143,9 @@ class Cursor(Iterator[Any]): def close(self, *args: Any, **kwargs: Any) -> None: ... def execute(self, __sql: str, __parameters: Iterable[Any] = ...) -> Cursor: ... def executemany(self, __sql: str, __seq_of_parameters: Iterable[Iterable[Any]]) -> Cursor: ... - def executescript(self, __sql_script: Union[bytes, Text]) -> 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_compile.pyi b/stdlib/@python2/sre_compile.pyi index 23317a918dad..efc3e568a07c 100644 --- a/stdlib/@python2/sre_compile.pyi +++ b/stdlib/@python2/sre_compile.pyi @@ -12,11 +12,11 @@ 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]] _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/sre_parse.pyi b/stdlib/@python2/sre_parse.pyi index e2a0be4e3bf1..35f6d4d32ae2 100644 --- a/stdlib/@python2/sre_parse.pyi +++ b/stdlib/@python2/sre_parse.pyi @@ -7,7 +7,7 @@ OCTDIGITS: Set[Any] HEXDIGITS: Set[Any] WHITESPACE: Set[Any] ESCAPES: Dict[str, Tuple[str, int]] -CATEGORIES: Dict[str, Union[Tuple[str, str], Tuple[str, List[Tuple[str, str]]]]] +CATEGORIES: Dict[str, Tuple[str, str] | Tuple[str, List[Tuple[str, str]]]] FLAGS: Dict[str, int] class Pattern: @@ -31,13 +31,13 @@ _CodeType = Union[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: ... - 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: ... @@ -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: ... diff --git a/stdlib/@python2/ssl.pyi b/stdlib/@python2/ssl.pyi index b9693fa89768..aabecaaba87a 100644 --- a/stdlib/@python2/ssl.pyi +++ b/stdlib/@python2/ssl.pyi @@ -27,30 +27,30 @@ 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: Union[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] = ..., - cadata: Union[Text, bytes, None] = ..., + certfile: str | None = ..., + keyfile: str | None = ..., + cafile: str | None = ..., + capath: str | None = ..., + cadata: Text | bytes | None = ..., ) -> SSLContext: ... _create_default_https_context: Callable[..., 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] = ..., + npn_protocols: Iterable[str] | None = ..., + ciphers: str | None = ..., + server_hostname: str | None = ..., + _context: SSLContext | None = ..., + _session: Any | None = ..., ) -> 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 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: Union[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 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: ... + 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: @@ -220,19 +220,17 @@ 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: Optional[StrPath] = ..., password: Optional[_PasswordType] = ... - ) -> 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: Optional[StrPath] = ..., capath: Optional[StrPath] = ..., cadata: Union[Text, bytes, None] = ... + self, cafile: StrPath | None = ..., capath: StrPath | None = ..., 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: ... 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 +239,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/string.pyi b/stdlib/@python2/string.pyi index a2b0a9d25ddb..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 @@ -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): @@ -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/stringold.pyi b/stdlib/@python2/stringold.pyi index 271da8357c70..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 @@ -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 28a4c0574419..8c101272322a 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 = ..., @@ -65,38 +65,38 @@ class CalledProcessError(Exception): cmd: Any # morally: Optional[bytes] 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) 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__( cls, args: _CMD, bufsize: int = ..., - executable: Optional[_TXT] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., + executable: _TXT | None = ..., + stdin: _FILE | None = ..., + stdout: _FILE | None = ..., + stderr: _FILE | None = ..., + preexec_fn: Callable[[], Any] | None = ..., 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]: ... + 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 e40ae2181be0..3ee4b9651346 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 = Union[Text, IO[bytes]] @@ -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: ... @@ -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/symtable.pyi b/stdlib/@python2/symtable.pyi index c7b8092aedbb..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: ... @@ -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/sys.pyi b/stdlib/@python2/sys.pyi index 7852911b6532..d4858ec251fa 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] @@ -86,8 +86,8 @@ 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_value: Union[BaseException, ClassType] +exc_type: type | None +exc_value: BaseException | ClassType exc_traceback: TracebackType class _WindowsVersionType: @@ -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 c5f00ee9ea08..2bef9e467bc9 100644 --- a/stdlib/@python2/sysconfig.pyi +++ b/stdlib/@python2/sysconfig.pyi @@ -1,17 +1,17 @@ -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) -> Optional[str]: ... +def get_config_var(name: str) -> str | None: ... @overload def get_config_vars() -> Dict[str, Any]: ... @overload def get_config_vars(arg: str, *args: str) -> List[Any]: ... def get_scheme_names() -> Tuple[str, ...]: ... def get_path_names() -> Tuple[str, ...]: ... -def get_path(name: str, scheme: str = ..., vars: Optional[Dict[str, Any]] = ..., expand: bool = ...) -> str: ... -def get_paths(scheme: str = ..., vars: Optional[Dict[str, Any]] = ..., expand: bool = ...) -> Dict[str, str]: ... +def get_path(name: str, scheme: str = ..., vars: Dict[str, Any] | None = ..., expand: bool = ...) -> str: ... +def get_paths(scheme: str = ..., vars: Dict[str, Any] | None = ..., expand: bool = ...) -> Dict[str, str]: ... def get_python_version() -> str: ... def get_platform() -> str: ... def is_python_build(check_home: bool = ...) -> bool: ... -def parse_config_h(fp: IO[Any], vars: Optional[Dict[str, Any]] = ...) -> Dict[str, Any]: ... +def parse_config_h(fp: IO[Any], vars: Dict[str, Any] | None = ...) -> Dict[str, Any]: ... def get_config_h_filename() -> str: ... def get_makefile_filename() -> str: ... diff --git a/stdlib/@python2/tarfile.pyi b/stdlib/@python2/tarfile.pyi index 169d7d2c89f6..c08c96b6f0d5 100644 --- a/stdlib/@python2/tarfile.pyi +++ b/stdlib/@python2/tarfile.pyi @@ -1,6 +1,6 @@ import io from types import TracebackType -from typing import IO, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Text, Tuple, Type, Union +from typing import IO, Callable, Dict, Iterable, Iterator, List, Mapping, Text, Tuple, Type # tar constants NUL: bytes @@ -50,21 +50,21 @@ TAR_PLAIN: int TAR_GZIPPED: int def open( - name: Optional[Text] = ..., + name: Text | None = ..., mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., + fileobj: IO[bytes] | None = ..., bufsize: int = ..., *, - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., errors: str = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., - compresslevel: Optional[int] = ..., + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., + compresslevel: int | None = ..., ) -> TarFile: ... class ExFileObject(io.BufferedReader): @@ -72,136 +72,136 @@ 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] + fileobj: IO[bytes] | None + format: int | None tarinfo: Type[TarInfo] - dereference: Optional[bool] - ignore_zeros: Optional[bool] - encoding: Optional[str] + dereference: bool | None + ignore_zeros: bool | None + encoding: str | None errors: str fileobject: Type[ExFileObject] - pax_headers: Optional[Mapping[str, str]] - debug: Optional[int] - errorlevel: Optional[int] + pax_headers: Mapping[str, str] | None + debug: int | None + errorlevel: int | None offset: int # undocumented posix: bool def __init__( self, - name: Optional[Text] = ..., + name: Text | None = ..., mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + fileobj: IO[bytes] | None = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., errors: str = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., - copybufsize: Optional[int] = ..., # undocumented + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., + copybufsize: int | None = ..., # undocumented ) -> None: ... def __enter__(self) -> TarFile: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def __iter__(self) -> Iterator[TarInfo]: ... @classmethod def open( cls, - name: Optional[Text] = ..., + name: Text | None = ..., mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., + fileobj: IO[bytes] | None = ..., bufsize: int = ..., *, - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., errors: str = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... @classmethod def taropen( cls, - name: Optional[Text], + name: Text | None, mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., + fileobj: IO[bytes] | None = ..., *, compresslevel: int = ..., - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... @classmethod def gzopen( cls, - name: Optional[Text], + name: Text | None, mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., + fileobj: IO[bytes] | None = ..., compresslevel: int = ..., *, - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... @classmethod def bz2open( cls, - name: Optional[Text], + name: Text | None, mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., + fileobj: IO[bytes] | None = ..., compresslevel: int = ..., *, - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> TarFile: ... @classmethod def xzopen( cls, - name: Optional[Text], + name: Text | None, mode: str = ..., - fileobj: Optional[IO[bytes]] = ..., - preset: Optional[int] = ..., + fileobj: IO[bytes] | None = ..., + preset: int | None = ..., *, - format: Optional[int] = ..., - tarinfo: Optional[Type[TarInfo]] = ..., - dereference: Optional[bool] = ..., - ignore_zeros: Optional[bool] = ..., - encoding: Optional[str] = ..., - pax_headers: Optional[Mapping[str, str]] = ..., - debug: Optional[int] = ..., - errorlevel: Optional[int] = ..., + format: int | None = ..., + tarinfo: Type[TarInfo] | None = ..., + dereference: bool | None = ..., + ignore_zeros: bool | None = ..., + encoding: str | None = ..., + pax_headers: Mapping[str, str] | None = ..., + debug: int | None = ..., + errorlevel: int | None = ..., ) -> 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 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 next(self) -> 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) -> 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 @@ -214,15 +214,13 @@ 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]]] = ..., + exclude: Callable[[str], bool] | None = ..., + filter: Callable[[TarInfo], TarInfo | None] | 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]] = ... - ) -> TarInfo: ... + 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 close(self) -> None: ... def is_tarfile(name: Text) -> bool: ... @@ -248,8 +246,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 @@ -267,15 +265,15 @@ class TarInfo: def linkpath(self) -> str: ... @linkpath.setter def linkpath(self, linkname: str) -> None: ... - def get_info(self) -> Mapping[str, Union[str, int, bytes, Mapping[str, str]]]: ... - def tobuf(self, format: Optional[int] = ..., encoding: Optional[str] = ..., errors: str = ...) -> bytes: ... + def get_info(self) -> Mapping[str, str | int | bytes | Mapping[str, str]]: ... + def tobuf(self, format: int | None = ..., encoding: str | None = ..., errors: str = ...) -> bytes: ... def create_ustar_header( - self, info: Mapping[str, Union[str, int, bytes, Mapping[str, str]]], encoding: str, errors: str + self, info: Mapping[str, str | int | bytes | Mapping[str, str]], encoding: str, errors: str ) -> bytes: ... def create_gnu_header( - self, info: Mapping[str, Union[str, int, bytes, Mapping[str, str]]], encoding: str, errors: str + self, info: Mapping[str, str | int | bytes | Mapping[str, str]], encoding: str, errors: str ) -> bytes: ... - def create_pax_header(self, info: Mapping[str, Union[str, int, bytes, Mapping[str, str]]], encoding: str) -> bytes: ... + def create_pax_header(self, info: Mapping[str, str | int | bytes | Mapping[str, str]], encoding: str) -> bytes: ... @classmethod def create_pax_global_header(cls, pax_headers: Mapping[str, str]) -> bytes: ... def isfile(self) -> bool: ... diff --git a/stdlib/@python2/telnetlib.pyi b/stdlib/@python2/telnetlib.pyi index 388e5a8c9310..dfb01f26398e 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, Pattern, Sequence, Tuple DEBUGLEVEL: int TELNET_PORT: int @@ -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: ... @@ -98,7 +98,7 @@ class Telnet: def read_lazy(self) -> bytes: ... def read_very_lazy(self) -> bytes: ... def read_sb_data(self) -> bytes: ... - def set_option_negotiation_callback(self, callback: Optional[Callable[[socket.socket, bytes, bytes], Any]]) -> None: ... + def set_option_negotiation_callback(self, callback: Callable[[socket.socket, bytes, bytes], Any] | None) -> None: ... def process_rawq(self) -> None: ... def rawq_getchar(self) -> bytes: ... def fill_rawq(self) -> None: ... @@ -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] = ... - ) -> Tuple[int, Optional[Match[bytes]], bytes]: ... + self, list: Sequence[Pattern[bytes] | bytes], timeout: float | None = ... + ) -> Tuple[int, Match[bytes] | None, bytes]: ... diff --git a/stdlib/@python2/tempfile.pyi b/stdlib/@python2/tempfile.pyi index 9ea5e2ecba60..c5f67d243ac8 100644 --- a/stdlib/@python2/tempfile.pyi +++ b/stdlib/@python2/tempfile.pyi @@ -1,11 +1,11 @@ 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, overload 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: ... @@ -51,34 +51,32 @@ 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: Optional[Union[bytes, unicode]] = ..., + suffix: bytes | unicode = ..., + prefix: bytes | unicode = ..., + dir: bytes | unicode | None = ..., ) -> _TemporaryFileWrapper: ... def NamedTemporaryFile( - mode: Union[bytes, unicode] = ..., + mode: bytes | unicode = ..., bufsize: int = ..., - suffix: Union[bytes, unicode] = ..., - prefix: Union[bytes, unicode] = ..., - dir: Optional[Union[bytes, unicode]] = ..., + suffix: bytes | unicode = ..., + prefix: bytes | unicode = ..., + dir: bytes | unicode | None = ..., 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: Optional[Union[bytes, unicode]] = ..., + suffix: bytes | unicode = ..., + prefix: bytes | unicode = ..., + dir: bytes | unicode | None = ..., ) -> _TemporaryFileWrapper: ... class TemporaryDirectory: name: Any - def __init__( - self, suffix: Union[bytes, unicode] = ..., prefix: Union[bytes, unicode] = ..., dir: Union[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: ... @@ -86,17 +84,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 bab2acdc84cd..e45a1b5c4a89 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, Optional, Text, Type, TypeVar # TODO recursive type _TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] @@ -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] = ..., + 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: ... - 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: Type[BaseException] | None, 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,22 +63,22 @@ class _RLock: def __init__(self) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> bool: ... def release(self) -> None: ... RLock = _RLock class Condition: - def __init__(self, lock: Union[Lock, _RLock, None] = ...) -> None: ... + def __init__(self, lock: Lock | _RLock | None = ...) -> None: ... def __enter__(self) -> bool: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] - ) -> Optional[bool]: ... + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def acquire(self, blocking: bool = ...) -> 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: 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: ... 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 0a5353fca9c6..48ae9da9c65e 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 _TimeTuple = Tuple[int, int, int, int, int, int, int, int, int] @@ -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 ctime(secs: float | None = ...) -> str: ... +def gmtime(secs: float | None = ...) -> struct_time: ... +def localtime(secs: float | None = ...) -> struct_time: ... +def mktime(t: _TimeTuple | struct_time) -> float: ... def sleep(secs: float) -> None: ... -def strftime(format: str, t: Union[_TimeTuple, struct_time] = ...) -> str: ... +def strftime(format: str, t: _TimeTuple | struct_time = ...) -> str: ... def strptime(string: str, format: str = ...) -> struct_time: ... def time() -> float: ... diff --git a/stdlib/@python2/timeit.pyi b/stdlib/@python2/timeit.pyi index dfb6a7b731ae..ecb528725a9c 100644 --- a/stdlib/@python2/timeit.pyi +++ b/stdlib/@python2/timeit.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, List, Optional, Sequence, Text, Union +from typing import IO, Any, Callable, List, Sequence, Text, Union _str = Union[str, Text] _Timer = Callable[[], float] @@ -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: Callable[[_timerFunc], _timerFunc] | None = ...) -> None: ... diff --git a/stdlib/@python2/trace.pyi b/stdlib/@python2/trace.pyi index 810639869e20..62f228673a55 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]] @@ -9,16 +9,16 @@ _fileModuleFunction = Tuple[str, Optional[str], str] class CoverageResults: def __init__( self, - counts: Optional[Dict[Tuple[str, int], int]] = ..., - calledfuncs: Optional[Dict[_fileModuleFunction, int]] = ..., - infile: Optional[StrPath] = ..., - callers: Optional[Dict[Tuple[_fileModuleFunction, _fileModuleFunction], int]] = ..., - outfile: Optional[StrPath] = ..., + counts: Dict[Tuple[str, int], int] | None = ..., + calledfuncs: Dict[_fileModuleFunction, int] | None = ..., + infile: StrPath | None = ..., + callers: Dict[Tuple[_fileModuleFunction, _fileModuleFunction], int] | None = ..., + outfile: StrPath | None = ..., ) -> None: ... # undocumented def update(self, other: CoverageResults) -> None: ... - def write_results(self, show_missing: bool = ..., summary: bool = ..., coverdir: Optional[StrPath] = ...) -> None: ... + def write_results(self, show_missing: bool = ..., summary: bool = ..., coverdir: StrPath | None = ...) -> None: ... def write_results_file( - self, path: StrPath, lines: Sequence[str], lnotab: Any, lines_hit: Mapping[int, int], encoding: Optional[str] = ... + self, path: StrPath, lines: Sequence[str], lnotab: Any, lines_hit: Mapping[int, int], encoding: str | None = ... ) -> Tuple[int, int]: ... class Trace: @@ -30,16 +30,13 @@ class Trace: countcallers: int = ..., ignoremods: Sequence[str] = ..., ignoredirs: Sequence[str] = ..., - infile: Optional[StrPath] = ..., - outfile: Optional[StrPath] = ..., + infile: StrPath | None = ..., + outfile: StrPath | None = ..., timing: bool = ..., ) -> None: ... - def run(self, cmd: Union[str, types.CodeType]) -> None: ... + def run(self, cmd: str | types.CodeType) -> None: ... def runctx( - self, - cmd: Union[str, types.CodeType], - globals: Optional[Mapping[str, Any]] = ..., - locals: Optional[Mapping[str, Any]] = ..., + 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/traceback.pyi b/stdlib/@python2/traceback.pyi index 3144fdd6700b..2152ab255942 100644 --- a/stdlib/@python2/traceback.pyi +++ b/stdlib/@python2/traceback.pyi @@ -3,25 +3,25 @@ from typing import IO, List, Optional, Tuple, Type _PT = Tuple[str, int, str, Optional[str]] -def print_tb(tb: Optional[TracebackType], limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... +def print_tb(tb: TracebackType | None, limit: int | None = ..., file: IO[str] | None = ...) -> None: ... def print_exception( - etype: Optional[Type[BaseException]], - value: Optional[BaseException], - tb: Optional[TracebackType], - limit: Optional[int] = ..., - file: Optional[IO[str]] = ..., + etype: Type[BaseException] | None, + value: BaseException | None, + tb: TracebackType | None, + limit: int | None = ..., + file: IO[str] | None = ..., ) -> 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: 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: Optional[BaseException]) -> List[str]: ... +def format_exception_only(etype: Type[BaseException] | None, value: BaseException | None) -> List[str]: ... def format_exception( - etype: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[TracebackType], limit: Optional[int] = ... + etype: Type[BaseException] | None, value: BaseException | None, tb: TracebackType | None, limit: int | None = ... ) -> 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 6476c9de04ff..659dfd31b161 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 @@ -33,8 +33,8 @@ class Terminator(Exception): ... class TurtleGraphicsError(Exception): ... class Shape(object): - def __init__(self, type_: str, data: Union[_PolygonCoords, PhotoImage, None] = ...) -> None: ... - def addcomponent(self, poly: _PolygonCoords, fill: _Color, outline: Optional[_Color] = ...) -> None: ... + def __init__(self, type_: str, data: _PolygonCoords | PhotoImage | None = ...) -> None: ... + def addcomponent(self, poly: _PolygonCoords, fill: _Color, outline: _Color | None = ...) -> None: ... class TurtleScreen(TurtleScreenBase): def __init__(self, cv: Canvas, mode: str = ..., colormode: float = ..., delay: int = ...) -> None: ... @@ -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 @@ -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 @@ -112,16 +112,16 @@ class TNavigator(object): def setx(self, x: float) -> None: ... def sety(self, y: float) -> None: ... @overload - def distance(self, x: Union[TNavigator, Tuple[float, float]], y: None = ...) -> float: ... + def distance(self, x: TNavigator | Tuple[float, float], y: None = ...) -> float: ... @overload def distance(self, x: float, y: float) -> float: ... @overload - def towards(self, x: Union[TNavigator, Tuple[float, float]], y: None = ...) -> float: ... + def towards(self, x: TNavigator | Tuple[float, float], y: None = ...) -> float: ... @overload def towards(self, x: float, y: float) -> float: ... def heading(self) -> float: ... def setheading(self, to_angle: float) -> None: ... - def circle(self, radius: float, extent: Optional[float] = ..., steps: Optional[int] = ...) -> None: ... + def circle(self, radius: float, extent: float | None = ..., steps: int | None = ...) -> None: ... fd = forward bk = back backward = back @@ -178,7 +178,7 @@ class TPen(object): @overload def pen( self, - pen: Optional[_PenState] = ..., + pen: _PenState | None = ..., *, shown: bool = ..., pendown: bool = ..., @@ -203,10 +203,10 @@ _T = TypeVar("_T") class RawTurtle(TPen, TNavigator): def __init__( - self, canvas: Union[Canvas, TurtleScreen, None] = ..., shape: str = ..., undobuffersize: int = ..., visible: bool = ... + self, canvas: Canvas | TurtleScreen | None = ..., shape: str = ..., undobuffersize: int = ..., visible: bool = ... ) -> None: ... def reset(self) -> None: ... - def setundobuffer(self, size: Optional[int]) -> None: ... + def setundobuffer(self, size: int | None) -> None: ... def undobufferentries(self) -> int: ... def clear(self) -> None: ... def clone(self: _T) -> _T: ... @@ -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 @@ -231,22 +231,22 @@ class RawTurtle(TPen, TNavigator): # a compound stamp or not. So, as per the "no Union return" policy, # we return Any. def stamp(self) -> Any: ... - def clearstamp(self, stampid: Union[int, Tuple[int, ...]]) -> None: ... - def clearstamps(self, n: Optional[int] = ...) -> None: ... + def clearstamp(self, stampid: int | Tuple[int, ...]) -> None: ... + def clearstamps(self, n: int | None = ...) -> None: ... def filling(self) -> bool: ... def begin_fill(self) -> None: ... def end_fill(self) -> None: ... - def dot(self, size: Optional[int] = ..., *color: _Color) -> None: ... + def dot(self, size: int | None = ..., *color: _Color) -> None: ... def write(self, arg: object, move: bool = ..., align: str = ..., font: Tuple[str, int, str] = ...) -> None: ... def begin_poly(self) -> None: ... def end_poly(self) -> None: ... - def get_poly(self) -> Optional[_PolygonCoords]: ... + def get_poly(self) -> _PolygonCoords | None: ... def getscreen(self) -> TurtleScreen: ... def getturtle(self: _T) -> _T: ... getpen = getturtle - def onclick(self, fun: Callable[[float, float], Any], btn: int = ..., add: Optional[bool] = ...) -> None: ... - def onrelease(self, fun: Callable[[float, float], Any], btn: int = ..., add: Optional[bool] = ...) -> None: ... - def ondrag(self, fun: Callable[[float, float], Any], btn: int = ..., add: Optional[bool] = ...) -> None: ... + def onclick(self, fun: Callable[[float, float], Any], btn: int = ..., add: bool | None = ...) -> None: ... + def onrelease(self, fun: Callable[[float, float], Any], btn: int = ..., add: bool | None = ...) -> None: ... + def ondrag(self, fun: Callable[[float, float], Any], btn: int = ..., add: bool | None = ...) -> None: ... def undo(self) -> None: ... turtlesize = shapesize @@ -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: Union[int, float] = ..., - height: Union[int, float] = ..., - startx: Optional[int] = ..., - starty: Optional[int] = ..., + self, width: int | float = ..., height: int | float = ..., startx: int | None = ..., starty: int | None = ... ) -> None: ... def title(self, titlestring: str) -> None: ... def bye(self) -> None: ... @@ -295,7 +291,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 @@ -311,7 +307,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 +317,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 +328,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 +336,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: ... @@ -365,16 +361,16 @@ def home() -> None: ... def setx(x: float) -> None: ... def sety(y: float) -> None: ... @overload -def distance(x: Union[TNavigator, Tuple[float, float]], y: None = ...) -> float: ... +def distance(x: TNavigator | Tuple[float, float], y: None = ...) -> float: ... @overload def distance(x: float, y: float) -> float: ... @overload -def towards(x: Union[TNavigator, Tuple[float, float]], y: None = ...) -> float: ... +def towards(x: TNavigator | Tuple[float, float], y: None = ...) -> float: ... @overload def towards(x: float, y: float) -> float: ... def heading() -> float: ... def setheading(to_angle: float) -> None: ... -def circle(radius: float, extent: Optional[float] = ..., steps: Optional[int] = ...) -> None: ... +def circle(radius: float, extent: float | None = ..., steps: int | None = ...) -> None: ... fd = forward bk = back @@ -431,7 +427,7 @@ def isvisible() -> bool: ... def pen() -> _PenState: ... # type: ignore @overload def pen( - pen: Optional[_PenState] = ..., + pen: _PenState | None = ..., *, shown: bool = ..., pendown: bool = ..., @@ -455,7 +451,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 +462,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: ... @@ -478,23 +474,23 @@ def tilt(angle: float) -> None: ... # a compound stamp or not. So, as per the "no Union return" policy, # we return Any. def stamp() -> Any: ... -def clearstamp(stampid: Union[int, Tuple[int, ...]]) -> None: ... -def clearstamps(n: Optional[int] = ...) -> None: ... +def clearstamp(stampid: int | Tuple[int, ...]) -> None: ... +def clearstamps(n: int | None = ...) -> None: ... def filling() -> bool: ... def begin_fill() -> None: ... def end_fill() -> None: ... -def dot(size: Optional[int] = ..., *color: _Color) -> None: ... +def dot(size: int | None = ..., *color: _Color) -> None: ... def write(arg: object, move: bool = ..., align: str = ..., font: Tuple[str, int, str] = ...) -> None: ... def begin_poly() -> None: ... def end_poly() -> None: ... -def get_poly() -> Optional[_PolygonCoords]: ... +def get_poly() -> _PolygonCoords | None: ... def getscreen() -> TurtleScreen: ... def getturtle() -> Turtle: ... getpen = getturtle -def onrelease(fun: Callable[[float, float], Any], btn: int = ..., add: Optional[Any] = ...) -> None: ... -def ondrag(fun: Callable[[float, float], Any], btn: int = ..., add: Optional[Any] = ...) -> None: ... +def onrelease(fun: Callable[[float, float], Any], btn: int = ..., add: Any | None = ...) -> None: ... +def ondrag(fun: Callable[[float, float], Any], btn: int = ..., add: Any | None = ...) -> None: ... def undo() -> None: ... turtlesize = shapesize diff --git a/stdlib/@python2/types.pyi b/stdlib/@python2/types.pyi index cf57c6329665..72b9321a860f 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, overload _T = TypeVar("_T") @@ -27,11 +27,11 @@ 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: 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] = ..., - argdefs: Optional[Tuple[object, ...]] = ..., - closure: Optional[Tuple[_Cell, ...]] = ..., + name: str | None = ..., + argdefs: Tuple[object, ...] | None = ..., + closure: Tuple[_Cell, ...] | None = ..., ) -> 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 @@ -95,11 +95,9 @@ class GeneratorType: def next(self) -> Any: ... def send(self, __arg: Any) -> Any: ... @overload - def throw( - self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... - ) -> Any: ... + def throw(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 +116,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] - __path__: Optional[Iterable[str]] + __package__: str | None + __path__: Iterable[str] | None __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 @@ -164,7 +162,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..a1b02e81990c 100644 --- a/stdlib/@python2/typing.pyi +++ b/stdlib/@python2/typing.pyi @@ -9,17 +9,12 @@ Any = object() class TypeVar: __name__: str - __bound__: Optional[Type[Any]] + __bound__: Type[Any] | None __constraints__: Tuple[Type[Any], ...] __covariant__: bool __contravariant__: bool def __init__( - self, - name: str, - *constraints: Type[Any], - bound: Optional[Type[Any]] = ..., - covariant: bool = ..., - contravariant: bool = ..., + self, name: str, *constraints: Type[Any], bound: Type[Any] | None = ..., covariant: bool = ..., contravariant: bool = ... ) -> None: ... _promote = object() @@ -144,11 +139,11 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]): @overload @abstractmethod def throw( - self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., __tb: Optional[TracebackType] = ... + self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ... ) -> _T_co: ... @overload @abstractmethod - def throw(self, __typ: BaseException, __val: None = ..., __tb: Optional[TracebackType] = ...) -> _T_co: ... + def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... @abstractmethod def close(self) -> None: ... @property @@ -218,9 +213,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 +231,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): @@ -263,11 +258,8 @@ class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]): class ContextManager(Protocol[_T_co]): def __enter__(self) -> _T_co: ... def __exit__( - self, - __exc_type: Optional[Type[BaseException]], - __exc_value: Optional[BaseException], - __traceback: Optional[TracebackType], - ) -> Optional[bool]: ... + 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]): # TODO: We wish the key type could also be covariant, but that doesn't work, @@ -276,9 +268,9 @@ 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: 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 +291,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 @@ -346,7 +338,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 +354,8 @@ class IO(Iterator[AnyStr], Generic[AnyStr]): def __enter__(self) -> IO[AnyStr]: ... @abstractmethod def __exit__( - self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType] - ) -> Optional[bool]: ... + self, t: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None + ) -> bool | None: ... class BinaryIO(IO[str]): # TODO readinto @@ -379,7 +371,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 +384,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,8 +396,8 @@ 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] - def expand(self, template: Union[str, Text]) -> Any: ... + lastgroup: Any | None + def expand(self, template: str | Text) -> Any: ... @overload def group(self, group1: int = ...) -> AnyStr: ... @overload @@ -416,9 +408,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 @@ -433,12 +425,12 @@ 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. - 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: ... @@ -452,7 +444,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 2499ae19d0f9..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, - Optional, Text as Text, Tuple, Type as Type, TypeVar, - Union, ValuesView, _Alias, overload as overload, @@ -67,8 +65,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,11 +89,11 @@ class ParamSpecKwargs: class ParamSpec: __name__: str - __bound__: Optional[Type[Any]] + __bound__: Type[Any] | None __covariant__: bool __contravariant__: bool def __init__( - self, name: str, *, bound: Union[None, Type[Any], str] = ..., contravariant: bool = ..., covariant: bool = ... + self, name: str, *, bound: None | Type[Any] | str = ..., contravariant: bool = ..., covariant: bool = ... ) -> None: ... @property def args(self) -> ParamSpecArgs: ... diff --git a/stdlib/@python2/unicodedata.pyi b/stdlib/@python2/unicodedata.pyi index 19c4a6781660..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 @@ -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..65a5a7878de6 100644 --- a/stdlib/@python2/unittest.pyi +++ b/stdlib/@python2/unittest.pyi @@ -11,7 +11,6 @@ from typing import ( List, Mapping, NoReturn, - Optional, Pattern, Sequence, Set, @@ -79,7 +78,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: ... @@ -144,9 +143,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: Union[Set[Any], FrozenSet[Any]], second: Union[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: ... @@ -177,8 +174,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: ... @@ -187,16 +184,16 @@ 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): def __init__( self, testFunc: Callable[[], None], - setUp: Optional[Callable[[], None]] = ..., - tearDown: Optional[Callable[[], None]] = ..., - description: Optional[str] = ..., + setUp: Callable[[], None] | None = ..., + tearDown: Callable[[], None] | None = ..., + description: str | None = ..., ) -> None: ... def debug(self) -> None: ... def countTestCases(self) -> int: ... @@ -212,13 +209,13 @@ class TestSuite(Testable): class TestLoader: testMethodPrefix: str - sortTestMethodsUsing: Optional[Callable[[str, str], int]] + sortTestMethodsUsing: Callable[[str, str], int] | None 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,12 +229,12 @@ class TextTestResult(TestResult): class TextTestRunner: def __init__( self, - stream: Optional[TextIO] = ..., + stream: TextIO | None = ..., descriptions: bool = ..., 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 @@ -245,10 +242,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: @@ -256,18 +253,18 @@ class TestProgram: def runTests(self) -> None: ... # undocumented def main( - module: Union[None, Text, types.ModuleType] = ..., - defaultTest: Optional[str] = ..., - argv: Optional[Sequence[str]] = ..., - testRunner: Union[Type[TextTestRunner], TextTestRunner, None] = ..., + module: None | Text | types.ModuleType = ..., + defaultTest: str | None = ..., + argv: Sequence[str] | None = ..., + 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 30aaec8095b4..f6bb555b9581 100644 --- a/stdlib/@python2/urllib.pyi +++ b/stdlib/@python2/urllib.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, AnyStr, List, Mapping, Sequence, Text, Tuple, TypeVar, Union +from typing import IO, Any, AnyStr, List, Mapping, Sequence, Text, Tuple, TypeVar def url2pathname(pathname: AnyStr) -> AnyStr: ... def pathname2url(pathname: AnyStr) -> AnyStr: ... @@ -125,7 +125,7 @@ def unquote(s: AnyStr) -> AnyStr: ... def unquote_plus(s: AnyStr) -> AnyStr: ... def quote(s: AnyStr, safe: Text = ...) -> AnyStr: ... def quote_plus(s: AnyStr, safe: Text = ...) -> AnyStr: ... -def urlencode(query: Union[Sequence[Tuple[Any, Any]], Mapping[Any, Any]], doseq=...) -> str: ... +def urlencode(query: Sequence[Tuple[Any, Any]] | Mapping[Any, Any], doseq=...) -> str: ... def getproxies() -> Mapping[str, str]: ... def proxy_bypass(host: str) -> Any: ... # undocumented diff --git a/stdlib/@python2/urllib2.pyi b/stdlib/@python2/urllib2.pyi index 8c355db46d75..bf6157b8428b 100644 --- a/stdlib/@python2/urllib2.pyi +++ b/stdlib/@python2/urllib2.pyi @@ -1,12 +1,12 @@ 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 = Union[str, unicode] class URLError(IOError): - reason: Union[str, BaseException] + reason: str | BaseException class HTTPError(URLError, addinfourl): code: int @@ -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,30 +47,28 @@ 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: Union[Request, _string], data: Optional[_string] = ..., timeout: Optional[float] = ... - ) -> Optional[addinfourl]: ... + 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 # a custom opener has been installed that fails to handle the request. def urlopen( - url: Union[Request, _string], - data: Optional[_string] = ..., - timeout: Optional[float] = ..., - cafile: Optional[_string] = ..., - capath: Optional[_string] = ..., + url: Request | _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: Union[BaseHandler, Type[BaseHandler]]) -> OpenerDirector: ... +def build_opener(*handlers: BaseHandler | Type[BaseHandler]) -> OpenerDirector: ... class BaseHandler: handler_order: int @@ -97,21 +95,21 @@ 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: def __init__(self) -> None: ... - def add_password(self, realm: Optional[Text], uri: Union[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: Union[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 +122,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: Union[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 +146,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 +176,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 40691239a87b..6668c743373a 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 = Union[str, unicode] @@ -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 69d5754bc216..e8717aecbe36 100644 --- a/stdlib/@python2/uu.pyi +++ b/stdlib/@python2/uu.pyi @@ -1,8 +1,8 @@ -from typing import BinaryIO, Optional, Text, Union +from typing import BinaryIO, Text, Union _File = Union[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..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 @@ -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 a94e9fc86d2e..e3540ed60b0c 100644 --- a/stdlib/@python2/warnings.pyi +++ b/stdlib/@python2/warnings.pyi @@ -1,20 +1,13 @@ from types import ModuleType, TracebackType -from typing import List, Optional, 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 def showwarning( - message: Union[Warning, str], - category: Type[Warning], - filename: str, - lineno: int, - file: Optional[TextIO] = ..., - line: Optional[str] = ..., + message: Warning | str, category: Type[Warning], filename: str, lineno: int, file: TextIO | None = ..., line: str | None = ... ) -> None: ... -def formatwarning( - message: Union[Warning, str], category: Type[Warning], filename: str, lineno: int, line: Optional[str] = ... -) -> 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: ... @@ -24,32 +17,32 @@ def resetwarnings() -> None: ... class _OptionError(Exception): ... class WarningMessage: - message: Union[Warning, str] + message: Warning | str category: Type[Warning] filename: str lineno: int - file: Optional[TextIO] - line: Optional[str] + file: TextIO | None + line: str | None def __init__( self, - message: Union[Warning, str], + message: Warning | str, category: Type[Warning], filename: str, lineno: int, - file: Optional[TextIO] = ..., - line: Optional[str] = ..., + file: TextIO | None = ..., + line: str | None = ..., ) -> None: ... class catch_warnings: @overload - def __new__(cls, *, record: Literal[False] = ..., module: Optional[ModuleType] = ...) -> _catch_warnings_without_records: ... + def __new__(cls, *, record: Literal[False] = ..., module: ModuleType | None = ...) -> _catch_warnings_without_records: ... @overload - def __new__(cls, *, record: Literal[True], module: Optional[ModuleType] = ...) -> _catch_warnings_with_records: ... + def __new__(cls, *, record: Literal[True], module: ModuleType | None = ...) -> _catch_warnings_with_records: ... @overload - def __new__(cls, *, record: bool, module: Optional[ModuleType] = ...) -> catch_warnings: ... - def __enter__(self) -> Optional[List[WarningMessage]]: ... + def __new__(cls, *, record: bool, module: ModuleType | None = ...) -> catch_warnings: ... + def __enter__(self) -> List[WarningMessage] | None: ... def __exit__( - self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... class _catch_warnings_without_records(catch_warnings): diff --git a/stdlib/@python2/wave.pyi b/stdlib/@python2/wave.pyi index 8615d8fad8ca..0e9fe612cd24 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 = Union[Text, IO[bytes]] @@ -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/weakref.pyi b/stdlib/@python2/weakref.pyi index 5e8f4cd12b03..6467f3a7517f 100644 --- a/stdlib/@python2/weakref.pyi +++ b/stdlib/@python2/weakref.pyi @@ -1,19 +1,5 @@ from _weakrefset import WeakSet as WeakSet -from typing import ( - Any, - Callable, - Generic, - Iterable, - Iterator, - List, - Mapping, - MutableMapping, - Tuple, - Type, - TypeVar, - Union, - overload, -) +from typing import Any, Callable, Generic, Iterable, Iterator, List, Mapping, MutableMapping, Tuple, Type, TypeVar, overload from _weakref import ( CallableProxyType as CallableProxyType, @@ -37,7 +23,7 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]): @overload def __init__(self) -> None: ... @overload - def __init__(self, __other: Union[Mapping[_KT, _VT], Iterable[Tuple[_KT, _VT]]], **kwargs: _VT) -> None: ... + def __init__(self, __other: Mapping[_KT, _VT] | Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... def __len__(self) -> int: ... def __getitem__(self, k: _KT) -> _VT: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... @@ -66,7 +52,7 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]): @overload def __init__(self, dict: None = ...) -> None: ... @overload - def __init__(self, dict: Union[Mapping[_KT, _VT], Iterable[Tuple[_KT, _VT]]]) -> None: ... + def __init__(self, dict: Mapping[_KT, _VT] | Iterable[Tuple[_KT, _VT]]) -> None: ... def __len__(self) -> int: ... def __getitem__(self, k: _KT) -> _VT: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... diff --git a/stdlib/@python2/webbrowser.pyi b/stdlib/@python2/webbrowser.pyi index 9e143bb8c88f..f634bc11ca7d 100644 --- a/stdlib/@python2/webbrowser.pyi +++ b/stdlib/@python2/webbrowser.pyi @@ -1,12 +1,12 @@ import sys -from typing import Callable, List, Optional, Sequence, Text, Union +from typing import Callable, List, Sequence, Text class Error(Exception): ... def register( - name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., update_tryorder: int = ... + name: Text, klass: Callable[[], BaseBrowser] | None, 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: ... @@ -24,14 +24,14 @@ 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): 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/whichdb.pyi b/stdlib/@python2/whichdb.pyi index 67542096d712..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) -> Optional[str]: ... +def whichdb(filename: Text) -> str | None: ... diff --git a/stdlib/@python2/winsound.pyi b/stdlib/@python2/winsound.pyi index be9a8c660781..3d79f3b043f2 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 overload from typing_extensions import Literal if sys.platform == "win32": @@ -21,7 +21,7 @@ if sys.platform == "win32": def Beep(frequency: int, duration: int) -> None: ... # Can actually accept anything ORed with 4, and if not it's definitely str, but that's inexpressible @overload - def PlaySound(sound: Optional[bytes], flags: Literal[4]) -> None: ... + def PlaySound(sound: bytes | None, flags: Literal[4]) -> None: ... @overload - def PlaySound(sound: Optional[Union[str, bytes]], flags: int) -> None: ... + def PlaySound(sound: str | bytes | None, flags: int) -> None: ... def MessageBeep(type: int = ...) -> None: ... diff --git a/stdlib/@python2/wsgiref/handlers.pyi b/stdlib/@python2/wsgiref/handlers.pyi index e8d32bea3f7b..d7e35ba8aff6 100644 --- a/stdlib/@python2/wsgiref/handlers.pyi +++ b/stdlib/@python2/wsgiref/handlers.pyi @@ -8,7 +8,7 @@ from .util import FileWrapper _exc_info = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] -def format_date_time(timestamp: Optional[float]) -> str: ... # undocumented +def format_date_time(timestamp: float | None) -> str: ... # undocumented 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]] + wsgi_file_wrapper: Type[FileWrapper] | None headers_class: Type[Headers] # undocumented - traceback_limit: Optional[int] + traceback_limit: int | None error_status: str error_headers: List[Tuple[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..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]] @@ -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..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 @@ -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..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 @@ -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..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): ... @@ -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..2496b3884ea1 100644 --- a/stdlib/@python2/xml/dom/domreg.pyi +++ b/stdlib/@python2/xml/dom/domreg.pyi @@ -1,10 +1,8 @@ from _typeshed.xml import DOMImplementation -from typing import Callable, Dict, Iterable, Optional, Tuple, Union +from typing import Callable, Dict, Iterable, Tuple well_known_implementations: Dict[str, str] registered: Dict[str, Callable[[], DOMImplementation]] def registerDOMImplementation(name: str, factory: Callable[[], DOMImplementation]) -> None: ... -def getDOMImplementation( - name: Optional[str] = ..., features: Union[str, Iterable[Tuple[str, Optional[str]]]] = ... -) -> DOMImplementation: ... +def getDOMImplementation(name: str | None = ..., features: 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..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") @@ -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 2f5988bf76e0..ed46ac4561ec 100644 --- a/stdlib/@python2/xml/dom/minidom.pyi +++ b/stdlib/@python2/xml/dom/minidom.pyi @@ -1,23 +1,23 @@ import xml.dom -from typing import IO, Any, Optional, 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 _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 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): ... @@ -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: Optional[Any] = ... - ) -> 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/ElementInclude.pyi b/stdlib/@python2/xml/etree/ElementInclude.pyi index c6144e40852a..b74285d3e9b7 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 from xml.etree.ElementTree import Element XINCLUDE: str @@ -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: 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 # Which can't be represented using Callable... -def include(elem: Element, loader: Optional[Callable[..., Union[str, Element]]] = ...) -> None: ... +def include(elem: Element, loader: Callable[..., str | Element] | None = ...) -> None: ... diff --git a/stdlib/@python2/xml/etree/ElementPath.pyi b/stdlib/@python2/xml/etree/ElementPath.pyi index de49ffcf1209..02fe84567543 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 from xml.etree.ElementTree import Element xpath_tokenizer_re: Pattern[str] @@ -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,13 @@ def prepare_predicate(next: _next, token: _token) -> _callback: ... ops: Dict[str, Callable[[_next, _token], _callback]] class _SelectorContext: - parent_map: Optional[Dict[Element, Element]] + parent_map: Dict[Element, Element] | None root: Element def __init__(self, root: Element) -> None: ... _T = TypeVar("_T") -def iterfind(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) -> Generator[Element, None, None]: ... -def find(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) -> Optional[Element]: ... -def findall(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) -> List[Element]: ... -def findtext( - elem: Element, path: str, default: Optional[_T] = ..., namespaces: Optional[Dict[str, str]] = ... -) -> Union[_T, str]: ... +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: ... diff --git a/stdlib/@python2/xml/etree/ElementTree.pyi b/stdlib/@python2/xml/etree/ElementTree.pyi index f7527fa5d890..a7a0a1c65f46 100644 --- a/stdlib/@python2/xml/etree/ElementTree.pyi +++ b/stdlib/@python2/xml/etree/ElementTree.pyi @@ -11,7 +11,6 @@ from typing import ( KeysView, List, MutableSequence, - Optional, Sequence, Text, Tuple, @@ -55,11 +54,11 @@ _file_or_filename = Union[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: 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: ... @@ -67,38 +66,35 @@ 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]] = ... - ) -> Optional[Element]: ... + 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]] = ..., - ) -> Optional[_str_result_type]: ... + self, path: _str_argument_type, default: None = ..., 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]] = ... - ) -> Union[_T, _str_result_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 = ...) -> 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) -> 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]: ... + 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]: ... 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 @@ -109,7 +105,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,66 +113,63 @@ 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]: ... + 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]] = ..., - ) -> Optional[_str_result_type]: ... + self, path: _str_argument_type, default: None = ..., 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]] = ... - ) -> Union[_T, _str_result_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, 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: Sequence[str] | None = ..., 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 +183,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 +195,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 f4ad8ba34c89..0c6da9a87d13 100644 --- a/stdlib/@python2/xml/sax/__init__.pyi +++ b/stdlib/@python2/xml/sax/__init__.pyi @@ -1,9 +1,9 @@ -from typing import IO, Any, List, NoReturn, Optional, Text, Union +from typing import IO, Any, List, NoReturn, Text 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: ... @@ -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 parseString(string: Union[bytes, Text], handler: ContentHandler, errorHandler: Optional[ErrorHandler] = ...) -> None: ... +def parse(source: str | IO[str] | IO[bytes], handler: ContentHandler, errorHandler: 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..1fc896490f54 100644 --- a/stdlib/@python2/xml/sax/saxutils.pyi +++ b/stdlib/@python2/xml/sax/saxutils.pyi @@ -1,7 +1,7 @@ from _typeshed import SupportsWrite from codecs import StreamReaderWriter, StreamWriter from io import RawIOBase, TextIOBase -from typing import Mapping, Optional, Text, Union +from typing import Mapping, Text from xml.sax import handler, xmlreader def escape(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ... @@ -11,7 +11,7 @@ def quoteattr(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ... class XMLGenerator(handler.ContentHandler): def __init__( self, - out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ..., + out: TextIOBase | RawIOBase | StreamWriter | StreamReaderWriter | SupportsWrite[str] | None = ..., encoding: Text = ..., ) -> None: ... def startDocument(self): ... @@ -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..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: ... @@ -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 868de39ee7f7..5a7d0fc34f0e 100644 --- a/stdlib/@python2/xmlrpclib.pyi +++ b/stdlib/@python2/xmlrpclib.pyi @@ -5,7 +5,7 @@ from ssl import SSLContext from StringIO import StringIO from time import struct_time from types import InstanceType -from typing import IO, Any, AnyStr, Callable, Iterable, List, Mapping, MutableMapping, Optional, Tuple, Type, Union +from typing import IO, Any, AnyStr, Callable, Iterable, List, Mapping, MutableMapping, Tuple, Type, Union _Unmarshaller = Any _timeTuple = Tuple[int, int, int, int, int, int, int, int, int] @@ -52,7 +52,7 @@ Boolean: Type[bool] class DateTime: value: str - def __init__(self, value: Union[str, unicode, datetime, float, int, _timeTuple, struct_time] = ...) -> None: ... + def __init__(self, value: str | unicode | datetime | float | int | _timeTuple | struct_time = ...) -> None: ... def make_comparable(self, other: _dateTimeComp) -> Tuple[unicode, unicode]: ... def __lt__(self, other: _dateTimeComp) -> bool: ... def __le__(self, other: _dateTimeComp) -> bool: ... @@ -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,32 +97,28 @@ 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, - values: Union[ - Iterable[ - Union[ - None, - int, - bool, - long, - float, - str, - unicode, - List[Any], - Tuple[Any, ...], - Mapping[Any, Any], - datetime, - InstanceType, - ] - ], - Fault, - ], + values: Iterable[ + None + | int + | bool + | long + | float + | str + | unicode + | List[Any] + | Tuple[Any, ...] + | Mapping[Any, Any] + | datetime + | InstanceType + ] + | Fault, ) -> str: ... def dump_nil(self, value: None, write: Callable[[str], None]) -> None: ... def dump_int(self, value: int, write: Callable[[str], None]) -> None: ... @@ -155,7 +151,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: ... @@ -187,15 +183,15 @@ 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] = ..., - methodresponse: Optional[bool] = ..., - encoding: Optional[str] = ..., + params: Tuple[Any, ...] | Fault, + 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,13 +208,13 @@ 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 def single_request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> Tuple[Any, ...]: ... - def getparser(self) -> Tuple[Union[ExpatParser, SlowParser], Unmarshaller]: ... - def get_host_info(self, host: _hostDesc) -> Tuple[str, Optional[List[Tuple[str, str]]], Optional[Mapping[Any, Any]]]: ... + def getparser(self) -> Tuple[ExpatParser | SlowParser, Unmarshaller]: ... + def get_host_info(self, host: _hostDesc) -> Tuple[str, List[Tuple[str, str]] | None, 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: ... @@ -228,21 +224,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 043aa5e342c7..5a0879492a88 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, Pattern, Protocol, Sequence, Text, Tuple, Type, Union _SZI = Union[Text, ZipInfo] _DT = Tuple[int, int, int, int, int, int] @@ -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__( @@ -26,48 +26,44 @@ class ZipExtFile(io.BufferedIOBase): fileobj: IO[bytes], mode: str, zipinfo: ZipInfo, - decrypter: Optional[Callable[[Sequence[int]], bytes]] = ..., + decrypter: Callable[[Sequence[int]], bytes] | None = ..., 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] - fp: Optional[IO[bytes]] + fp: IO[bytes] | None NameToInfo: Dict[Text, ZipInfo] start_dir: int # undocumented - def __init__( - self, file: Union[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: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] + self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... def close(self) -> None: ... def getinfo(self, name: 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 extractall( - self, path: Optional[StrPath] = ..., members: Optional[Iterable[Text]] = ..., pwd: Optional[bytes] = ... - ) -> None: ... + 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 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,13 +86,13 @@ 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: Union[StrPath, IO[bytes]]) -> bool: ... +def is_zipfile(filename: StrPath | IO[bytes]) -> bool: ... ZIP_STORED: int ZIP_DEFLATED: int diff --git a/stdlib/@python2/zipimport.pyi b/stdlib/@python2/zipimport.pyi index 14aa86bb90ad..bcefd6859059 100644 --- a/stdlib/@python2/zipimport.pyi +++ b/stdlib/@python2/zipimport.pyi @@ -1,16 +1,15 @@ from types import CodeType, ModuleType -from typing import Optional, Union class ZipImportError(ImportError): ... class zipimporter(object): archive: str prefix: str - def __init__(self, path: Union[str, bytes]) -> None: ... - def find_module(self, fullname: str, path: Optional[str] = ...) -> Optional[zipimporter]: ... + def __init__(self, path: str | bytes) -> None: ... + 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/@python2/zlib.pyi b/stdlib/@python2/zlib.pyi index f33777ced457..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 @@ -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: ...