-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
gh-129598: allow multi stmts for ast single with ';' #129620
Conversation
There was a problem hiding this 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?
There was a problem hiding this 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() |
There was a problem hiding this comment.
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.
I don't think so. Its not exported from ast module, recreated on every call to |
Misc/NEWS.d/next/Library/2025-02-03-16-27-14.gh-issue-129598.0js33I.rst
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
Sorry, missed that, what is the question? Ah, NM, its up there. Probably for someone else do decide and another PR? |
Had to add a bit more than just a visitor node due to possibility of block statements, so the following are all handled correctly:
ast.parse(..., mode='single')
parses of multiple statements which are then not unparsed #129598