ruff
2cd74f00 - Cache parenthesized expression boundaries in the formatter (#26344)

Commit
103 days ago
Cache parenthesized expression boundaries in the formatter (#26344) ## Summary Formatting frequently asks whether an expression was parenthesized in the source. Prior to this change, each check re-tokenized the surrounding source and skipped trivia independently, even though the parser token stream is already available. This PR builds `TriviaRanges` in the same token traversal that collects comment ranges. It stores those ranges alongside a `ParenthesizedExpressions` index backed by a single `FxHashSet<TextRange>`, so comment placement and `PyFormatContext` share the same source-boundary data. Hot-path checks become one lookup without an additional token traversal or source-scanning fallback. Formatter paths that need the full parenthesized range continue to use the parsed-token `parentheses_iterator`.
Author
Parents
Loading