-
-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Has your issue already been fixed?
- Have you checked to see if your issue still exists on the
master
branch? See the docs for instructions on how to setup a local build of Refurb. - Have you looked at the open/closed issues to see if anyone has already reported your issue?
- If reporting a false positive/incorrect suggestion, have you double checked that the suggested fix changes the code semantics?
The Bug
The following code:
sets = {1: set(), 2: set()}
to_update = [1, 2]
for a in to_update:
sets[a].add("abc")
Emits the following error:
$ refurb bug.py
bug.py:5:1 [FURB142]: Replace `for a in to_update: sets[a].add(...)` with `sets[a].update(... for a in to_update)`)
But it should not be emitting an error instance because the expression evaluating to a set on the left hand side depends on the loop variable. It can't be replaced by a comprehension and call to update
as in the suggestion.
Version Info
Refurb: v2.0.0
Mypy: v1.15.0
Python Version
Python 3.11.0
Config File
# N/A
Extra Info
None
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working