Skip to content
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

gh-104799: Move location of type_params AST fields #104828

Merged
merged 3 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 6 additions & 6 deletions Doc/library/ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,6 @@ Function and class definitions
body=[
FunctionDef(
name='f',
type_params=[],
args=arguments(
posonlyargs=[],
args=[
Expand All @@ -1749,7 +1748,8 @@ Function and class definitions
decorator_list=[
Name(id='decorator1', ctx=Load()),
Name(id='decorator2', ctx=Load())],
returns=Constant(value='return annotation'))],
returns=Constant(value='return annotation'),
type_params=[])],
type_ignores=[])


Expand Down Expand Up @@ -1848,7 +1848,6 @@ Function and class definitions
body=[
ClassDef(
name='Foo',
type_params=[],
bases=[
Name(id='base1', ctx=Load()),
Name(id='base2', ctx=Load())],
Expand All @@ -1860,7 +1859,8 @@ Function and class definitions
Pass()],
decorator_list=[
Name(id='decorator1', ctx=Load()),
Name(id='decorator2', ctx=Load())])],
Name(id='decorator2', ctx=Load())],
type_params=[])],
type_ignores=[])

Async and await
Expand All @@ -1887,7 +1887,6 @@ Async and await
body=[
AsyncFunctionDef(
name='f',
type_params=[],
args=arguments(
posonlyargs=[],
args=[],
Expand All @@ -1901,7 +1900,8 @@ Async and await
func=Name(id='other_func', ctx=Load()),
args=[],
keywords=[])))],
decorator_list=[])],
decorator_list=[],
type_params=[])],
type_ignores=[])


Expand Down
12 changes: 6 additions & 6 deletions Grammar/python.gram
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ class_def[stmt_ty]:
class_def_raw[stmt_ty]:
| invalid_class_def_raw
| 'class' a=NAME t=[type_params] b=['(' z=[arguments] ')' { z }] ':' c=block {
_PyAST_ClassDef(a->v.Name.id, t,
_PyAST_ClassDef(a->v.Name.id,
(b) ? ((expr_ty) b)->v.Call.args : NULL,
(b) ? ((expr_ty) b)->v.Call.keywords : NULL,
c, NULL, EXTRA) }
c, NULL, t, EXTRA) }

# Function definitions
# --------------------
Expand All @@ -269,17 +269,17 @@ function_def[stmt_ty]:
function_def_raw[stmt_ty]:
| invalid_def_raw
| 'def' n=NAME t=[type_params] &&'(' params=[params] ')' a=['->' z=expression { z }] &&':' tc=[func_type_comment] b=block {
_PyAST_FunctionDef(n->v.Name.id, t,
_PyAST_FunctionDef(n->v.Name.id,
(params) ? params : CHECK(arguments_ty, _PyPegen_empty_arguments(p)),
b, NULL, a, NEW_TYPE_COMMENT(p, tc), EXTRA) }
b, NULL, a, NEW_TYPE_COMMENT(p, tc), t, EXTRA) }
| ASYNC 'def' n=NAME t=[type_params] &&'(' params=[params] ')' a=['->' z=expression { z }] &&':' tc=[func_type_comment] b=block {
CHECK_VERSION(
stmt_ty,
5,
"Async functions are",
_PyAST_AsyncFunctionDef(n->v.Name.id, t,
_PyAST_AsyncFunctionDef(n->v.Name.id,
(params) ? params : CHECK(arguments_ty, _PyPegen_empty_arguments(p)),
b, NULL, a, NEW_TYPE_COMMENT(p, tc), EXTRA)
b, NULL, a, NEW_TYPE_COMMENT(p, tc), t, EXTRA)
) }

# Function parameters
Expand Down
36 changes: 18 additions & 18 deletions Include/internal/pycore_ast.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading