Commit 9afc3fd 1 parent bbdc28e commit 9afc3fd Copy full SHA for 9afc3fd
File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -216,6 +216,21 @@ def visit_stmt(
216
216
217
217
yield from self .visit (child )
218
218
219
+ def visit_yield_expr (self , node : Node ) -> Iterator [Line ]:
220
+ """
221
+ If a "yield expr", treat similarly to "return expr",
222
+ but if it is a "yield from expr", treat expr as a group
223
+ """
224
+ content = node .children [1 ]
225
+ if content .type != syms .yield_arg :
226
+ # this is a "yield expr"
227
+ yield from self .visit_stmt (node , keywords = set (), parens = {"yield" })
228
+ return
229
+ # this is a "yield from expr"
230
+ assert isinstance (content , Node )
231
+ wrap_in_parentheses (content , content .children [1 ], visible = False )
232
+ yield from self .visit_default (node )
233
+
219
234
def visit_typeparams (self , node : Node ) -> Iterator [Line ]:
220
235
yield from self .visit_default (node )
221
236
node .children [0 ].prefix = ""
@@ -1414,6 +1429,7 @@ def maybe_make_parens_invisible_in_atom(
1414
1429
syms .expr_stmt ,
1415
1430
syms .assert_stmt ,
1416
1431
syms .return_stmt ,
1432
+ syms .yield_expr ,
1417
1433
syms .except_clause ,
1418
1434
syms .funcdef ,
1419
1435
syms .with_stmt ,
You can’t perform that action at this time.
0 commit comments