operator.itemgetter cannot be used to replace a lambda function for indexing with lambda arguments.
# xxx.py
xs = [1, 2, 3, 4, 5]
xm = map(lambda x: x[5-x], xs)
xxx.py:
3:10 FURB118 [*] Use `operator.itemgetter(5-x)` instead of defining a lambda
Here if replaced with operator.itemgetter(5-x), the x would be a undefined variable
ruff: 0.4.5
python: 3.12.2
operator.itemgettercannot be used to replace a lambda function for indexing with lambda arguments.Here if replaced with
operator.itemgetter(5-x), the x would be a undefined variable