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 SyntaxWarning: invalid escape sequence #2184

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented May 14, 2024

This removes all those pesky warnings from our unittest output so now it looks like:
% coverage run -m unittest discover tests

............................................................................
.......................ss.............................................s....
----------------------------------------------------------------------
Ran 151 tests in 3.606s

% ruff check --select=W605 --fix # https://docs.astral.sh/ruff

Found 34 errors (34 fixed, 0 remaining).

% ruff rule W605

invalid-escape-sequence (W605)

Derived from the pycodestyle linter.

Fix is always available.

What it does

Checks for invalid escape sequences.

Why is this bad?

Invalid escape sequences are deprecated in Python 3.6.

Example

regex = "\.png$"

Use instead:

regex = r"\.png$"

Or, if the string already contains a valid escape sequence:

value = "new line\nand invalid escape \_ here"

Use instead:

value = "new line\nand invalid escape \\_ here"

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant