ruff/crates/ruff_python_ast/src
konsti 0b9af031fb
Format ExprIfExp (ternary operator) (#5597)
## Summary

Format `ExprIfExp`, also known as the ternary operator or inline `if`.
It can look like
```python
a1 = 1 if True else 2
```
but also
```python
b1 = (
    # We return "a" ...
    "a" # that's our True value
    # ... if this condition matches ...
    if True # that's our test
    # ... otherwise we return "b§
    else "b" # that's our False value
)
```

This also fixes a visitor order bug.

The jaccard index on django goes from 0.911 to 0.915.

## Test Plan

I added fixtures without and with comments in strange places.
2023-07-07 19:11:52 +00:00
..
source_code Upgrade RustPython (#5334) 2023-06-23 20:39:47 +00:00
visitor Format ExprIfExp (ternary operator) (#5597) 2023-07-07 19:11:52 +00:00
all.rs Allow re-assignments to `__all__` (#4967) 2023-06-08 17:19:56 +00:00
call_path.rs Refactor range from `Attributed` to `Node`s (#4422) 2023-05-16 06:36:32 +00:00
cast.rs Upgrade RustPython (#4900) 2023-06-08 05:53:14 +00:00
comparable.rs Upgrade RustPython (#5192) 2023-06-19 21:09:53 +00:00
docstrings.rs Move Python whitespace utilities into new `ruff_python_whitespace` crate (#4993) 2023-06-10 00:59:57 +00:00
function.rs Format Function definitions (#4951) 2023-06-08 16:07:33 +00:00
hashable.rs Create a `rust_python_ast` crate (#3370) 2023-03-07 15:18:40 +00:00
helpers.rs Remove some allocations in argument detection (#5481) 2023-07-03 12:21:26 -04:00
identifier.rs Format let-else with rustfmt nightly (#5461) 2023-07-03 02:13:35 +00:00
imports.rs Run `rustfmt` on nightly to clean up erroneous comments (#5106) 2023-06-15 00:19:05 +00:00
lib.rs Remove prelude from `ruff_python_ast` (#5369) 2023-06-26 11:43:49 -04:00
node.rs Try statements have a body: Fix formatter instability (#5558) 2023-07-06 16:07:47 +02:00
relocate.rs Refactor range from `Attributed` to `Node`s (#4422) 2023-05-16 06:36:32 +00:00
statement_visitor.rs Upgrade RustPython (#5192) 2023-06-19 21:09:53 +00:00
str.rs Basic string formatting 2023-06-23 09:46:05 +02:00
token_kind.rs Bring pycodestyle rules into full compatibility (on SciPy) (#4472) 2023-05-17 16:51:55 +00:00
types.rs Replace `parents` statement stack with a `Nodes` abstraction (#4233) 2023-05-06 16:12:41 +00:00
typing.rs Upgrade RustPython (#4747) 2023-05-31 08:26:35 +00:00
visitor.rs Remove prelude from `ruff_python_ast` (#5369) 2023-06-26 11:43:49 -04:00
whitespace.rs Move Python whitespace utilities into new `ruff_python_whitespace` crate (#4993) 2023-06-10 00:59:57 +00:00