gh-129598: allow multi stmts for ast single with ';'#129620
gh-129598: allow multi stmts for ast single with ';'#129620JelleZijlstra merged 12 commits intopython:mainfrom
Conversation
picnixz
left a comment
There was a problem hiding this comment.
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.
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
picnixz
left a comment
There was a problem hiding this comment.
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