for-loop-set-mutations (FURB142)
Derived from the refurb linter.
Fix is always available.
This rule is unstable and in preview. The --preview
flag is required for use.
What it does
Checks for code that updates a set with the contents of an iterable by
using a for
loop to call .add()
or .discard()
on each element
separately.
Why is this bad?
When adding or removing a batch of elements to or from a set, it's more idiomatic to use a single method call rather than adding or removing elements one by one.
Example
Use instead: