Switch to PEP-604 syntax in python2 stubs (#5915)

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
This commit is contained in:
Oleg Höfling
2021-08-14 11:12:30 +02:00
committed by GitHub
parent 431c4f7fc1
commit ff63953188
235 changed files with 2473 additions and 2768 deletions

View File

@@ -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: ...