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

Fix re string type #1077

Merged
merged 3 commits into from
Oct 15, 2024
Merged

Conversation

jhunkeler
Copy link
Contributor

@jhunkeler jhunkeler commented Sep 25, 2024

  • Replaces string literal with a raw string
  • https://docs.python.org/3/library/re.html#module-re states: [..] any invalid escape sequences in Python’s usage of the backslash in string literals now generate a SyntaxWarning and in the future this will become a SyntaxError. The solution is to use Python's raw string notation for regular expression patterns.

This PR addresses ...

Under Python 3.10:

DeprecationWarning: invalid escape sequence '\.'
    _VERSION_RE = re.compile(f"^[0-9]+\.[0-9]+\.[0-9]+$")

Under 3.11:

    _VERSION_RE = re.compile(f"^[0-9]+\.[0-9]+\.[0-9]+$")
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: invalid escape sequence '\.'

Under 3.12:

SyntaxWarning: invalid escape sequence '\.'
    _VERSION_RE = re.compile(f"^[0-9]+\.[0-9]+\.[0-9]+$")

Tasks

  • update or add relevant tests
  • update relevant docstrings and / or docs/ page
  • Does this PR change any API used downstream? (if not, label with no-changelog-entry-needed)
    • write news fragment(s) in changes/: echo "changed something" > changes/<PR#>.<changetype>.rst (see below for change types)
news fragment change types...
  • changes/<PR#>.hst.rst: HST reference files
  • changes/<PR#>.jwst.rst: JWST reference files
  • changes/<PR#>.roman.rst: Roman reference files
  • changes/<PR#>.doc.rst: documentation change
  • changes/<PR#>.testing.rst: change to tests or test automation
  • changes/<PR#>.general.rst: infrastructure or miscellaneous change

@jhunkeler jhunkeler requested a review from a team as a code owner September 25, 2024 19:34
jhunkeler and others added 3 commits October 15, 2024 10:09
* Replaces string literal with a raw string
* https://docs.python.org/3/library/re.html#module-re states:
  [..] any invalid escape sequences in Python’s usage of the backslash in
  string literals now generate a SyntaxWarning and in the future this will
  become a SyntaxError. The solution is to use Python's raw string notation
  for regular expression patterns.
@alphasentaurii
Copy link
Collaborator

The CI tests were passing prior to rebasing this PR. The failures according to the logs are a result of the cached context being incorrect (it's still pulling jwst_1293.pmap even though the latest context is now at 1298), which has nothing to do with these changes. Approving and merging and will correct the CI cached context issue in a separate PR.

@alphasentaurii alphasentaurii merged commit fd8d5a7 into spacetelescope:master Oct 15, 2024
4 of 10 checks passed
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