-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid parenthesizing comprehension element (#6198)
## Summary This PR adds a new precedence level for the comprehension element. This fixes the generator to not add parentheses around the comprehension element every time. The new precedence level is `COMPREHENSION_ELEMENT` and it should occur after the `NAMED_EXPR` precedence level because named expressions are always parenthesized. This matches the behavior of Python `ast.unparse` and tested with the following snippet: ```python import ast code = "" ast.unparse(ast.parse(code)) ``` ## Test Plan Add a bunch of test cases for all the valid nodes at that position. fixes: #5777
- Loading branch information
1 parent
0274de1
commit cb34e6d
Showing
1 changed file
with
22 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters