Use PEP 585 syntax wherever possible (#6717)

This commit is contained in:
Alex Waygood
2021-12-28 10:31:43 +00:00
committed by GitHub
parent e6cb341d94
commit 8d5d2520ac
237 changed files with 966 additions and 1069 deletions

View File

@@ -16,7 +16,6 @@ from typing import (
KeysView,
Mapping,
MutableSequence,
Tuple,
Type,
TypeVar,
ValuesView,
@@ -42,9 +41,9 @@ class _Cell:
@final
class FunctionType:
__closure__: Tuple[_Cell, ...] | None
__closure__: tuple[_Cell, ...] | None
__code__: CodeType
__defaults__: Tuple[Any, ...] | None
__defaults__: tuple[Any, ...] | None
__dict__: dict[str, Any]
__globals__: dict[str, Any]
__name__: str
@@ -56,8 +55,8 @@ class FunctionType:
code: CodeType,
globals: dict[str, Any],
name: str | None = ...,
argdefs: Tuple[object, ...] | None = ...,
closure: Tuple[_Cell, ...] | None = ...,
argdefs: tuple[object, ...] | None = ...,
closure: tuple[_Cell, ...] | None = ...,
) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __get__(self, obj: object | None, type: type | None) -> MethodType: ...
@@ -76,15 +75,15 @@ class CodeType:
co_stacksize: int
co_flags: int
co_code: bytes
co_consts: Tuple[Any, ...]
co_names: Tuple[str, ...]
co_varnames: Tuple[str, ...]
co_consts: tuple[Any, ...]
co_names: tuple[str, ...]
co_varnames: tuple[str, ...]
co_filename: str
co_name: str
co_firstlineno: int
co_lnotab: bytes
co_freevars: Tuple[str, ...]
co_cellvars: Tuple[str, ...]
co_freevars: tuple[str, ...]
co_cellvars: tuple[str, ...]
if sys.version_info >= (3, 8):
def __init__(
self,
@@ -95,15 +94,15 @@ class CodeType:
stacksize: int,
flags: int,
codestring: bytes,
constants: Tuple[Any, ...],
names: Tuple[str, ...],
varnames: Tuple[str, ...],
constants: tuple[Any, ...],
names: tuple[str, ...],
varnames: tuple[str, ...],
filename: str,
name: str,
firstlineno: int,
lnotab: bytes,
freevars: Tuple[str, ...] = ...,
cellvars: Tuple[str, ...] = ...,
freevars: tuple[str, ...] = ...,
cellvars: tuple[str, ...] = ...,
) -> None: ...
else:
def __init__(
@@ -114,15 +113,15 @@ class CodeType:
stacksize: int,
flags: int,
codestring: bytes,
constants: Tuple[Any, ...],
names: Tuple[str, ...],
varnames: Tuple[str, ...],
constants: tuple[Any, ...],
names: tuple[str, ...],
varnames: tuple[str, ...],
filename: str,
name: str,
firstlineno: int,
lnotab: bytes,
freevars: Tuple[str, ...] = ...,
cellvars: Tuple[str, ...] = ...,
freevars: tuple[str, ...] = ...,
cellvars: tuple[str, ...] = ...,
) -> None: ...
if sys.version_info >= (3, 10):
def replace(
@@ -136,11 +135,11 @@ class CodeType:
co_flags: int = ...,
co_firstlineno: int = ...,
co_code: bytes = ...,
co_consts: Tuple[Any, ...] = ...,
co_names: Tuple[str, ...] = ...,
co_varnames: Tuple[str, ...] = ...,
co_freevars: Tuple[str, ...] = ...,
co_cellvars: Tuple[str, ...] = ...,
co_consts: tuple[Any, ...] = ...,
co_names: tuple[str, ...] = ...,
co_varnames: tuple[str, ...] = ...,
co_freevars: tuple[str, ...] = ...,
co_cellvars: tuple[str, ...] = ...,
co_filename: str = ...,
co_name: str = ...,
co_linetable: object = ...,
@@ -159,11 +158,11 @@ class CodeType:
co_flags: int = ...,
co_firstlineno: int = ...,
co_code: bytes = ...,
co_consts: Tuple[Any, ...] = ...,
co_names: Tuple[str, ...] = ...,
co_varnames: Tuple[str, ...] = ...,
co_freevars: Tuple[str, ...] = ...,
co_cellvars: Tuple[str, ...] = ...,
co_consts: tuple[Any, ...] = ...,
co_names: tuple[str, ...] = ...,
co_varnames: tuple[str, ...] = ...,
co_freevars: tuple[str, ...] = ...,
co_cellvars: tuple[str, ...] = ...,
co_filename: str = ...,
co_name: str = ...,
co_lnotab: bytes = ...,
@@ -281,8 +280,8 @@ class _StaticFunctionType:
@final
class MethodType:
__closure__: Tuple[_Cell, ...] | None # inherited from the added function
__defaults__: Tuple[Any, ...] | None # inherited from the added function
__closure__: tuple[_Cell, ...] | None # inherited from the added function
__defaults__: tuple[Any, ...] | None # inherited from the added function
__func__: _StaticFunctionType
__self__: object
__name__: str # inherited from the added function
@@ -385,18 +384,18 @@ if sys.version_info >= (3, 7):
kwds: dict[str, Any] | None = ...,
exec_body: Callable[[dict[str, Any]], None] | None = ...,
) -> type: ...
def resolve_bases(bases: Iterable[object]) -> Tuple[Any, ...]: ...
def resolve_bases(bases: Iterable[object]) -> tuple[Any, ...]: ...
else:
def new_class(
name: str,
bases: Tuple[type, ...] = ...,
bases: tuple[type, ...] = ...,
kwds: dict[str, Any] | None = ...,
exec_body: Callable[[dict[str, Any]], None] | None = ...,
) -> type: ...
def prepare_class(
name: str, bases: Tuple[type, ...] = ..., kwds: dict[str, Any] | None = ...
name: str, bases: tuple[type, ...] = ..., kwds: dict[str, Any] | None = ...
) -> tuple[type, dict[str, Any], dict[str, Any]]: ...
# Actually a different type, but `property` is special and we want that too.
@@ -419,8 +418,8 @@ if sys.version_info >= (3, 8):
if sys.version_info >= (3, 9):
class GenericAlias:
__origin__: type
__args__: Tuple[Any, ...]
__parameters__: Tuple[Any, ...]
__args__: tuple[Any, ...]
__parameters__: tuple[Any, ...]
def __init__(self, origin: type, args: Any) -> None: ...
def __getattr__(self, name: str) -> Any: ... # incomplete
@@ -434,6 +433,6 @@ if sys.version_info >= (3, 10):
NotImplementedType = _NotImplementedType # noqa F811 from builtins
@final
class UnionType:
__args__: Tuple[Any, ...]
__args__: tuple[Any, ...]
def __or__(self, obj: Any) -> UnionType: ...
def __ror__(self, obj: Any) -> UnionType: ...