mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
23 lines
No EOL
388 B
Markdown
23 lines
No EOL
388 B
Markdown
# combine-if-conditions (SIM114)
|
|
|
|
Derived from the **flake8-simplify** linter.
|
|
|
|
### What it does
|
|
Checks if consecutive `if` branches have the same body.
|
|
|
|
### Why is this bad?
|
|
These branches can be combine using the python `or` statement
|
|
|
|
### Example
|
|
```python
|
|
if x = 1:
|
|
print("Hello")
|
|
elif x = 2:
|
|
print("Hello")
|
|
```
|
|
|
|
Use instead:
|
|
```python
|
|
if x = 1 or x = 2
|
|
print("Hello")
|
|
``` |