-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
needs-decisionAwaiting a decision from a maintainerAwaiting a decision from a maintainerruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
The rule should only apply to trivial conditions with the simplest expressions (e.g. even having 2 sub-expressions joined with and or or is too much).
a.py:
from typing import Optional
# an ugly but realistic type
something: Optional[list] = None
if something is not None and len(something) > 1:
runner_image = something[0].url
else:
runner_image = None
cmd: ruff --isolated --select SIM --line-length=120 a.py
Output:
a.py:5:1: SIM108 [*] Use ternary operator `runner_image = something[0].url if something is not None and len(something) > 1 else None` instead of `if`-`else`-block
My eyes refuse to read runner_image = something[0].url if something is not None and len(something) > 1 else None.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
needs-decisionAwaiting a decision from a maintainerAwaiting a decision from a maintainerruleImplementing or modifying a lint ruleImplementing or modifying a lint rule