flake8-simplify icon indicating copy to clipboard operation
flake8-simplify copied to clipboard

❄ A flake8 plugin that helps you to simplify code

Results 54 flake8-simplify issues
Sort by recently updated
recently updated
newest added

## Desired change * **Rule(s)**: SIM908 * **Adjustment**: The rule only detects dictionary access via `[x]`, not `.get(x)`. It should detect both. ## Explanation I noticed that if you misread...

enhancement

## Explanation 3 elements are ok to recognize, but when you quickly have a look it's hard to distinguish 4 repeated lines from 5 repeated lines. Also, it clutters the...

enhancement

## Explanation `input()` does the same as `input("")`, but has less clutter ## Example ```python # Bad input("") # Good input() ```

enhancement

## Explanation It does the same thing and `print()` is shorter. ## Example ```python # Bad print("") # Good print() ```

enhancement

## Explanation A code smell I see sometimes is enumeration of variables where an iterable should be used, e.g. a list. Using a list has several advantages: * Extendability: If...

enhancement

## Desired change * **Rule(s)**: SIM102 * **Adjustment**: If a comment is placed between `if` conditions, don't flag this rule ## Explanation Sometimes it is clearer to split up logic...

enhancement

## Explanation Analyze f-strings. If f-string has no text and only a passed value, then use that value directly. # Example 1 ```python # Bad foo = "bar" my_text =...

enhancement

## Explanation This can make the code much less repetitive. It would be nice to do this with common code at the start of each branch, but this could be...

enhancement

## Explanation It's a pretty typical situation that you have a dictionary and you need to do something with a value in there. If the key is not in there,...

enhancement

## Explanation There are many opportunities for the walrus operator to simplify code, but my go-to party trick is below. ## Example ```python # Bad with open('file.txt', 'r') as fd:...

enhancement