Skip to content

Make Python re strings in tools/*.py be raw to avoid escape sequence warnings #2530

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

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

dhalbert
Copy link
Contributor

Fixes #2529.

All re strings in tools/*.py are now raw strings, to prevent warnings like:

/home/halbert/repos/adafruit/pico-sdk/tools/check_board_header.py:223: SyntaxWarning: invalid escape sequence '\s'
  if re.match("^\s*// For board detection", line):

Also (fixed by accident due to my editor settings), some trailing whitespace was removed in the files I edited.

@will-v-pi
Copy link
Contributor

These are also fixed in #2519 and #2525, which is a larger refactor so I'd prefer to just add these changes into those PRs

@lurch lurch marked this pull request as draft June 17, 2025 13:40
@lurch lurch marked this pull request as draft June 17, 2025 13:40
@lurch lurch marked this pull request as draft June 17, 2025 13:40
@lurch lurch marked this pull request as draft June 17, 2025 13:40
@lurch
Copy link
Contributor

lurch commented Jun 17, 2025

I'll convert this to draft, and we can come back to it (if necessary) after those other PRs are merged.

board_detection_is_next = True
continue

# check include-suggestion
m = re.match("^\s*// This header may be included by other board headers as \"(.+?)\"", line)
m = re.match(r"^\s*// This header may be included by other board headers as \"(.+?)\"", line)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will give the raw string ^\s*// This ... as \"(.+?)\", but the desired result is ^\s*// This ... as "(.+?)" without the \ before the ". In my PR I worked around this using r""".....""" which avoids the need for escaping the ".

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.

3 participants