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

Python3.12 warnings about Invalid escape sequences #1112

Open
davmlaw opened this issue Jul 12, 2024 · 4 comments
Open

Python3.12 warnings about Invalid escape sequences #1112

davmlaw opened this issue Jul 12, 2024 · 4 comments
Assignees

Comments

@davmlaw
Copy link
Contributor

davmlaw commented Jul 12, 2024

Invalid escape sequences were Deprecated in 3.6 now Python 3.12 seems to get a bit angry about it, giving warnings:

/opt/variantgrid/genes/hgvs/hgvs_converter.py:62: SyntaxWarning: invalid escape sequence '\d'
  if re.match(".*ins\d+$", hgvs_string):
/opt/variantgrid/classification/models/condition_text_matching.py:717: SyntaxWarning: invalid escape sequence '\d'
  pattern = f"{matched_term.id.lower()}(.*?)({prefix}:\d+)"
/opt/variantgrid/uicore/templatetags/js_tags.py:59: SyntaxWarning: invalid escape sequence '\`'
  text = text.replace('\\', '\\\\').replace('`', '\`').replace('</script>', '<\\/script>')
/opt/variantgrid/seqauto/illumina/samplesheet.py:14: SyntaxWarning: invalid escape sequence '\='
  ILLEGAL_CHARACTERS = "?()[]/\=+<>:;\"',*^|&. "  # From Illumina docs
/opt/variantgrid/upload/views/views.py:204: SyntaxWarning: invalid escape sequence '\.'
  accept_file_types = f"/(\.|\/)({'|'.join(extensions)})$/i"

This is probably just a matter of adding an "r" to the start, but need to test

@davmlaw
Copy link
Contributor Author

davmlaw commented Jul 31, 2024

These were all straight forward regex except the js_tags change which I am 95% sure is right - @TheMadBug - can you make sure that is good?

@TheMadBug
Copy link
Member

@davmlaw yup, I ran that in iPython and can confirm that the new way is right (and I'm surprised the old way even ran on old Python)

@davmlaw davmlaw closed this as completed Aug 5, 2024
@davmlaw
Copy link
Contributor Author

davmlaw commented Aug 5, 2024

internal change only - not user testable

@EmmaTudini
Copy link
Contributor

Re-opening as can be tested in Shariant -
This is in relation to finding OMIM, MONDO, PMID etc terms in text. The change is to be explicit in code about special characters in the search pattern (something that older Python’s would allow by default but newer versions wanted you to be explicit about). Can test by making sure citations still work, but pretty safe change.

@EmmaTudini EmmaTudini reopened this Aug 23, 2024
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

No branches or pull requests

3 participants