Skip to content

gh-142349: Fix ast.unparse for lazy import statements - #144893

Merged
pablogsal merged 1 commit into
python:mainfrom
pablogsal:unparse-lazy
Feb 16, 2026
Merged

gh-142349: Fix ast.unparse for lazy import statements#144893
pablogsal merged 1 commit into
python:mainfrom
pablogsal:unparse-lazy

Conversation

@pablogsal

@pablogsalpablogsal commented Feb 16, 2026

Copy link
Copy Markdown
Member

The unparser was not handling the is_lazy attribute on Import and
ImportFrom AST nodes, causing lazy imports to be unparsed as regular
imports. This broke the round-trip (parse → unparse → reparse) for
any file containing lazy import statements.

The unparser was not handling the `is_lazy` attribute on Import and
ImportFrom AST nodes, causing lazy imports to be unparsed as regular
imports. This broke the round-trip (parse → unparse → reparse) for
any file containing `lazy import` statements.

@itamaroitamaro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be covered by additional unittests?

@pablogsal

Copy link
Copy Markdown
MemberAuthor

Should this be covered by additional unittests?

For now I am landing this to stop the inevitable failure in all the buildbots that build with -uall we can then add unittest later

@pablogsal
pablogsal merged commit 18c04f2 into python:mainFeb 16, 2026
53 checks passed
@pablogsal
pablogsal deleted the unparse-lazy branch February 16, 2026 22:57
brijkapadia pushed a commit to brijkapadia/cpython that referenced this pull request Feb 28, 2026
…44893)
The unparser was not handling the `is_lazy` attribute on Import and
ImportFrom AST nodes, causing lazy imports to be unparsed as regular
imports. This broke the round-trip (parse → unparse → reparse) for
any file containing `lazy import` statements.
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
…44893)
The unparser was not handling the `is_lazy` attribute on Import and
ImportFrom AST nodes, causing lazy imports to be unparsed as regular
imports. This broke the round-trip (parse → unparse → reparse) for
any file containing `lazy import` statements.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@pablogsal@itamaro@Yhg1s