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

Implement W605, invalid escape sequence #474

Closed
andersk opened this issue Oct 26, 2022 · 1 comment · Fixed by #482
Closed

Implement W605, invalid escape sequence #474

andersk opened this issue Oct 26, 2022 · 1 comment · Fixed by #482
Assignees
Labels
rule Implementing or modifying a lint rule

Comments

@andersk
Copy link
Contributor

andersk commented Oct 26, 2022

Python 3.6 deprecated unrecognized backslash escape sequences in string literals such as "\c", and they will eventually become errors. Pycodestyle raises W605 invalid escape sequence '\c'. These aren’t adjusted by Black, so it’d be good for Ruff to have this rule too. This probably requires a CST parser (#286).

$ cat a.py
"\c"
$ black a.py
All done! ✨ 🍰 ✨
1 file left unchanged.
$ flake8 a.py
a.py:1:2: W605 invalid escape sequence '\c'
$ python -Wall a.py
/tmp/a.py:1: DeprecationWarning: invalid escape sequence '\c'
  "\c"
$ python -Werror a.py
  File "/tmp/a.py", line 1
    "\c"
    ^^^^
SyntaxError: invalid escape sequence '\c'
$ ruff a.py
No pyproject.toml found.
Falling back to default configuration...
@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Oct 26, 2022
@charliermarsh charliermarsh self-assigned this Oct 26, 2022
@charliermarsh
Copy link
Member

I can implement this via token iteration for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants