mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:16 +00:00
Fix =/== error in ManualDictLookup
(#3117)
This commit is contained in:
parent
ffd8e958fc
commit
817d0b4902
2 changed files with 2 additions and 28 deletions
|
@ -91,9 +91,9 @@ define_violation!(
|
|||
///
|
||||
/// ### Example
|
||||
/// ```python
|
||||
/// if x = 1:
|
||||
/// if x == 1:
|
||||
/// return "Hello"
|
||||
/// elif x = 2:
|
||||
/// elif x == 2:
|
||||
/// return "Goodbye"
|
||||
/// else:
|
||||
/// return "Goodnight"
|
||||
|
|
|
@ -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")
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue