Skip to content

gh-135959: Mark ast.ImportFrom.level as required #135960

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions Doc/library/ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,11 @@ Imports
alias(name='z')],
level=0)])

.. versionchanged:: next

Previously, the ``level`` field was marked as optional in the interface
definition, although the CPython parser always sets this field to an integer.


.. class:: alias(name, asname)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The ``level`` field on :class:`ast.ImportFrom` is now marked as required.
The parser always sets it to an integer.
2 changes: 1 addition & 1 deletion Parser/Python.asdl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module Python
| Assert(expr test, expr? msg)

| Import(alias* names)
| ImportFrom(identifier? module, alias* names, int? level)
| ImportFrom(identifier? module, alias* names, int level)

| Global(identifier* names)
| Nonlocal(identifier* names)
Expand Down
19 changes: 6 additions & 13 deletions Python/Python-ast.c

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

Loading