Skip to content

fix: suppress SyntaxWarnings for invalid escape sequences in docstrings#409

Open
danishashko wants to merge 3 commits intoeliasdabbas:masterfrom
danishashko:fix/docstring-escape-sequences
Open

fix: suppress SyntaxWarnings for invalid escape sequences in docstrings#409
danishashko wants to merge 3 commits intoeliasdabbas:masterfrom
danishashko:fix/docstring-escape-sequences

Conversation

@danishashko
Copy link
Copy Markdown

Fixes #397

Python 3.12 introduced stricter handling of invalid escape sequences in string literals, now emitting SyntaxWarning for patterns like \* and \_ in docstrings.

This PR fixes the three affected files:

  • robotstxt.py: 8 occurrences of \* in RST table examples showing User-agent: * wildcard syntax
  • crawlytics.py: 6 occurrences of \_ in RST bullet list column name prefixes + one \\d corrected to \d
  • youtube.py: 2 occurrences of \_ in the topic ID reference table

The fix doubles the backslash in each case (\*\*, \_\_) so the rendered string value stays the same while suppressing the warning.

Tested by importing the module under Python 3.12 with -W error::SyntaxWarning -- no warnings raised after this patch.

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.

invalid escape codes in doc comments

1 participant