-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
formatterRelated to the formatterRelated to the formatter
Milestone
Description
In #5169 I'm playing with test cases and noticed tuples with trailing comments exceeding line-length don't get formatted.
I added this to the ruff fixtures for tuple formatting:
# Trailing comment should force format
i1 = ("aasdsdasd", "aasdsdasd", "aasdsdasd", "aasdsdasd", "aasdsdasd", "aasdsdasd") # TrailingWith black you'll get:
# Trailing comment should force format
i1 = (
"aasdsdasd",
"aasdsdasd",
"aasdsdasd",
"aasdsdasd",
"aasdsdasd",
"aasdsdasd",
) # TrailingHere's the modified snapshot results:
Snapshot file: crates/ruff_python_formatter/tests/snapshots/format@expression__tuple.py.snap
Snapshot: format@expression/tuple.py
Source: crates/ruff_python_formatter/tests/fixtures.rs:151
Input file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/tuple.py
────────────────────────────────────────────────────────────────────────────────────────
-old snapshot
+new results
────────────┬───────────────────────────────────────────────────────────────────────────
258 258 │ "qweiurpoiqwurepqiurpqirpuqoiwrupqoirupqoirupqoiurpqiorupwqiourpqurpqurpqurpqurpqurpqurüqurqpuriq",
259 259 │ )
260 260 │
261 261 │ # Trailing comment should force format
262 │-i1 = (
263 │- "aasdsdasd",
264 │- "aasdsdasd",
265 │- "aasdsdasd",
266 │- "aasdsdasd",
267 │- "aasdsdasd",
268 │- "aasdsdasd",
269 │-) # Trailing
262 │+i1 = ("aasdsdasd", "aasdsdasd", "aasdsdasd", "aasdsdasd", "aasdsdasd", "aasdsdasd") # Trailing
270 263 │ ```
If I can scoop this up in #5169 I'll submit a separate PR, but I figured I could start by documenting this here.
UPDATE: Looking into it more this looks like a general trailing comment issue rather than specifically a tuple issue. You can repro with dict using:
d2 = {"a": 1000, "b": 1000, "c": 1000, "d": 1000, "e": 1000, "f": 1000, "g": 1000} # TrailingReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
formatterRelated to the formatterRelated to the formatter