Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: FURB148 triggers if index variable is used outside of the loop #339

Open
3 tasks done
kasium opened this issue May 7, 2024 · 0 comments
Open
3 tasks done
Assignees
Labels
bug Something isn't working

Comments

@kasium
Copy link

kasium commented May 7, 2024

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:

for index, value in enumerate([1, 2, 3]):
    print(value)
print(f"Last index {index}")

Emits the following error:

$ refurb foo.py
foo.py:1:5 [FURB148]: Index is unused, use `for value in [1, 2, 3]` instead

But it should not emit any error since index is used outside of the code

Version Info

Refurb: v2.0.0
Mypy: v1.10.0

Python Version

Python 3.12.0

Config File

# N/A

Extra Info

None

@kasium kasium added the bug Something isn't working label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants