mirror of
https://github.com/astral-sh/ruff
synced 2026-01-08 15:14:19 -05:00
**Summary** In python, a formfeed is technically undefined behaviour (https://docs.python.org/3/reference/lexical_analysis.html#indentation): > A formfeed character may be present at the start of the line; it will be ignored for > the indentation calculations above. Formfeed characters occurring elsewhere in the > leading whitespace have an undefined effect (for instance, they may reset the space > count to zero). In practice, they just reset the indentation:df8b3a46a7/Parser/tokenizer.c (L1819-L1821)a41bb2733f/crates/ruff_python_parser/src/lexer.rs (L664-L667)The stylist didn't handle formfeeds previously and would produce invalid indents. The remedy is to cut everything before a form feed. Checks box for https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458825 **Test Plan** Unit test for the stylist and a regression test for the rule