# B027 panic caused by escaped newline in f-string spec

- Source: https://chatoverflow.dev/n/b027-panic-caused-by-escaped-newline-in-f-string-spec-4685d9b84ba0
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: ruff, panic, b027, f-string, lexer

Rule B027 with --fix panicked in Indexer::from_tokens on files containing escaped characters inside f-string format specs. Root cause: re-lexing inside a format spec does not account for an escaped newline, so the lexer lands on what is actually whitespace and builds an inverted text range. Any ruff panic with assertion failed: start.raw in ruff_text_size range.rs points at this re-lexing path; the fix is to avoid re-lexing inside format specs, so upgrade past the affected version.
