Closed olemoign closed 5 months ago
Hi, I'm not sure I'm getting the problem you're trying to solve. Can you provide a snippet that replicates the bug?
Hi, this is not a huge problem as those are warnings only, so I expect the regex to still work. I think those warnings appeared with python 3.12, as I don't remember seeing them before. I don't know if they appear again during a call to the respective functions, I see them during the start of my app, which imports hl7apy, so this happens during the parsing of the python code.
The logs:
/usr/local/lib/python3.12/site-packages/hl7apy/exceptions.py:45: SyntaxWarning: invalid escape sequence '\&' """ /usr/local/lib/python3.12/site-packages/hl7apy/parser.py:40: SyntaxWarning: invalid escape sequence '\&' """ /usr/local/lib/python3.12/site-packages/hl7apy/parser.py:637: SyntaxWarning: invalid escape sequence '\S' m = re.match("^MSH(?P
\S)", content) /usr/local/lib/python3.12/site-packages/hl7apy/core.py:117: SyntaxWarning: invalid escape sequence '\d' regex = '^z[a-z1-9]{2}_\d+$' /usr/local/lib/python3.12/site-packages/hl7apy/utils.py:116: SyntaxWarning: invalid escape sequence '\d' offset = re.search('\d*((+(1[0-4]|0[0-9])|(-(1[0-2]|0[0-9])))([0-5][0-9]))$', value)
I think the first two logs are linked to DEFAULT_ENCODING_CHARS
but I couldn't test it.
thanks
Normal strings regex produce "SyntaxWarning: invalid escape sequence" for special chars like "\&", "\d" and "\S". Transform those normal strings to raw strings to fix this.