Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.

Commit 93bef83

Browse files
committed
Support trailing comma in with list
1 parent 799a686 commit 93bef83

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

rewrite-python/src/main/java/org/openrewrite/python/internal/PythonPrinter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,9 @@ public J visitTry(J.Try tryable, PrintOutputCapture<P> p) {
12731273
}
12741274

12751275
visitSpace(resource.getAfter(), Location.TRY_RESOURCE_SUFFIX, p);
1276+
visitMarkers(resource.getMarkers(), p);
12761277
}
1278+
visitMarkers(resources.getMarkers(), p);
12771279
if (!omitParentheses) {
12781280
p.append(")");
12791281
}

rewrite/tests/python/all/with_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ def test_with():
1515
)
1616

1717

18+
def test_with_trailing_comma():
19+
# language=python
20+
rewrite_run(
21+
python(
22+
"""\
23+
with (len([]) as x , ):
24+
pass
25+
"""
26+
)
27+
)
28+
29+
1830
def test_with_parens():
1931
# language=python
2032
rewrite_run(

0 commit comments

Comments
 (0)