SACGF / variantgrid

VariantGrid public repo
Other
23 stars 2 forks source link

Python3.12 warnings about Invalid escape sequences #1112

Open davmlaw opened 4 months ago

davmlaw commented 4 months ago

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 commented 3 months ago

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 commented 3 months ago

@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 commented 3 months ago

internal change only - not user testable

EmmaTudini commented 2 months ago

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.