[flake8-simplify]: combine-if-conditions (#2823)

This commit is contained in:
Colin Delahunty 2023-02-12 16:00:32 -05:00 committed by GitHub
parent 1666e8ba1e
commit 1f07ad6e61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 323 additions and 3 deletions

View file

@ -0,0 +1,23 @@
# 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")
```

View file

@ -0,0 +1,24 @@
# if-with-same-arms (SIM114)
Derived from the **flake8-simplify** linter.
### What it does
Checks for `if` branches with identical arm bodies.
### Why is this bad?
If multiple arms of an `if` statement have the same body, using `or`
better signals the intent of the statement.
### Example
```python
if x = 1:
print("Hello")
elif x = 2:
print("Hello")
```
Use instead:
```python
if x = 1 or x = 2
print("Hello")
```