-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violations
Description
Summary
The fix for unnecessary-map
(C417) introduces a syntax error when the lambda expression contains a yield expression. The fix, and possibly the rule, should be suppressed in that case. Example:
$ cat >c417.py <<'# EOF'
base = 0
gens = map(lambda x: (yield base + x), [1, 2, 3])
for gen in gens:
print(*[*gen])
base += 20
# EOF
$ python c417.py
1
22
43
$ ruff --isolated check c417.py --select C417 --unsafe-fixes --fix
Found 1 error (1 fixed, 0 remaining).
$ python c417.py 2>&1 | tail -n 3
gens = ((yield base + x) for x in [1, 2, 3])
^^^^^^^^^^^^^^
SyntaxError: 'yield' inside generator expression
Version
ruff 0.12.11 (c2bc15b 2025-08-28)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violations