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
unnecessary-map (C417) has a false positive in Ruff 0.9.3 when there is not exactly one lambda parameter. If the fix is enabled, it changes the program’s behavior by suppressing or changing the raised error.
$ cat >c417.py <<'# EOF'try: print(list(map(lambda: 1, "xyz")))except Exception as e: print(repr(e))try: print(list(map(lambda x, y: x, [(1, 2), (3, 4)])))except Exception as e: print(repr(e))try: print(list(map(lambda x, y: x, "xyz")))except Exception as e: print(repr(e))
# EOF
$ python c417.pyTypeError('<lambda>() takes 0 positional arguments but 1 was given')TypeError("<lambda>() missing 1 required positional argument: 'y'")TypeError("<lambda>() missing 1 required positional argument: 'y'")
$ ruff --isolated check --select C417 c417.py --unsafe-fixes --fixFound 3 errors (3 fixed, 0 remaining).
$ cat c417.pytry: print([1 for _ in "xyz"])except Exception as e: print(repr(e))try: print([x for x, y in [(1, 2), (3, 4)]])except Exception as e: print(repr(e))try: print([x for x, y in "xyz"])except Exception as e: print(repr(e))
$ python c417.py[1, 1, 1][1, 3]ValueError('not enough values to unpack (expected 2, got 1)')
The text was updated successfully, but these errors were encountered:
Description
unnecessary-map
(C417) has a false positive in Ruff 0.9.3 when there is not exactly one lambda parameter. If the fix is enabled, it changes the program’s behavior by suppressing or changing the raised error.The text was updated successfully, but these errors were encountered: