Fix SyntaxWarning for invalid escape sequence in tornado/util.py#68701
Open
AhmadYasser1 wants to merge 2 commits intosaltstack:3006.xfrom
Open
Fix SyntaxWarning for invalid escape sequence in tornado/util.py#68701AhmadYasser1 wants to merge 2 commits intosaltstack:3006.xfrom
AhmadYasser1 wants to merge 2 commits intosaltstack:3006.xfrom
Conversation
Contributor
Author
|
The Lint / Lint Salt's Source Code check is failing due to a CI infrastructure issue: The Pre-Commit check passes, confirming the code change itself is valid. |
The `re_unescape` function's docstring contained a bare `\d` which Python 3.12+ treats as an invalid escape sequence, producing: SyntaxWarning: invalid escape sequence '\d' Convert the docstring to a raw string (r"""...""") to prevent the warning while preserving the docstring content. Fixes saltstack#68568
The previous lint check failed due to a transient cassandra-driver install issue unrelated to this change.
7188b20 to
e9ac9cc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes a
SyntaxWarning: invalid escape sequence '\d'emitted by Python 3.12+ when importingsalt/ext/tornado/util.py.The
re_unescapefunction's docstring contained a bare\d(as part of documenting that strings containing\dcannot be unescaped). Python 3.12+ treats unrecognized backslash sequences in regular strings asSyntaxWarning, which will become aSyntaxErrorin a future Python version.The fix converts the docstring to a raw string (
r"""..."""), which preserves the content while preventing the warning.What issues does this PR fix or reference?
Fixes #68568
Previous Behavior
On Python 3.12+, importing
salt.ext.tornado.utilproduces:New Behavior
No warning is emitted on any Python version.
Merge requirements satisfied?
Commits signed with GPG?
No