[X] 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.
[X] Have you looked at the open/closed issues to see if anyone has already reported your issue?
[X] 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 here
a = list(range(10))
index = 1
f = lambda x: (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).
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
Extra Info
ruff issue linked here: https://github.com/astral-sh/ruff/issues/11075