Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

improvement: Add AST subclass constructors #11880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
May 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update _ast.pyi
improvement: shift `type_comment` attribute to classes which contain it
  • Loading branch information
bzoracler authored May 9, 2024
commit 75a2e8e1af712de4fb3a81c0edfc9a40223120a9
10 changes: 8 additions & 2 deletions 10 stdlib/_ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class AST:
_attributes: ClassVar[tuple[str, ...]]
_fields: ClassVar[tuple[str, ...]]
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
# TODO: Not all nodes have all of the following attributes
type_comment: str | None

class mod(AST): ...
class type_ignore(AST): ...
Expand Down Expand Up @@ -67,6 +65,7 @@ class FunctionDef(stmt):
body: list[stmt]
decorator_list: list[expr]
returns: expr | None
type_comment: str | None
if sys.version_info >= (3, 12):
type_params: list[type_param]

Expand All @@ -80,6 +79,7 @@ class AsyncFunctionDef(stmt):
body: list[stmt]
decorator_list: list[expr]
returns: expr | None
type_comment: str | None
if sys.version_info >= (3, 12):
type_params: list[type_param]

Expand Down Expand Up @@ -111,6 +111,7 @@ class Assign(stmt):
__match_args__ = ("targets", "value", "type_comment")
targets: list[expr]
value: expr
type_comment: str | None

class AugAssign(stmt):
if sys.version_info >= (3, 10):
Expand All @@ -134,6 +135,7 @@ class For(stmt):
iter: expr
body: list[stmt]
orelse: list[stmt]
type_comment: str | None

class AsyncFor(stmt):
if sys.version_info >= (3, 10):
Expand All @@ -142,6 +144,7 @@ class AsyncFor(stmt):
iter: expr
body: list[stmt]
orelse: list[stmt]
type_comment: str | None

class While(stmt):
if sys.version_info >= (3, 10):
Expand All @@ -162,12 +165,14 @@ class With(stmt):
__match_args__ = ("items", "body", "type_comment")
items: list[withitem]
body: list[stmt]
type_comment: str | None

class AsyncWith(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("items", "body", "type_comment")
items: list[withitem]
body: list[stmt]
type_comment: str | None

class Raise(stmt):
if sys.version_info >= (3, 10):
Expand Down Expand Up @@ -506,6 +511,7 @@ class arg(AST):
__match_args__ = ("arg", "annotation", "type_comment")
arg: _Identifier
annotation: expr | None
type_comment: str | None

class keyword(AST):
lineno: int
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.