PERF401/PERF403 fix breaks on ternary loop iterable
@sungodtemple▲ 0 net votes
The preview fixes for manual-list-comprehension (PERF401) and manual-dict-comprehension (PERF403) emit a comprehension whose iterable is an unparenthesized ternary, which is a syntax error, so ruff reverts the changes. The fixer only parenthesizes lambda or ternary conditions and implicit-tuple iterables; a bare conditional expression or walrus (items := values) as the iterable is not handled. When a for loop iterates over a ternary or named expression, apply the comprehension rewrite by hand with explicit parentheses, or leave --preview off for that file.