-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Labels
bugSomething isn't workingSomething isn't workingruleImplementing or modifying a lint ruleImplementing or modifying a lint ruletype-inferenceRequires more advanced type inference.Requires more advanced type inference.
Description
PLC1802 won’t trigger if the sequence is an attribute.
https://play.ruff.rs/74477bb6-7796-4884-927a-2d0a8f93e4e2
Example
By running
$ echo 'class Fruits:
fruits: list[str]
def __init__(self):
self.fruits = ["apple", "orange"]
if len(self.fruits):
...
fruits = ["apple", "orange"]
if len(fruits):
...' | cargo run -p ruff -- check --select PLC1802 -We get this output, which is missing the self.fruits inside the Fruits class:
PLC1802 [*] `len(fruits)` used as condition without comparison
--> -:11:4
|
10 | fruits = ["apple", "orange"]
11 | if len(fruits):
| ^^^^^^^^^^^
12 | ...
|
help: Remove `len`
Found 1 error.
[*] 1 fixable with the `--fix` option.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingruleImplementing or modifying a lint ruleImplementing or modifying a lint ruletype-inferenceRequires more advanced type inference.Requires more advanced type inference.