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

[3.12] gh-104799: Move location of type_params AST fields (GH-104828) #104974

Merged
merged 2 commits into from
May 30, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
136 changes: 68 additions & 68 deletions Doc/data/python3.12.abi

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Doc/library/ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@

.. class:: AST

This is the base of all AST node classes. The actual node classes are

Check warning on line 46 in Doc/library/ast.rst

View workflow job for this annotation

GitHub Actions / Docs

py:mod reference target not found: _ast
derived from the :file:`Parser/Python.asdl` file, which is reproduced
:ref:`above <abstract-grammar>`. They are defined in the :mod:`_ast` C
module and re-exported in :mod:`ast`.

There is one class defined for each left-hand side symbol in the abstract

Check warning on line 51 in Doc/library/ast.rst

View workflow job for this annotation

GitHub Actions / Docs

py:class reference target not found: ast.stmt

Check warning on line 51 in Doc/library/ast.rst

View workflow job for this annotation

GitHub Actions / Docs

py:class reference target not found: ast.expr

Check warning on line 51 in Doc/library/ast.rst

View workflow job for this annotation

GitHub Actions / Docs

py:class reference target not found: ast.expr
grammar (for example, :class:`ast.stmt` or :class:`ast.expr`). In addition,
there is one class defined for each constructor on the right-hand side; these
classes inherit from the classes for the left-hand side trees. For example,
Expand All @@ -64,7 +64,7 @@
Each concrete class has an attribute :attr:`_fields` which gives the names
of all child nodes.

Each instance of a concrete class has one attribute for each child node,

Check warning on line 67 in Doc/library/ast.rst

View workflow job for this annotation

GitHub Actions / Docs

py:attr reference target not found: left

Check warning on line 67 in Doc/library/ast.rst

View workflow job for this annotation

GitHub Actions / Docs

py:class reference target not found: ast.expr
of the type as defined in the grammar. For example, :class:`ast.BinOp`
instances have an attribute :attr:`left` of type :class:`ast.expr`.

Expand All @@ -79,7 +79,7 @@
end_lineno
end_col_offset

Instances of :class:`ast.expr` and :class:`ast.stmt` subclasses have

Check warning on line 82 in Doc/library/ast.rst

View workflow job for this annotation

GitHub Actions / Docs

py:class reference target not found: ast.expr

Check warning on line 82 in Doc/library/ast.rst

View workflow job for this annotation

GitHub Actions / Docs

py:class reference target not found: ast.stmt
:attr:`lineno`, :attr:`col_offset`, :attr:`end_lineno`, and
:attr:`end_col_offset` attributes. The :attr:`lineno` and :attr:`end_lineno`
are the first and last line numbers of source text span (1-indexed so the
Expand All @@ -93,9 +93,9 @@
one can get the source segment of a one-line expression node using
``source_line[node.col_offset : node.end_col_offset]``.

The constructor of a class :class:`ast.T` parses its arguments as follows:

Check warning on line 96 in Doc/library/ast.rst

View workflow job for this annotation

GitHub Actions / Docs

py:class reference target not found: ast.T

* If there are positional arguments, there must be as many as there are items

Check warning on line 98 in Doc/library/ast.rst

View workflow job for this annotation

GitHub Actions / Docs

py:attr reference target not found: T._fields
in :attr:`T._fields`; they will be assigned as attributes of these names.
* If there are keyword arguments, they will set the attributes of the same
names to the given values.
Expand Down Expand Up @@ -1724,7 +1724,6 @@
body=[
FunctionDef(
name='f',
type_params=[],
args=arguments(
posonlyargs=[],
args=[
Expand All @@ -1749,7 +1748,8 @@
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 @@
body=[
ClassDef(
name='Foo',
type_params=[],
bases=[
Name(id='base1', ctx=Load()),
Name(id='base2', ctx=Load())],
Expand All @@ -1860,7 +1859,8 @@
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 @@
body=[
AsyncFunctionDef(
name='f',
type_params=[],
args=arguments(
posonlyargs=[],
args=[],
Expand All @@ -1901,7 +1900,8 @@
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.