ruff/crates/ruff_python_formatter/src
Dylan 8156b45173
Avoid syntax error when formatting attribute expressions with outer parentheses, parenthesized value, and trailing comment on value (#20418)
Closes #19350 

This fixes a syntax error caused by formatting. However, the new tests reveal that there are some cases where formatting attributes with certain comments behaves strangely, both before and after this PR, so some more polish may be in order.

For example, without parentheses around the value, and both before and after this PR, we have:

```python
# unformatted
variable = (
    something # a comment
    .first_method("some string")
)

# formatted
variable = something.first_method("some string")  # a comment
```

which is probably not where the comment ought to go.
2025-11-17 09:11:36 -06:00
..
comments Adjust own-line comment placement between branches (#21185) 2025-11-17 07:30:34 -06:00
expression Avoid syntax error when formatting attribute expressions with outer parentheses, parenthesized value, and trailing comment on value (#20418) 2025-11-17 09:11:36 -06:00
module [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
other Avoid reusing nested, interpolated quotes before Python 3.12 (#20930) 2025-10-17 08:49:16 -04:00
pattern Avoid extra parentheses for long match patterns with as captures (#21176) 2025-11-03 17:06:52 -05:00
snapshots Update insta snapshots (#14366) 2024-11-15 19:31:15 +01:00
statement Allow newlines after function headers without docstrings (#21110) 2025-10-31 14:53:40 -04:00
string Avoid reusing nested, interpolated quotes before Python 3.12 (#20930) 2025-10-17 08:49:16 -04:00
type_param [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
builders.rs Implement template strings (#17851) 2025-05-30 15:00:56 -05:00
cli.rs Remove parentheses around multiple exception types on Python 3.14+ (#20768) 2025-10-14 11:17:45 -04:00
context.rs Avoid reusing nested, interpolated quotes before Python 3.12 (#20930) 2025-10-17 08:49:16 -04:00
db.rs Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
generated.rs Implement template strings (#17851) 2025-05-30 15:00:56 -05:00
lib.rs Update Rust toolchain to 1.91 (#21179) 2025-11-01 01:50:58 +00:00
main.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
options.rs [ruff] Update schemars to v1 (#20942) 2025-10-20 08:59:52 +02:00
prelude.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
preview.rs Avoid extra parentheses for long match patterns with as captures (#21176) 2025-11-03 17:06:52 -05:00
range.rs [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
shared_traits.rs Upgrade Rust toolchain to 1.83 (#14677) 2024-11-29 12:05:05 +00:00
verbatim.rs Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00