ruff/crates/ruff_python_formatter/src
konsti bd8f65814c
Format named expressions (walrus operator) (#5642)
## Summary

Format named expressions (walrus operator) such a `value := f()`. 

Unlike tuples, named expression parentheses are not part of the range
even when mandatory, so mapping optional parentheses to always gives us
decent formatting without implementing all [PEP
572](https://peps.python.org/pep-0572/) rules on when we need
parentheses where other expressions wouldn't. We might want to revisit
this decision later and implement special cases, but for now this gives
us what we need.

## Test Plan

black fixtures, i added some fixtures and checked django and cpython for
stability.

Closes #5613
2023-07-10 12:32:15 +00:00
..
comments formatter: multi char tokens in SimpleTokenizer (#5610) 2023-07-10 09:00:59 +01:00
expression Format named expressions (walrus operator) (#5642) 2023-07-10 12:32:15 +00:00
module Run rustfmt on nightly to clean up erroneous comments (#5106) 2023-06-15 00:19:05 +00:00
other Introduce parenthesized helper (#5565) 2023-07-07 11:28:25 +02:00
pattern Use dedicated structs in comparable.rs (#5042) 2023-06-13 03:57:34 +00:00
snapshots formatter: multi char tokens in SimpleTokenizer (#5610) 2023-07-10 09:00:59 +01:00
statement Format import statements (#5493) 2023-07-04 07:07:20 +00:00
builders.rs Don't add a magic trailing comma for a single entry (#5463) 2023-07-03 21:48:44 +02:00
cli.rs Create PyFormatOptions 2023-06-26 14:02:17 +02:00
context.rs Create PyFormatOptions 2023-06-26 14:02:17 +02:00
generated.rs Upgrade RustPython (#5192) 2023-06-19 21:09:53 +00:00
lib.rs Fix typos found by codespell (#5607) 2023-07-08 12:33:18 +02:00
main.rs Add a formatter CLI for debugging (#4809) 2023-06-05 07:33:33 +00:00
options.rs Prefer the configured quote style 2023-06-26 14:24:25 +02:00
prelude.rs Accept any Into<AnyNodeRef> as Comments arguments (#5205) 2023-06-20 16:49:21 +00:00
trivia.rs formatter: multi char tokens in SimpleTokenizer (#5610) 2023-07-10 09:00:59 +01:00