ruff/crates/ruff_linter/resources/test/fixtures/flake8_simplify
Dylan 0c2b88f224
[`flake8-simplify`] Further simplify to binary in preview for `if-else-block-instead-of-if-exp (SIM108)` (#12796)
In most cases we should suggest a ternary operator, but there are three
edge cases where a binary operator is more appropriate.

Given an if-else block of the form

```python
if test:
    target_var = body_value
else:
    target_var = else_value
```
This PR updates the check for SIM108 to the following:

- If `test == body_value` and preview enabled, suggest to replace with
`target_var = test or else_value`
- If `test == not body_value` and preview enabled, suggest to replace
with `target_var = body_value and else_value`
- If `not test == body_value` and preview enabled, suggest to replace
with `target_var = body_value and else_value`
- Otherwise, suggest to replace with `target_var = body_value if test
else else_value`

Closes #12189.
2024-08-10 16:49:25 +00:00
..
SIM101.py Redirect `PLR1701` to `SIM101` (#12021) 2024-06-27 13:44:11 +02:00
SIM102.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM103.py [`flake8-simplify`] Simplify double negatives in `SIM103` (#11684) 2024-06-01 23:21:11 +00:00
SIM105_0.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM105_1.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM105_2.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM105_3.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM105_4.py Skip BOM when inserting start-of-file imports (#7622) 2023-09-23 19:36:50 +00:00
SIM107.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM108.py [`flake8-simplify`] Further simplify to binary in preview for `if-else-block-instead-of-if-exp (SIM108)` (#12796) 2024-08-10 16:49:25 +00:00
SIM109.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM110.py Fix SIM110 with a yield in the condition (#7801) 2023-10-04 08:59:19 -04:00
SIM111.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM112.py [`SIM112`] Ignore `https_proxy`, `http_proxy`, and `no_proxy` (#8140) 2023-10-23 08:48:36 -05:00
SIM113.py Fix SIM113 false positive with async for loops (#9996) 2024-02-15 22:40:01 -05:00
SIM114.py Parenthesize conditions based on precedence when merging if arms (#12737) 2024-08-07 23:03:24 -04:00
SIM115.py Avoid recommending context manager in `__enter__` implementations (#11575) 2024-05-28 01:44:24 +00:00
SIM116.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM117.py Fix typos found by codespell (#9346) 2024-01-02 02:08:15 +00:00
SIM118.py Improve inference capabilities of the `BuiltinTypeChecker` (#10976) 2024-04-16 18:53:22 +01:00
SIM201.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM202.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM208.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM210.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM211.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM212.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM220.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM221.py Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
SIM222.py Account for possibly-empty f-string values in truthiness logic (#9484) 2024-01-11 21:16:19 -05:00
SIM223.py Account for possibly-empty f-string values in truthiness logic (#9484) 2024-01-11 21:16:19 -05:00
SIM300.py SIM300: CONSTANT_CASE variables are improperly flagged for yoda violation (#9164) 2023-12-20 20:26:07 +00:00
SIM401.py Make SIM401 catch ternary operations (#7415) 2023-10-20 20:47:00 +00:00
SIM910.py Extend `dict-get-with-none-default` (`SIM910`) to non-literals (#8762) 2023-11-19 00:21:53 +00:00
SIM911.py [`flake8-simplify`] Avoid raising `SIM911` for non-`zip` attribute calls (#11126) 2024-04-24 13:05:17 +00:00