Skip to content

_INDENT_RE is too narrow - '\x0c ' is strange but valid indent whitespace #446

@Zac-HD

Description

@Zac-HD

While working on my shed autoformatter, which includes some libcst-based passes, Hypothesmith uncovered a bug:

_INDENT_RE: Pattern[str] = re.compile(r"[ \t]+")

For example, 'class A:\n\x0c pass\n' is a valid class-declaration. It can even be parsed by libcst.parse_module(), but the refactoring tooling chokes on it.

(this is a terrible bug to report and I hope it never happens in the wild, but there you go!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparsingConverting source code into CST nodes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions