Skip to content
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

Update regex matching to handle proper class escaping #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

warthog9
Copy link
Contributor

@warthog9 warthog9 commented Apr 5, 2024

On Python 3.12 it's throwing compile warnings on the regex compiles:

spdx/verify-spdx-headers:8: SyntaxWarning: invalid escape sequence '\s'
  SPDX = re.compile(f'SPDX-License-Identifier:\s+({SLUG.pattern})')
spdx/verify-spdx-headers:21: SyntaxWarning: invalid escape sequence '\s'
  pattern = f"^{init}\s*{SPDX.pattern}\s*{fini}\\s*$"
spdx/verify-spdx-headers:21: SyntaxWarning: invalid escape sequence '\s'
  pattern = f"^{init}\s*{SPDX.pattern}\s*{fini}\s*$"

This escapes the the '\s' to be '\s' instead as that is compliant, seems to compile correctly, and makes the warning go away. Quick checking on my own repos seemed to not break anything.

@warthog9 warthog9 requested a review from a team as a code owner April 5, 2024 17:18
@warthog9 warthog9 requested review from npmccallum and removed request for a team April 5, 2024 17:18
@github-actions github-actions bot enabled auto-merge (rebase) April 5, 2024 17:18
auto-merge was automatically disabled April 6, 2024 19:00

Head branch was pushed to by a user without write access

@github-actions github-actions bot enabled auto-merge (rebase) April 6, 2024 19:00
auto-merge was automatically disabled April 6, 2024 19:02

Head branch was pushed to by a user without write access

@github-actions github-actions bot enabled auto-merge (rebase) April 6, 2024 19:02
On Python 3.12 it's throwing compile warnings on the regex compiles:

```
spdx/verify-spdx-headers:8: SyntaxWarning: invalid escape sequence '\s'
  SPDX = re.compile(f'SPDX-License-Identifier:\s+({SLUG.pattern})')
spdx/verify-spdx-headers:21: SyntaxWarning: invalid escape sequence '\s'
  pattern = f"^{init}\s*{SPDX.pattern}\s*{fini}\\s*$"
spdx/verify-spdx-headers:21: SyntaxWarning: invalid escape sequence '\s'
  pattern = f"^{init}\s*{SPDX.pattern}\s*{fini}\s*$"
```

This escapes the the '\s' to be '\\s' instead as that is compliant,
seems to compile correctly, and makes the warning go away.  Quick
checking on my own repos seemed to not break anything.

Signed-off-by: John 'Warthog9' Hawley <jhawley@tenstorrent.com>
auto-merge was automatically disabled April 6, 2024 19:03

Head branch was pushed to by a user without write access

@github-actions github-actions bot enabled auto-merge (rebase) April 6, 2024 19:03
@rjzak
Copy link
Member

rjzak commented Apr 8, 2024

Possibly a dumb question, but what version of Python runs on Github's CI runners?

@warthog9
Copy link
Contributor Author

warthog9 commented Apr 8, 2024

Depends on the image used, since each image has a different base it could be used with, and the image bases will shift slowly over time as Github upgrades them. I believe the current default is Ubuntu 22.04, but I haven't found an absolutely definitive answer to that.

In my specific case I'm running the checker outside the action itself on a Fedora 39 system, which has a newer Python, and running into the problem likely slightly ahead of when the default image for Github upgrades to a 3.12 base Python.

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.

2 participants