repeated-equality-comparison (PLR1714)
Derived from the Pylint linter.
Fix is always available.
What it does
Checks for repeated equality comparisons that can rewritten as a membership test.
Why is this bad?
To check if a variable is equal to one of many values, it is common to
write a series of equality comparisons (e.g.,
foo == "bar" or foo == "baz"
).
Instead, prefer to combine the values into a collection and use the in
operator to check for membership, which is more performant and succinct.
If the items are hashable, use a set
for efficiency; otherwise, use a
tuple
.
Example
Use instead: