Fix unstable formatting of trailing end-of-line comments of parenthesized attribute values (#16187)

This commit is contained in:
Micha Reiser 2025-02-18 07:43:51 +00:00 committed by GitHub
parent 82eae511ca
commit 31180a84e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 93 additions and 13 deletions

View file

@ -1,7 +1,6 @@
---
source: crates/ruff_python_formatter/tests/fixtures.rs
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/attribute.py
snapshot_kind: text
---
## Input
```python
@ -159,6 +158,23 @@ result = (
f(111111111111111111111111111111111111111111111111111111111111111111111111111111111)
+ 1
).bit_length()
# Regression test for https://github.com/astral-sh/ruff/issues/16151
result = (
(await query_the_thing(mypy_doesnt_understand)) # type: ignore[x]
.foo()
.bar()
)
(
(
a # trailing end-of-line
# trailing own-line
) # trailing closing parentheses
# dangling before dot
.b # trailing end-of-line
)
```
## Output
@ -295,4 +311,21 @@ result = (
f(111111111111111111111111111111111111111111111111111111111111111111111111111111111)
+ 1
).bit_length()
# Regression test for https://github.com/astral-sh/ruff/issues/16151
result = (
(await query_the_thing(mypy_doesnt_understand)) # type: ignore[x]
.foo()
.bar()
)
(
(
a # trailing end-of-line
# trailing own-line
) # trailing closing parentheses
# dangling before dot
.b # trailing end-of-line
)
```