Skip to content

Silence Python warnings about invalid backslashes. #1694

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

Closed
wants to merge 1 commit into from

Conversation

collinfunk
Copy link
Contributor

This patch fixes the following warnings:

/home/collin/.local/src/redis-docs/build/components/component.py:464: SyntaxWarning: invalid escape sequence '\.'
  f'find {self._content} -regex ".*\.md"').strip().split('\n')
/home/collin/.local/src/redis-docs/build/components/markdown.py:250: SyntaxWarning: invalid escape sequence '\['
  self.payload = re.sub(f'(\[.+?\])(\(.+?\))', rep, self.payload)
/home/collin/.local/src/redis-docs/build/components/example.py:17: SyntaxWarning: invalid escape sequence '\['
  'c#': '\[Fact\]|\[SkipIfRedis\(.*\)\]'

The first one should be marked raw since we want the \ to be passed to the shell.

The others are not needed. Using "]" is only required when trying to match the literal ']' in a set of characers.

This patch fixes the following warnings:

    /home/collin/.local/src/redis-docs/build/components/component.py:464: SyntaxWarning: invalid escape sequence '\.'
      f'find {self._content} -regex ".*\.md"').strip().split('\n')
    /home/collin/.local/src/redis-docs/build/components/markdown.py:250: SyntaxWarning: invalid escape sequence '\['
      self.payload = re.sub(f'(\[.+?\])(\(.+?\))', rep, self.payload)
    /home/collin/.local/src/redis-docs/build/components/example.py:17: SyntaxWarning: invalid escape sequence '\['
      'c#': '\[Fact\]|\[SkipIfRedis\(.*\)\]'

The first one should be marked raw since we want the '\' to be passed to
the shell.

The others are not needed. Using "\]" is only required when trying to
match the literal ']' in a set of characers.
@dwdougherty
Copy link
Collaborator

Hi @collinfunk. Thank you for this PR. Only one of the four changes are relevant when this PR gets merged. So I'll just add that change to this other PR and close this one if that's okay with you.

@collinfunk
Copy link
Contributor Author

@dwdougherty Ah, I didn't look at that draft PR. Sure, you can just add the relevant patch there.

dwdougherty added a commit that referenced this pull request Jun 12, 2025
@dwdougherty
Copy link
Collaborator

Added the suggestion that still applies to this PR.

@collinfunk collinfunk deleted the silence-python-warnings branch June 14, 2025 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants