Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-129598: allow multi stmts for ast single with ';'#129620

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JelleZijlstra merged 12 commits intopython:mainfromtom-pytel:fix-issue-129598
Mar 19, 2025

Conversation

@tom-pytel
Copy link
Contributor

@tom-pyteltom-pytel commentedFeb 3, 2025
edited by bedevere-appbot
Loading

Had to add a bit more than just a visitor node due to possibility of block statements, so the following are all handled correctly:

$ ./pythonPython3.14.0a4+ (heads/astsingle:9ba281d871,Feb32025,09:15:49) [GCC11.4.0]onlinuxType"help","copyright","credits"or"license"formoreinformation.>>>fromastimport*>>>print(unparse(parse('i = 1; "expr"; raise Exception',mode='exec')))i=1'expr'raiseException>>>print(unparse(parse('i = 1; "expr"; raise Exception',mode='single')))i=1;'expr';raiseException>>>print(unparse(parse('if i:\n "expr"\nelse:\n raise Exception',mode='single')))ifi:'expr'else:raiseException>>>print(unparse(parse('@decorator\ndef func():\n "docstring"\n i = 1; "expr"; raise Exception',mode='single')))@decoratordeffunc():"""docstring"""i=1'expr'raiseException

Copy link
Member

@picnixzpicnixz left a comment

Choose a reason for hiding this comment

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

Can we have tests please?

Copy link
Member

@picnixzpicnixz left a comment

Choose a reason for hiding this comment

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

We might want to address the cleanup parts in a separate PR as it's a bit orthogonal. If possible I'd like@JelleZijlstra's opinion on whether we should worry about the state of the visitor after an error or not, and whether we should worry about whether it's reusable or not.

try:
self._write_docstring_and_traverse_body(node)
finally:
self._type_ignores.clear()
Copy link
Member

Choose a reason for hiding this comment

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

Another question is whether the mapping precedences should be cleared in visit() as well.

@tom-pytel
Copy link
ContributorAuthor

whether we should worry about whether it's reusable or not.

I don't think so. Its not exported from ast module, recreated on every call tounparse() and its not even really a class, just a wrapper around some very simple state.

Copy link
Member

@picnixzpicnixz left a comment

Choose a reason for hiding this comment

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

Except for my question on the precedences mapping, I think it's fine.

@tom-pytel
Copy link
ContributorAuthor

tom-pytel commentedMar 1, 2025
edited
Loading

Except for my question on the precedences mapping, I think it's fine.

Sorry, missed that, what is the question?

Ah, NM, its up there. Probably for someone else do decide and another PR?

@JelleZijlstraJelleZijlstra merged commita8cb5e4 intopython:mainMar 19, 2025
39 checks passed
@tom-pyteltom-pytel deleted the fix-issue-129598 branchMarch 31, 2025 11:06
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@tomasr8tomasr8tomasr8 left review comments

@AA-TurnerAA-TurnerAA-Turner left review comments

@JelleZijlstraJelleZijlstraJelleZijlstra approved these changes

@picnixzpicnixzpicnixz approved these changes

@isidenticalisidenticalAwaiting requested review from isidenticalisidentical is a code owner

@Eclips4Eclips4Awaiting requested review from Eclips4Eclips4 is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@tom-pytel@JelleZijlstra@tomasr8@AA-Turner@picnixz

[8]ページ先頭

©2009-2025 Movatter.jp