Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stylist indentation with a formfeed #7489

Merged
merged 1 commit into from
Sep 19, 2023
Merged

Fix stylist indentation with a formfeed #7489

merged 1 commit into from
Sep 19, 2023

Commits on Sep 18, 2023

  1. Fix stylist indentation with a formfeed

    **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:
    
    https://github.com/python/cpython/blob/df8b3a46a7aa369f246a09ffd11ceedf1d34e921/Parser/tokenizer.c#L1819-L1821
    https://github.com/astral-sh/ruff/blob/a41bb2733fe75a71f4cf6d4bb21e659fc4630b30/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 #7455 (comment)
    
    **Test Plan** Unit test for the stylist and a regression test for the rule
    konstin committed Sep 18, 2023
    Configuration menu
    Copy the full SHA
    92ba971 View commit details
    Browse the repository at this point in the history