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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-104984: remove kwargs and starargs from Call & ClassDef #104986

Merged
merged 1 commit into from
May 26, 2023
Merged
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
9 changes: 3 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 @@ -481,7 +481,7 @@
Comparison operator tokens.


.. class:: Call(func, args, keywords, starargs, kwargs)
.. class:: Call(func, args, keywords)

A function call. ``func`` is the function, which will often be a
:class:`Name` or :class:`Attribute` object. Of the arguments:
Expand All @@ -491,7 +491,7 @@
arguments passed by keyword.

When creating a ``Call`` node, ``args`` and ``keywords`` are required, but
they can be empty lists. ``starargs`` and ``kwargs`` are optional.
they can be empty lists.

.. doctest::

Expand Down Expand Up @@ -1820,7 +1820,7 @@
type_ignores=[])


.. class:: ClassDef(name, bases, keywords, starargs, kwargs, body, decorator_list)
.. class:: ClassDef(name, bases, keywords, body, decorator_list)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also now out of date with the implementation in main and 3.12 due to the addition of type_params argument in PEP 695, but that's being addressed in #104642

Still seems sensible to remove starargs and kwargs in this PR, and let @JelleZijlstra resolve the resulting conflict on this line in #104642

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, backporting this will mean that the PEP 695 docs PR won't backport cleanly, which may cause a bit more of a pain. @JelleZijlstra how do you prefer to handle this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just merge this first, I'll take care of the backports


A class definition.

Expand All @@ -1829,9 +1829,6 @@
* ``keywords`` is a list of :class:`keyword` nodes, principally for 'metaclass'.
Other keywords will be passed to the metaclass, as per `PEP-3115
<https://peps.python.org/pep-3115/>`_.
* ``starargs`` and ``kwargs`` are each a single node, as in a function call.
starargs will be expanded to join the list of base classes, and kwargs will
be passed to the metaclass.
* ``body`` is a list of nodes representing the code within the class
definition.
* ``decorator_list`` is a list of nodes, as in :class:`FunctionDef`.
Expand Down