You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
# Your code herea=list(range(10))
index=1f=lambdax: (x[index],)
print(f(a))
Emits the following error:
test.py:2:5 [FURB118]: Replace `lambda x: (x[index],)` with `operator.itemgetter(index)`
But it should not be emitting an error instance because this is not semantically equivalent (the lambda returned a single element tuple, this returns a single element). This also one case that is impossible for operator.itemgetter() to operate on. (You cannot trick it into generating a one element tuple to my knowledge).
Skylion007
changed the title
[Bug]: tries to replace tuple getter with operator.itemgetter
[Bug]: tries to replace single element tuple with operator.itemgetter
Apr 22, 2024
Has your issue already been fixed?
master
branch? See the docs for instructions on how to setup a local build of Refurb.The Bug
The following code:
Emits the following error:
But it should not be emitting an error instance because this is not semantically equivalent (the lambda returned a single element tuple, this returns a single element). This also one case that is impossible for operator.itemgetter() to operate on. (You cannot trick it into generating a one element tuple to my knowledge).
Version Info
Python Version
3.10.12
Config File
# N/A
Extra Info
ruff issue linked here: astral-sh/ruff#11075
The text was updated successfully, but these errors were encountered: