Skip to content

PIE810 autofix changes raw strings to backslashes #9663

@JelleZijlstra

Description

@JelleZijlstra

Start with this code:

if x.startswith("a") or x.startswith("b") or re.match(r"a\.b", x):
    pass

Ruff correctly complains that I should use a single .startswith() call.

Run Ruff's autofix for PIE810:

if x.startswith(("a", "b")) or re.match("a\\.b", x):
    pass

And now my string is not raw any more.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfixesRelated to suggested fixes for violations

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions