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

Stop SyntaxWarnings because of some escaped blank #483

Merged

Conversation

hacklschorsch
Copy link
Member

I see these often at the very beginning when running tests - I removed that backslash, but also, not so sure what I'm doing here. @crwood is removing these okay? Why are they there in the first place?

    _zkapauthorizer/replicate.py:393: SyntaxWarning: invalid escape sequence '\ '
    _zkapauthorizer/replicate.py:490: SyntaxWarning: invalid escape sequence '\ '

    _zkapauthorizer/replicate.py:393: SyntaxWarning: invalid escape sequence '\ '
    _zkapauthorizer/replicate.py:490: SyntaxWarning: invalid escape sequence '\ '
@hacklschorsch hacklschorsch requested a review from crwood November 7, 2024 14:16
Copy link
Member

@crwood crwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, this was a change introduced in Python 3.12 (which raises a SyntaxWarning for invalid escape sequences instead of a DeprecationWarning). See here or here

The usual/recommended way to fix this is by making the docstring into a "raw" string (i.e., adding an r prefix to the to the first line of the docstring by changing """... to r"""...); as per PEP 257:

Use r"""raw triple double quotes""" if you use any backslashes in your docstrings.

Removing it also works, but depending on what's rendering those docstrings (if they're being rendered by anything?), you might see an extra space where there was no extra space before.

@hacklschorsch hacklschorsch merged commit 330f808 into PrivateStorageio:main Nov 7, 2024
2 of 13 checks passed
@hacklschorsch
Copy link
Member Author

Thank you for your review @crwood !

@hacklschorsch hacklschorsch deleted the stop-syntax-warning branch November 7, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants