Fix =/== error in ManualDictLookup (#3117)

This commit is contained in:
Rupert Tombs 2023-02-22 15:14:30 +00:00 committed by GitHub
parent ffd8e958fc
commit 817d0b4902
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 28 deletions

View file

@ -91,9 +91,9 @@ define_violation!(
/// ///
/// ### Example /// ### Example
/// ```python /// ```python
/// if x = 1: /// if x == 1:
/// return "Hello" /// return "Hello"
/// elif x = 2: /// elif x == 2:
/// return "Goodbye" /// return "Goodbye"
/// else: /// else:
/// return "Goodnight" /// return "Goodnight"

View file

@ -1,26 +0,0 @@
# if-to-dict (SIM116)
Derived from the **flake8-simplify** linter.
Autofix is always available.
### What it does
Checks for three or more consecutive if-statements with direct returns
### Why is this bad?
These can be simplified by using a dictionary
### Example
```python
if x = 1:
return "Hello"
elif x = 2:
return "Goodbye"
else:
return "Goodnight"
```
Use instead:
```python
return {1: "Hello", 2: "Goodbye"}.get(x, "Goodnight")
```