Deprecation warning due to invalid escape sequences in Python 3.8

Open
#352 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Start by running the Python 3.8 command shown in the issue, then inspect the reported expressions in test/test_samplefile.py and odml/rdf/query_creator.py. Update the affected string literals so the warnings are no longer emitted, and rerun the command to confirm the reported invalid-escape warnings are gone.

Written by the indexing model from the issue text.

Description

Deprecation warnings are emitted in Python 3.8 for invalid escape sequences. Escaping them or using raw strings will fix this issue.

find . -iname '*.py'  | xargs -P 4 -I{} python3.8 -Wall -m py_compile {}                               
./test/test_samplefile.py:41: DeprecationWarning: invalid escape sequence \s
  offset = len(re.compile('(\s*)').match(lines[0]).group())
./test/test_samplefile.py:43: DeprecationWarning: invalid escape sequence \w
  '[\w:]+)\])?(\s+linked to (?P<link>[\w/]+))?')
./odml/rdf/query_creator.py:91: DeprecationWarning: invalid escape sequence \(
  doc_pattern = re.compile("(doc|document)\(.*?\)")
./odml/rdf/query_creator.py:96: DeprecationWarning: invalid escape sequence \(
  sec_pattern = re.compile("(sec|section)\(.*?\)")
./odml/rdf/query_creator.py:101: DeprecationWarning: invalid escape sequence \(
  prop_pattern = re.compile("(prop|property)\(.*?\)")
./odml/rdf/query_creator.py:107: DeprecationWarning: invalid escape sequence \(
  p = re.compile("[\(|, ](id|author|date|version|repository|sections)[\)|,]")
./odml/rdf/query_creator.py:112: DeprecationWarning: invalid escape sequence \(
  p = re.compile("[\(|, ](id|name|definition|type|repository|reference|sections|properties)[\)|,]")
./odml/rdf/query_creator.py:117: DeprecationWarning: invalid escape sequence \(
  p = re.compile("[\(|, ](id|name|definition|dtype|unit|uncertainty|reference|value_origin)[\)|,]")
./odml/rdf/query_creator.py:153: DeprecationWarning: invalid escape sequence \(
  doc_pattern = re.compile("(doc|document)\(.*?\)")
./odml/rdf/query_creator.py:158: DeprecationWarning: invalid escape sequence \(
  sec_pattern = re.compile("(sec|section)\(.*?\)")
./odml/rdf/query_creator.py:163: DeprecationWarning: invalid escape sequence \(
  prop_pattern = re.compile("(prop|property)\(.*?\)")
./odml/rdf/query_creator.py:171: DeprecationWarning: invalid escape sequence \(
  p = re.compile("[, |\(](id|author|date|version|repository|sections):(.*?)[,|\)]")
./odml/rdf/query_creator.py:176: DeprecationWarning: invalid escape sequence \(
  p = re.compile("[, |\(](id|name|definition|type|repository|reference|sections|properties):(.*?)[,|\)]")
./odml/rdf/query_creator.py:181: DeprecationWarning: invalid escape sequence \(
  p = re.compile("[, |\(](id|name|definition|dtype|unit|uncertainty|reference|value_origin):(.*?)[,|\)]")
./odml/rdf/query_creator.py:185: DeprecationWarning: invalid escape sequence \[
  p_value = re.compile("value:\[(.*)]")
Dominant language
Python
Stars
25
Forks
30
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from G-Node/python-odml

All issues in G-Node/python-odml

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.