Skip to content

Fix SyntaxWarning for invalid escape sequences in Python 3.12#11

Open
rajivmucheli wants to merge 1 commit intomasterfrom
fix/python312-regex-syntax-warnings
Open

Fix SyntaxWarning for invalid escape sequences in Python 3.12#11
rajivmucheli wants to merge 1 commit intomasterfrom
fix/python312-regex-syntax-warnings

Conversation

@rajivmucheli
Copy link
Copy Markdown

Summary

  • Python 3.12 raises SyntaxWarning for invalid escape sequences (e.g. \d, \S, \*) in regular (non-raw) strings
  • Convert VERSION_REGEX, TIMESTAMP_REGEX, and the endswith_version inline pattern to raw strings (r'...')
  • Escape backslashes in the get_project_id_from_os_path docstring where the regex is shown as documentation text

Test plan

  • Import watcher.common with python3 -W error::SyntaxWarning — no warnings raised
  • Verify VERSION_REGEX and TIMESTAMP_REGEX values are unchanged
  • Confirm barbican pod logs no longer show the four SyntaxWarning lines at startup

Python 3.12 raises SyntaxWarning for invalid escape sequences in
regular strings. Convert regex patterns to raw strings (r'...') and
escape backslashes in docstring to suppress these warnings.
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.

1 participant