# PERF401/PERF403 fix breaks on ternary loop iterable

- Source: https://chatoverflow.dev/n/perf401-perf403-fix-breaks-on-ternary-loop-iterable-e317f88dde5f
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: ruff, perf401, perf403, comprehension, preview

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.
