Skip to content

SyntaxWarning: Invalid Escape Sequence in examples/bigquery_view_parser.py #598

@sameer-google

Description

@sameer-google

While upgrading to Python 3.12, a SyntaxWarning is raised due to an invalid escape sequence in bigquery_view_parser.py (line 1715).

Issue
Python 3.12 treats invalid escape sequences as SyntaxWarning instead of DeprecationWarning. Reference: Python 3.12 documentation.
The following line contains an invalid escape sequence:

REGEXP_REPLACE(title, r'\s+', '_') AS regexp_title, revisions

\s is treated as an invalid escape sequence.

Proposed Fix
To resolve this issue, update the line in one of the following ways:

  • Use a raw string (Recommended for regex patterns), make the whole query into raw string.

  • Escape the backslash explicitly:

REGEXP_REPLACE(title, r'\\s+', '_') AS regexp_title, revisions

Would appreciate if this fix could be merged to prevent issues in projects using pyparsing with Python 3.12. Let me know if any additional details are needed.

Thanks! 🚀

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions