ruff/crates/ruff_python_formatter/src/expression
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
..
binary_like.rs Fix invalid syntax for binary expression in unary op (#5370) 2023-06-29 08:09:26 +02:00
expr_attribute.rs Fix attribute chain own line comments (#5340) 2023-06-26 09:13:07 +00:00
expr_await.rs Format Function definitions (#4951) 2023-06-08 16:07:33 +00:00
expr_bin_op.rs Preserve parentheses around left side of binary expression 2023-06-30 09:52:14 +02:00
expr_bool_op.rs Format let-else with rustfmt nightly (#5461) 2023-07-03 02:13:35 +00:00
expr_call.rs Introduce parenthesized helper (#5565) 2023-07-07 11:28:25 +02:00
expr_compare.rs Fix invalid syntax for binary expression in unary op (#5370) 2023-06-29 08:09:26 +02:00
expr_constant.rs Format implicit string continuation (#5328) 2023-06-26 12:41:47 +00:00
expr_dict.rs Introduce parenthesized helper (#5565) 2023-07-07 11:28:25 +02:00
expr_dict_comp.rs Format Function definitions (#4951) 2023-06-08 16:07:33 +00:00
expr_formatted_value.rs Format Function definitions (#4951) 2023-06-08 16:07:33 +00:00
expr_generator_exp.rs Change generator formatting dummy to include NOT_YET_IMPLEMENTED (#5464) 2023-07-03 09:11:14 +02:00
expr_if_exp.rs Format ExprIfExp (ternary operator) (#5597) 2023-07-07 19:11:52 +00:00
expr_joined_str.rs Format Function definitions (#4951) 2023-06-08 16:07:33 +00:00
expr_lambda.rs Format Function definitions (#4951) 2023-06-08 16:07:33 +00:00
expr_list.rs Introduce parenthesized helper (#5565) 2023-07-07 11:28:25 +02:00
expr_list_comp.rs Change generator formatting dummy to include NOT_YET_IMPLEMENTED (#5464) 2023-07-03 09:11:14 +02:00
expr_name.rs Format Function definitions (#4951) 2023-06-08 16:07:33 +00:00
expr_named_expr.rs Format Function definitions (#4951) 2023-06-08 16:07:33 +00:00
expr_set.rs Introduce parenthesized helper (#5565) 2023-07-07 11:28:25 +02:00
expr_set_comp.rs Fix unstable set comprehension formatting (#5327) 2023-06-23 11:50:24 +02:00
expr_slice.rs Remove prelude from ruff_python_ast (#5369) 2023-06-26 11:43:49 -04:00
expr_starred.rs format StmtWith (#5350) 2023-06-26 15:09:06 +01:00
expr_subscript.rs Format Slice Expressions (#5047) 2023-06-21 15:09:39 +00:00
expr_tuple.rs Introduce parenthesized helper (#5565) 2023-07-07 11:28:25 +02:00
expr_unary_op.rs Remove prelude from ruff_python_ast (#5369) 2023-06-26 11:43:49 -04:00
expr_yield.rs Format Function definitions (#4951) 2023-06-08 16:07:33 +00:00
expr_yield_from.rs Format Function definitions (#4951) 2023-06-08 16:07:33 +00:00
mod.rs Fix invalid syntax for binary expression in unary op (#5370) 2023-06-29 08:09:26 +02:00
parentheses.rs Introduce parenthesized helper (#5565) 2023-07-07 11:28:25 +02:00
string.rs Normalize '\r' in string literals to '\n' 2023-06-30 10:13:23 +02:00