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

[Adjust Rule] SIM300 false positive with literals on both sides

Open 0xallie opened this issue 1 year ago • 1 comments

Desired change

  • Rule(s): SIM300
  • Adjustment: Don't trigger if both sides of a comparison are literals

Explanation

These comparisons are pointless, but swapping them around (only to be told to swap them around again after) is also pointless.

Example

Example 1

if "a" == "b":
    pass
SIM300: Use '"b" == "a"' instead of '"a" == "b"' (Yoda-conditions)

Example 2

if 1 == 2:
    pass
SIM300: Use '2 == 1' instead of '1 == 2' (Yoda-conditions)

0xallie avatar Oct 02 '22 15:10 0xallie