Use PEP 585 syntax in Python 2, protobuf & _ast stubs, where possible (#6949)

This commit is contained in:
Alex Waygood
2022-01-18 15:14:03 +00:00
committed by GitHub
parent aa885ecd65
commit 8af5e0d340
264 changed files with 2217 additions and 2411 deletions

View File

@@ -17,8 +17,6 @@ from typing import (
NoReturn,
Pattern,
Text,
Tuple,
Type,
TypeVar,
ValuesView,
overload,
@@ -40,11 +38,11 @@ PY2: Literal[True]
PY3: Literal[False]
PY34: Literal[False]
string_types: tuple[Type[str], Type[unicode]]
integer_types: tuple[Type[int], Type[long]]
class_types: tuple[Type[Type[Any]], Type[types.ClassType]]
text_type: Type[unicode]
binary_type: Type[str]
string_types: tuple[type[str], type[unicode]]
integer_types: tuple[type[int], type[long]]
class_types: tuple[type[type[Any]], type[types.ClassType]]
text_type: type[unicode]
binary_type: type[str]
MAXSIZE: int
@@ -62,9 +60,9 @@ class Iterator:
def get_method_function(meth: types.MethodType) -> types.FunctionType: ...
def get_method_self(meth: types.MethodType) -> object | None: ...
def get_function_closure(fun: types.FunctionType) -> Tuple[types._Cell, ...] | 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) -> Tuple[Any, ...] | None: ...
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, _V]) -> typing.Iterator[_K]: ...
def itervalues(d: Mapping[_K, _V]) -> typing.Iterator[_V]: ...
@@ -89,9 +87,9 @@ def assertRaisesRegex(self: unittest.TestCase, msg: str = ...) -> 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: AnyStr | Pattern[AnyStr], msg: str = ...) -> None: ...
def reraise(tp: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None = ...) -> NoReturn: ...
def reraise(tp: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None = ...) -> NoReturn: ...
def exec_(_code_: unicode | types.CodeType, _globs_: dict[str, Any] = ..., _locs_: dict[str, Any] = ...): ...
def raise_from(value: BaseException | Type[BaseException], from_value: BaseException | None) -> NoReturn: ...
def raise_from(value: BaseException | type[BaseException], from_value: BaseException | None) -> NoReturn: ...
print_ = print
@@ -105,7 +103,7 @@ def python_2_unicode_compatible(klass: _T) -> _T: ...
class _LazyDescr(object):
name: str
def __init__(self, name: str) -> None: ...
def __get__(self, obj: object | None, type: Type[Any] | None = ...) -> Any: ...
def __get__(self, obj: object | None, type: type[Any] | None = ...) -> Any: ...
class MovedModule(_LazyDescr):
mod: str