ruff/crates/ruff_linter/src/rules
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
..
airflow Use `CompactString` for `Identifier` (#12101) 2024-07-01 10:06:02 +02:00
eradicate Maintain synchronicity between the lexer and the parser (#11457) 2024-06-03 18:23:50 +05:30
fastapi [`fastapi`] Implement `FAST001` (`fastapi-redundant-response-model`) and `FAST002` (`fastapi-non-annotated-dependency`) (#11579) 2024-07-21 18:28:10 +00:00
flake8_2020 [`flake8-2020`] fix minor typo in `YTT301` documentation (#11543) 2024-05-26 13:23:41 -04:00
flake8_annotations Update dependency black to v24 (#12728) 2024-08-10 18:04:37 +05:30
flake8_async Update dependency black to v24 (#12728) 2024-08-10 18:04:37 +05:30
flake8_bandit Update dependency black to v24 (#12728) 2024-08-10 18:04:37 +05:30
flake8_blind_except Document that BLE001 supports both BaseException and Exception (#12788) 2024-08-09 17:28:50 +02:00
flake8_boolean_trap Update dependency black to v24 (#12728) 2024-08-10 18:04:37 +05:30
flake8_bugbear Update dependency black to v24 (#12728) 2024-08-10 18:04:37 +05:30
flake8_builtins [`flake8-builtins`] Implement import, lambda, and module shadowing (#12546) 2024-07-29 01:42:42 +00:00
flake8_commas Enable token-based rules on source with syntax errors (#11950) 2024-07-02 08:57:46 +00:00
flake8_comprehensions [`flake8-comprehensions`] Set comprehensions not a violation for `sum` in `unnecessary-comprehension-in-call` (`C419`) (#12691) 2024-08-06 02:30:58 +00:00
flake8_copyright Omit code frames for fixes with empty ranges (#12304) 2024-07-12 15:21:28 +00:00
flake8_datetimez Create a newtype wrapper around `Vec<FStringElement>` (#11400) 2024-05-13 16:04:04 +00:00
flake8_debugger refactor: Use `QualifiedName` for `Imported::call_path` (#10214) 2024-03-06 09:55:59 +01:00
flake8_django Treat `type(Protocol)` et al as metaclass base (#12770) 2024-08-09 20:10:12 +00:00
flake8_errmsg Upgrade to Rust 1.80 (#12586) 2024-07-30 19:18:08 +00:00
flake8_executable Add document for executable determination (#12547) 2024-07-28 16:23:00 -04:00
flake8_fixme Introduce `LinterSettings` 2023-09-20 17:02:34 +02:00
flake8_future_annotations Update dependency black to v24 (#12728) 2024-08-10 18:04:37 +05:30
flake8_gettext Use `CompactString` for `Identifier` (#12101) 2024-07-01 10:06:02 +02:00
flake8_implicit_str_concat Always allow explicit multi-line concatenations when implicit are banned (#12532) 2024-07-26 10:36:35 -04:00
flake8_import_conventions `ruff server` now supports the `source.organizeImports` source action (#10652) 2024-04-04 22:20:50 +00:00
flake8_logging Rename `SemanticModel::is_builtin` to `SemanticModel::has_builtin_binding` (#10991) 2024-04-18 11:11:42 +01:00
flake8_logging_format Upgrade to Rust 1.80 (#12586) 2024-07-30 19:18:08 +00:00
flake8_no_pep420 Omit code frames for fixes with empty ranges (#12304) 2024-07-12 15:21:28 +00:00
flake8_pie Upgrade to Rust 1.80 (#12586) 2024-07-30 19:18:08 +00:00
flake8_print Improve handling of builtin symbols in linter rules (#10919) 2024-04-16 11:37:31 +01:00
flake8_pyi Update dependency black to v24 (#12728) 2024-08-10 18:04:37 +05:30
flake8_pytest_style Update dependency black to v24 (#12728) 2024-08-10 18:04:37 +05:30
flake8_quotes Implement a common trait for the string flags (#11564) 2024-05-27 16:02:01 +01:00
flake8_raise Split `CallPath` into `QualifiedName` and `UnqualifiedName` (#10210) 2024-03-04 09:06:51 +00:00
flake8_return [`ruff_linter`] - Use LibCST in `adjust_indentation` for mixed whitespace (#12740) 2024-08-08 10:49:58 +02:00
flake8_self Use `CompactString` for `Identifier` (#12101) 2024-07-01 10:06:02 +02:00
flake8_simplify [`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
flake8_slots Avoid recommending `__slots__` for classes that inherit from more than `namedtuple` (#12531) 2024-07-26 14:24:40 +00:00
flake8_tidy_imports Make ImportFrom level just a u32 (#11170) 2024-04-26 20:38:35 -06:00
flake8_todos Maintain synchronicity between the lexer and the parser (#11457) 2024-06-03 18:23:50 +05:30
flake8_type_checking Treat `type(Protocol)` et al as metaclass base (#12770) 2024-08-09 20:10:12 +00:00
flake8_unused_arguments Add a new `Binding::is_unused` method (#12729) 2024-08-07 11:17:56 +01:00
flake8_use_pathlib Spellcheck & grammar (#10375) 2024-03-13 02:34:23 +00:00
flynt Create a newtype wrapper around `Vec<FStringElement>` (#11400) 2024-05-13 16:04:04 +00:00
isort Avoid marking required imports as unused (#12537) 2024-07-26 14:23:43 -04:00
mccabe Maintain synchronicity between the lexer and the parser (#11457) 2024-06-03 18:23:50 +05:30
numpy Ignore `NPY201` inside `except` blocks for compatibility with older numpy versions (#12490) 2024-07-24 20:03:23 +00:00
pandas_vet Remove `BindingKind::ComprehensionVar` (#12347) 2024-07-16 11:18:04 -04:00
pep8_naming Update dependency black to v24 (#12728) 2024-08-10 18:04:37 +05:30
perflint Ignore list-copy recommendations for async `for` loops (#11250) 2024-05-02 11:48:52 -07:00
pycodestyle Update dependency black to v24 (#12728) 2024-08-10 18:04:37 +05:30
pydoclint Treat `type(Protocol)` et al as metaclass base (#12770) 2024-08-09 20:10:12 +00:00
pydocstyle Update dependency black to v24 (#12728) 2024-08-10 18:04:37 +05:30
pyflakes Update dependency black to v24 (#12728) 2024-08-10 18:04:37 +05:30
pygrep_hooks Respect per-file ignores for blanket and redirected noqa rules (#11728) 2024-06-04 03:57:59 +00:00
pylint Update dependency black to v24 (#12728) 2024-08-10 18:04:37 +05:30
pyupgrade Update dependency black to v24 (#12728) 2024-08-10 18:04:37 +05:30
refurb [`refurb`] - fix unused autofix for `implicit-cwd` (`FURB177`) (#12708) 2024-08-06 08:09:35 +02:00
ruff Update dependency black to v24 (#12728) 2024-08-10 18:04:37 +05:30
tryceratops TRY002: fixup docs (#12683) 2024-08-05 08:56:12 +00:00
mod.rs [`fastapi`] Implement `FAST001` (`fastapi-redundant-response-model`) and `FAST002` (`fastapi-non-annotated-dependency`) (#11579) 2024-07-21 18:28:10 +00:00