switch to new union syntax in third-party stubs (#5881)

This commit is contained in:
Akuli
2021-08-08 16:46:55 +03:00
committed by GitHub
parent c12c93ebe4
commit 1154218a0e
4 changed files with 229 additions and 235 deletions
+15 -21
View File
@@ -16,12 +16,10 @@ from typing import (
KeysView,
Mapping,
NoReturn,
Optional,
Pattern,
Tuple,
Type,
TypeVar,
Union,
ValuesView,
overload,
)
@@ -56,10 +54,10 @@ def create_unbound_method(func: types.FunctionType, cls: type) -> types.Function
Iterator = object
def get_method_function(meth: types.MethodType) -> types.FunctionType: ...
def get_method_self(meth: types.MethodType) -> Optional[object]: ...
def get_function_closure(fun: types.FunctionType) -> Optional[Tuple[types._Cell, ...]]: ...
def get_method_self(meth: types.MethodType) -> object | None: ...
def get_function_closure(fun: types.FunctionType) -> Tuple[types._Cell, ...] | None: ...
def get_function_code(fun: types.FunctionType) -> types.CodeType: ...
def get_function_defaults(fun: types.FunctionType) -> Optional[Tuple[Any, ...]]: ...
def get_function_defaults(fun: types.FunctionType) -> Tuple[Any, ...] | None: ...
def get_function_globals(fun: types.FunctionType) -> Dict[str, Any]: ...
def iterkeys(d: Mapping[_K, Any]) -> typing.Iterator[_K]: ...
def itervalues(d: Mapping[Any, _V]) -> typing.Iterator[_V]: ...
@@ -79,47 +77,43 @@ def int2byte(i: int) -> bytes: ...
def byte2int(bs: binary_type) -> int: ...
def indexbytes(buf: binary_type, i: int) -> int: ...
def iterbytes(buf: binary_type) -> typing.Iterator[int]: ...
def assertCountEqual(self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: Optional[str] = ...) -> None: ...
def assertCountEqual(self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: str | None = ...) -> None: ...
@overload
def assertRaisesRegex(self: unittest.TestCase, msg: Optional[str] = ...) -> Any: ...
def assertRaisesRegex(self: unittest.TestCase, msg: str | None = ...) -> Any: ...
@overload
def assertRaisesRegex(self: unittest.TestCase, callable_obj: Callable[..., Any], *args: Any, **kwargs: Any) -> Any: ...
def assertRegex(
self: unittest.TestCase, text: AnyStr, expected_regex: Union[AnyStr, Pattern[AnyStr]], msg: Optional[str] = ...
self: unittest.TestCase, text: AnyStr, expected_regex: AnyStr | Pattern[AnyStr], msg: str | None = ...
) -> None: ...
exec_ = exec
def reraise(
tp: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] = ...
) -> NoReturn: ...
def raise_from(value: Union[BaseException, Type[BaseException]], from_value: Optional[BaseException]) -> NoReturn: ...
def reraise(tp: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None = ...) -> NoReturn: ...
def raise_from(value: BaseException | Type[BaseException], from_value: BaseException | None) -> NoReturn: ...
print_ = print
def with_metaclass(meta: type, *bases: type) -> type: ...
def add_metaclass(metaclass: type) -> Callable[[_T], _T]: ...
def ensure_binary(s: Union[bytes, str], encoding: str = ..., errors: str = ...) -> bytes: ...
def ensure_str(s: Union[bytes, str], encoding: str = ..., errors: str = ...) -> str: ...
def ensure_text(s: Union[bytes, str], encoding: str = ..., errors: str = ...) -> str: ...
def ensure_binary(s: bytes | str, encoding: str = ..., errors: str = ...) -> bytes: ...
def ensure_str(s: bytes | str, encoding: str = ..., errors: str = ...) -> str: ...
def ensure_text(s: bytes | str, encoding: str = ..., errors: str = ...) -> str: ...
def python_2_unicode_compatible(klass: _T) -> _T: ...
class _LazyDescriptor:
name: str
def __init__(self, name: str) -> None: ...
def __get__(self, obj: Optional[object], type: Optional[type] = ...) -> Any: ...
def __get__(self, obj: object | None, type: type | None = ...) -> Any: ...
class MovedModule(_LazyDescriptor):
mod: str
def __init__(self, name: str, old: str, new: Optional[str] = ...) -> None: ...
def __init__(self, name: str, old: str, new: str | None = ...) -> None: ...
def __getattr__(self, attr: str) -> Any: ...
class MovedAttribute(_LazyDescriptor):
mod: str
attr: str
def __init__(
self, name: str, old_mod: str, new_mod: str, old_attr: Optional[str] = ..., new_attr: Optional[str] = ...
) -> None: ...
def __init__(self, name: str, old_mod: str, new_mod: str, old_attr: str | None = ..., new_attr: str | None = ...) -> None: ...
def add_move(move: Union[MovedModule, MovedAttribute]) -> None: ...
def add_move(move: MovedModule | MovedAttribute) -> None: ...
def remove_move(name: str) -> None: ...