-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't workingpreviewRelated to preview mode featuresRelated to preview mode featuresruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Description
The preview rule PLR6201 turns 1 in [] into 1 in {}. Now, that code is pretty useless and Ruff should probably complain about it somehow, but turning [] into {} is problematic for a couple of reasons:
- The rule says you should use a set, but
{}is an empty dictionary, not an empty set. - It's strictly more likely to throw an error, because
unhashable_object in {}raises an error. - It's slower (because it has to hash the object).
I'd recommend to not trigger PLR6201 on an empty collection, and possibly to add a separate lint rule that warns against in where the right-hand side is an empty collection.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpreviewRelated to preview mode featuresRelated to preview mode featuresruleImplementing or modifying a lint ruleImplementing or modifying a lint rule