mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-24 03:51:52 +08:00
change ast files to use new union syntax (#5880)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import sys
|
||||
import typing
|
||||
from typing import Any, ClassVar, Optional
|
||||
from typing import Any, ClassVar
|
||||
from typing_extensions import Literal
|
||||
|
||||
PyCF_ONLY_AST: int
|
||||
@@ -18,9 +18,9 @@ class AST:
|
||||
lineno: int
|
||||
col_offset: int
|
||||
if sys.version_info >= (3, 8):
|
||||
end_lineno: Optional[int]
|
||||
end_col_offset: Optional[int]
|
||||
type_comment: Optional[str]
|
||||
end_lineno: int | None
|
||||
end_col_offset: int | None
|
||||
type_comment: str | None
|
||||
|
||||
class mod(AST): ...
|
||||
|
||||
@@ -50,14 +50,14 @@ class FunctionDef(stmt):
|
||||
args: arguments
|
||||
body: typing.List[stmt]
|
||||
decorator_list: typing.List[expr]
|
||||
returns: Optional[expr]
|
||||
returns: expr | None
|
||||
|
||||
class AsyncFunctionDef(stmt):
|
||||
name: _identifier
|
||||
args: arguments
|
||||
body: typing.List[stmt]
|
||||
decorator_list: typing.List[expr]
|
||||
returns: Optional[expr]
|
||||
returns: expr | None
|
||||
|
||||
class ClassDef(stmt):
|
||||
name: _identifier
|
||||
@@ -67,7 +67,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]
|
||||
@@ -84,7 +84,7 @@ class AugAssign(stmt):
|
||||
class AnnAssign(stmt):
|
||||
target: expr
|
||||
annotation: expr
|
||||
value: Optional[expr]
|
||||
value: expr | None
|
||||
simple: int
|
||||
|
||||
class For(stmt):
|
||||
@@ -118,8 +118,8 @@ class AsyncWith(stmt):
|
||||
body: typing.List[stmt]
|
||||
|
||||
class Raise(stmt):
|
||||
exc: Optional[expr]
|
||||
cause: Optional[expr]
|
||||
exc: expr | None
|
||||
cause: expr | None
|
||||
|
||||
class Try(stmt):
|
||||
body: typing.List[stmt]
|
||||
@@ -129,13 +129,13 @@ class Try(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: int
|
||||
|
||||
@@ -176,7 +176,7 @@ class IfExp(expr):
|
||||
orelse: expr
|
||||
|
||||
class Dict(expr):
|
||||
keys: typing.List[Optional[expr]]
|
||||
keys: typing.List[expr | None]
|
||||
values: typing.List[expr]
|
||||
|
||||
class Set(expr):
|
||||
@@ -203,7 +203,7 @@ class Await(expr):
|
||||
value: expr
|
||||
|
||||
class Yield(expr):
|
||||
value: Optional[expr]
|
||||
value: expr | None
|
||||
|
||||
class YieldFrom(expr):
|
||||
value: expr
|
||||
@@ -220,8 +220,8 @@ class Call(expr):
|
||||
|
||||
class FormattedValue(expr):
|
||||
value: expr
|
||||
conversion: Optional[int]
|
||||
format_spec: Optional[expr]
|
||||
conversion: int | None
|
||||
format_spec: expr | None
|
||||
|
||||
class JoinedStr(expr):
|
||||
values: typing.List[expr]
|
||||
@@ -239,7 +239,7 @@ if sys.version_info < (3, 8):
|
||||
|
||||
class Constant(expr):
|
||||
value: Any # None, str, bytes, bool, int, float, complex, Ellipsis
|
||||
kind: Optional[str]
|
||||
kind: str | None
|
||||
# Aliases for value, for backwards compatibility
|
||||
s: Any
|
||||
n: complex
|
||||
@@ -261,9 +261,9 @@ else:
|
||||
_SliceT = slice
|
||||
|
||||
class Slice(_SliceT):
|
||||
lower: Optional[expr]
|
||||
upper: Optional[expr]
|
||||
step: Optional[expr]
|
||||
lower: expr | None
|
||||
upper: expr | None
|
||||
step: expr | None
|
||||
|
||||
if sys.version_info < (3, 9):
|
||||
class ExtSlice(slice):
|
||||
@@ -347,35 +347,35 @@ class comprehension(AST):
|
||||
class excepthandler(AST): ...
|
||||
|
||||
class ExceptHandler(excepthandler):
|
||||
type: Optional[expr]
|
||||
name: Optional[_identifier]
|
||||
type: expr | None
|
||||
name: _identifier | None
|
||||
body: typing.List[stmt]
|
||||
|
||||
class arguments(AST):
|
||||
if sys.version_info >= (3, 8):
|
||||
posonlyargs: typing.List[arg]
|
||||
args: typing.List[arg]
|
||||
vararg: Optional[arg]
|
||||
vararg: arg | None
|
||||
kwonlyargs: typing.List[arg]
|
||||
kw_defaults: typing.List[Optional[expr]]
|
||||
kwarg: Optional[arg]
|
||||
kw_defaults: typing.List[expr | None]
|
||||
kwarg: arg | None
|
||||
defaults: typing.List[expr]
|
||||
|
||||
class arg(AST):
|
||||
arg: _identifier
|
||||
annotation: Optional[expr]
|
||||
annotation: expr | None
|
||||
|
||||
class keyword(AST):
|
||||
arg: Optional[_identifier]
|
||||
arg: _identifier | None
|
||||
value: expr
|
||||
|
||||
class alias(AST):
|
||||
name: _identifier
|
||||
asname: Optional[_identifier]
|
||||
asname: _identifier | None
|
||||
|
||||
class withitem(AST):
|
||||
context_expr: expr
|
||||
optional_vars: Optional[expr]
|
||||
optional_vars: expr | None
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
class Match(stmt):
|
||||
@@ -386,7 +386,7 @@ if sys.version_info >= (3, 10):
|
||||
_pattern = pattern
|
||||
class match_case(AST):
|
||||
pattern: _pattern
|
||||
guard: Optional[expr]
|
||||
guard: expr | None
|
||||
body: typing.List[stmt]
|
||||
class MatchValue(pattern):
|
||||
value: expr
|
||||
@@ -395,18 +395,18 @@ if sys.version_info >= (3, 10):
|
||||
class MatchSequence(pattern):
|
||||
patterns: typing.List[pattern]
|
||||
class MatchStar(pattern):
|
||||
name: Optional[_identifier]
|
||||
name: _identifier | None
|
||||
class MatchMapping(pattern):
|
||||
keys: typing.List[expr]
|
||||
patterns: typing.List[pattern]
|
||||
rest: Optional[_identifier]
|
||||
rest: _identifier | None
|
||||
class MatchClass(pattern):
|
||||
cls: expr
|
||||
patterns: typing.List[pattern]
|
||||
kwd_attrs: typing.List[_identifier]
|
||||
kwd_patterns: typing.List[pattern]
|
||||
class MatchAs(pattern):
|
||||
pattern: Optional[_pattern]
|
||||
name: Optional[_identifier]
|
||||
pattern: _pattern | None
|
||||
name: _identifier | None
|
||||
class MatchOr(pattern):
|
||||
patterns: typing.List[pattern]
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# sys.
|
||||
import sys
|
||||
import typing as _typing
|
||||
from typing import Any, Iterator, Optional, TypeVar, Union, overload
|
||||
from typing import Any, Iterator, TypeVar, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
from _ast import * # type: ignore
|
||||
@@ -150,7 +150,7 @@ class NodeVisitor:
|
||||
class NodeTransformer(NodeVisitor):
|
||||
def generic_visit(self, node: AST) -> AST: ...
|
||||
# TODO: Override the visit_* methods with better return types.
|
||||
# The usual return type is Optional[AST], but Iterable[AST]
|
||||
# The usual return type is AST | None, but Iterable[AST]
|
||||
# is also allowed in some cases -- this needs to be mapped.
|
||||
|
||||
_T = TypeVar("_T", bound=AST)
|
||||
@@ -158,28 +158,28 @@ _T = TypeVar("_T", bound=AST)
|
||||
if sys.version_info >= (3, 8):
|
||||
@overload
|
||||
def parse(
|
||||
source: Union[str, bytes],
|
||||
filename: Union[str, bytes] = ...,
|
||||
source: str | bytes,
|
||||
filename: str | bytes = ...,
|
||||
mode: Literal["exec"] = ...,
|
||||
*,
|
||||
type_comments: bool = ...,
|
||||
feature_version: Union[None, int, _typing.Tuple[int, int]] = ...,
|
||||
feature_version: None | int | _typing.Tuple[int, int] = ...,
|
||||
) -> Module: ...
|
||||
@overload
|
||||
def parse(
|
||||
source: Union[str, bytes],
|
||||
filename: Union[str, bytes] = ...,
|
||||
source: str | bytes,
|
||||
filename: str | bytes = ...,
|
||||
mode: str = ...,
|
||||
*,
|
||||
type_comments: bool = ...,
|
||||
feature_version: Union[None, int, _typing.Tuple[int, int]] = ...,
|
||||
feature_version: None | int | _typing.Tuple[int, int] = ...,
|
||||
) -> AST: ...
|
||||
|
||||
else:
|
||||
@overload
|
||||
def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: Literal["exec"] = ...) -> Module: ...
|
||||
def parse(source: str | bytes, filename: str | bytes = ..., mode: Literal["exec"] = ...) -> Module: ...
|
||||
@overload
|
||||
def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> AST: ...
|
||||
def parse(source: str | bytes, filename: str | bytes = ..., mode: str = ...) -> AST: ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
def unparse(ast_obj: AST) -> str: ...
|
||||
@@ -188,20 +188,20 @@ def copy_location(new_node: _T, old_node: AST) -> _T: ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
def dump(
|
||||
node: AST, annotate_fields: bool = ..., include_attributes: bool = ..., *, indent: Union[int, str, None] = ...
|
||||
node: AST, annotate_fields: bool = ..., include_attributes: bool = ..., *, indent: int | str | None = ...
|
||||
) -> str: ...
|
||||
|
||||
else:
|
||||
def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ...
|
||||
|
||||
def fix_missing_locations(node: _T) -> _T: ...
|
||||
def get_docstring(node: AST, clean: bool = ...) -> Optional[str]: ...
|
||||
def get_docstring(node: AST, clean: bool = ...) -> str | None: ...
|
||||
def increment_lineno(node: _T, n: int = ...) -> _T: ...
|
||||
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, AST]) -> Any: ...
|
||||
def literal_eval(node_or_string: str | AST) -> Any: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
def get_source_segment(source: str, node: AST, *, padded: bool = ...) -> Optional[str]: ...
|
||||
def get_source_segment(source: str, node: AST, *, padded: bool = ...) -> str | None: ...
|
||||
|
||||
def walk(node: AST) -> Iterator[AST]: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import typing
|
||||
from typing import Any, Iterator, Optional, Union
|
||||
from typing import Any, Iterator
|
||||
|
||||
class NodeVisitor:
|
||||
def visit(self, node: AST) -> Any: ...
|
||||
@@ -8,15 +8,15 @@ class NodeVisitor:
|
||||
class NodeTransformer(NodeVisitor):
|
||||
def generic_visit(self, node: AST) -> None: ...
|
||||
|
||||
def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> AST: ...
|
||||
def parse(source: str | bytes, filename: str | bytes = ..., mode: str = ...) -> AST: ...
|
||||
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: ...
|
||||
def get_docstring(node: AST, clean: bool = ...) -> Optional[bytes]: ...
|
||||
def get_docstring(node: AST, clean: bool = ...) -> bytes | None: ...
|
||||
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, AST]) -> Any: ...
|
||||
def literal_eval(node_or_string: str | AST) -> Any: ...
|
||||
def walk(node: AST) -> Iterator[AST]: ...
|
||||
|
||||
PyCF_ONLY_AST: int
|
||||
@@ -58,7 +58,7 @@ class FunctionDef(stmt):
|
||||
args: arguments
|
||||
body: typing.List[stmt]
|
||||
decorator_list: typing.List[expr]
|
||||
type_comment: Optional[str]
|
||||
type_comment: str | None
|
||||
|
||||
class ClassDef(stmt):
|
||||
name: identifier
|
||||
@@ -67,7 +67,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]
|
||||
@@ -75,7 +75,7 @@ class Delete(stmt):
|
||||
class Assign(stmt):
|
||||
targets: typing.List[expr]
|
||||
value: expr
|
||||
type_comment: Optional[str]
|
||||
type_comment: str | None
|
||||
|
||||
class AugAssign(stmt):
|
||||
target: expr
|
||||
@@ -83,7 +83,7 @@ class AugAssign(stmt):
|
||||
value: expr
|
||||
|
||||
class Print(stmt):
|
||||
dest: Optional[expr]
|
||||
dest: expr | None
|
||||
values: typing.List[expr]
|
||||
nl: bool
|
||||
|
||||
@@ -92,7 +92,7 @@ class For(stmt):
|
||||
iter: expr
|
||||
body: typing.List[stmt]
|
||||
orelse: typing.List[stmt]
|
||||
type_comment: Optional[str]
|
||||
type_comment: str | None
|
||||
|
||||
class While(stmt):
|
||||
test: expr
|
||||
@@ -106,14 +106,14 @@ class If(stmt):
|
||||
|
||||
class With(stmt):
|
||||
context_expr: expr
|
||||
optional_vars: Optional[expr]
|
||||
optional_vars: expr | None
|
||||
body: typing.List[stmt]
|
||||
type_comment: Optional[str]
|
||||
type_comment: str | None
|
||||
|
||||
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]
|
||||
@@ -126,20 +126,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]
|
||||
@@ -155,9 +155,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]
|
||||
@@ -218,7 +218,7 @@ class GeneratorExp(expr):
|
||||
generators: typing.List[comprehension]
|
||||
|
||||
class Yield(expr):
|
||||
value: Optional[expr]
|
||||
value: expr | None
|
||||
|
||||
class Compare(expr):
|
||||
left: expr
|
||||
@@ -229,17 +229,17 @@ 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
|
||||
|
||||
class Num(expr):
|
||||
n: Union[int, float, complex]
|
||||
n: int | float | complex
|
||||
|
||||
class Str(expr):
|
||||
s: Union[str, bytes]
|
||||
s: str | bytes
|
||||
kind: str
|
||||
|
||||
class Attribute(expr):
|
||||
@@ -310,18 +310,18 @@ class comprehension(AST):
|
||||
ifs: typing.List[expr]
|
||||
|
||||
class ExceptHandler(AST):
|
||||
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]
|
||||
type_comments: typing.List[Optional[str]]
|
||||
type_comments: typing.List[str | None]
|
||||
|
||||
class keyword(AST):
|
||||
arg: identifier
|
||||
@@ -329,7 +329,7 @@ class keyword(AST):
|
||||
|
||||
class alias(AST):
|
||||
name: identifier
|
||||
asname: Optional[identifier]
|
||||
asname: identifier | None
|
||||
|
||||
class TypeIgnore(AST):
|
||||
lineno: int
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import typing
|
||||
from typing import Any, Iterator, Optional, Union
|
||||
from typing import Any, Iterator
|
||||
|
||||
class NodeVisitor:
|
||||
def visit(self, node: AST) -> Any: ...
|
||||
@@ -8,15 +8,15 @@ class NodeVisitor:
|
||||
class NodeTransformer(NodeVisitor):
|
||||
def generic_visit(self, node: AST) -> None: ...
|
||||
|
||||
def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ..., feature_version: int = ...) -> AST: ...
|
||||
def parse(source: str | bytes, filename: str | bytes = ..., mode: str = ..., feature_version: int = ...) -> AST: ...
|
||||
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: ...
|
||||
def get_docstring(node: AST, clean: bool = ...) -> Optional[str]: ...
|
||||
def get_docstring(node: AST, clean: bool = ...) -> str | None: ...
|
||||
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, AST]) -> Any: ...
|
||||
def literal_eval(node_or_string: str | AST) -> Any: ...
|
||||
def walk(node: AST) -> Iterator[AST]: ...
|
||||
|
||||
PyCF_ONLY_AST: int
|
||||
@@ -58,16 +58,16 @@ class FunctionDef(stmt):
|
||||
args: arguments
|
||||
body: typing.List[stmt]
|
||||
decorator_list: typing.List[expr]
|
||||
returns: Optional[expr]
|
||||
type_comment: Optional[str]
|
||||
returns: expr | None
|
||||
type_comment: str | None
|
||||
|
||||
class AsyncFunctionDef(stmt):
|
||||
name: identifier
|
||||
args: arguments
|
||||
body: typing.List[stmt]
|
||||
decorator_list: typing.List[expr]
|
||||
returns: Optional[expr]
|
||||
type_comment: Optional[str]
|
||||
returns: expr | None
|
||||
type_comment: str | None
|
||||
|
||||
class ClassDef(stmt):
|
||||
name: identifier
|
||||
@@ -77,7 +77,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]
|
||||
@@ -85,7 +85,7 @@ class Delete(stmt):
|
||||
class Assign(stmt):
|
||||
targets: typing.List[expr]
|
||||
value: expr
|
||||
type_comment: Optional[str]
|
||||
type_comment: str | None
|
||||
|
||||
class AugAssign(stmt):
|
||||
target: expr
|
||||
@@ -95,7 +95,7 @@ class AugAssign(stmt):
|
||||
class AnnAssign(stmt):
|
||||
target: expr
|
||||
annotation: expr
|
||||
value: Optional[expr]
|
||||
value: expr | None
|
||||
simple: int
|
||||
|
||||
class For(stmt):
|
||||
@@ -103,14 +103,14 @@ class For(stmt):
|
||||
iter: expr
|
||||
body: typing.List[stmt]
|
||||
orelse: typing.List[stmt]
|
||||
type_comment: Optional[str]
|
||||
type_comment: str | None
|
||||
|
||||
class AsyncFor(stmt):
|
||||
target: expr
|
||||
iter: expr
|
||||
body: typing.List[stmt]
|
||||
orelse: typing.List[stmt]
|
||||
type_comment: Optional[str]
|
||||
type_comment: str | None
|
||||
|
||||
class While(stmt):
|
||||
test: expr
|
||||
@@ -125,16 +125,16 @@ class If(stmt):
|
||||
class With(stmt):
|
||||
items: typing.List[withitem]
|
||||
body: typing.List[stmt]
|
||||
type_comment: Optional[str]
|
||||
type_comment: str | None
|
||||
|
||||
class AsyncWith(stmt):
|
||||
items: typing.List[withitem]
|
||||
body: typing.List[stmt]
|
||||
type_comment: Optional[str]
|
||||
type_comment: str | None
|
||||
|
||||
class Raise(stmt):
|
||||
exc: Optional[expr]
|
||||
cause: Optional[expr]
|
||||
exc: expr | None
|
||||
cause: expr | None
|
||||
|
||||
class Try(stmt):
|
||||
body: typing.List[stmt]
|
||||
@@ -144,15 +144,15 @@ class Try(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 Global(stmt):
|
||||
names: typing.List[identifier]
|
||||
@@ -171,9 +171,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]
|
||||
@@ -235,7 +235,7 @@ class Await(expr):
|
||||
value: expr
|
||||
|
||||
class Yield(expr):
|
||||
value: Optional[expr]
|
||||
value: expr | None
|
||||
|
||||
class YieldFrom(expr):
|
||||
value: expr
|
||||
@@ -251,7 +251,7 @@ class Call(expr):
|
||||
keywords: typing.List[keyword]
|
||||
|
||||
class Num(expr):
|
||||
n: Union[float, int, complex]
|
||||
n: float | int | complex
|
||||
|
||||
class Str(expr):
|
||||
s: str
|
||||
@@ -259,8 +259,8 @@ class Str(expr):
|
||||
|
||||
class FormattedValue(expr):
|
||||
value: expr
|
||||
conversion: typing.Optional[int]
|
||||
format_spec: typing.Optional[expr]
|
||||
conversion: int | None
|
||||
format_spec: expr | None
|
||||
|
||||
class JoinedStr(expr):
|
||||
values: typing.List[expr]
|
||||
@@ -347,38 +347,38 @@ class comprehension(AST):
|
||||
is_async: int
|
||||
|
||||
class ExceptHandler(AST):
|
||||
type: Optional[expr]
|
||||
name: Optional[identifier]
|
||||
type: expr | None
|
||||
name: identifier | None
|
||||
body: typing.List[stmt]
|
||||
lineno: int
|
||||
col_offset: int
|
||||
|
||||
class arguments(AST):
|
||||
args: typing.List[arg]
|
||||
vararg: Optional[arg]
|
||||
vararg: arg | None
|
||||
kwonlyargs: typing.List[arg]
|
||||
kw_defaults: typing.List[expr]
|
||||
kwarg: Optional[arg]
|
||||
kwarg: arg | None
|
||||
defaults: typing.List[expr]
|
||||
|
||||
class arg(AST):
|
||||
arg: identifier
|
||||
annotation: Optional[expr]
|
||||
annotation: expr | None
|
||||
lineno: int
|
||||
col_offset: int
|
||||
type_comment: typing.Optional[str]
|
||||
type_comment: str | None
|
||||
|
||||
class keyword(AST):
|
||||
arg: Optional[identifier]
|
||||
arg: identifier | None
|
||||
value: expr
|
||||
|
||||
class alias(AST):
|
||||
name: identifier
|
||||
asname: Optional[identifier]
|
||||
asname: identifier | None
|
||||
|
||||
class withitem(AST):
|
||||
context_expr: expr
|
||||
optional_vars: Optional[expr]
|
||||
optional_vars: expr | None
|
||||
|
||||
class TypeIgnore(AST):
|
||||
lineno: int
|
||||
|
||||
Reference in New Issue
Block a user