Skip to content

Commit

Permalink
Correct whitespace handling for with item with parens
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Nov 14, 2024
1 parent 263d33e commit 2710b03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 3 additions & 5 deletions rewrite/rewrite/python/_parser_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,9 @@ def visit_With(self, node):

if parenthesized and self._parentheses_stack and self._parentheses_stack[-1] is parens_handler:
self._cursor += 1
self._parentheses_stack.pop()
resources_container = JContainer(
items_prefix,
resources,
Markers.EMPTY
resources_container = self._parentheses_stack.pop()[0](
JContainer(items_prefix, resources, Markers.EMPTY),
Space.EMPTY
)
else:
resources_container = JContainer(
Expand Down
3 changes: 2 additions & 1 deletion rewrite/tests/python/all/with_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def test_with_parens():
rewrite_run(
python(
"""\
with (open('/dev/null') as x):
with (
open('/dev/null') as x):
pass
"""
)
Expand Down

0 comments on commit 2710b03

Please sign in to comment.