Open DeborahVolpe opened 2 months ago
@DeborahVolpe, could you please clarify where exactly and under what conditions are you seeing this error.
Invalid escape sequences currently (in Python 3.12), raise SyntaxWarning
, not SyntaxError
.
See also escape sequences in python docs.
Thank you for your response. To be precise the first error occurring in this our CI test is the following:
"D:\a\mqt-qao\mqt-qao.nox\tests-3-11\Lib\site-packages\dwave\samplers\greedy\sampler.py", line 32 E """Steepest descent sampler for binary quadratic models. E ^^^ E SyntaxError: invalid escape sequence '_'
Refferring to https://github.com/dwavesystems/dwave-samplers/blob/6b336abd0402519ce8de95952665b8f99cbd3e10/dwave/samplers/greedy/sampler.py#L52.
It is the _ character after the wikipedia link in the comment line. I think that it is not the only point in which a not-allowed character is employed.
@DeborahVolpe, that's a known issue we're fixing across our packages (converting such strings to raw strings), but what's not clear is why is this raised as SyntaxError
in your setup, because this is only SyntaxWarning
in Python 3.12+ (and only DeprecationWarning
in Python 3.11). At some point, but not yet known when - perhaps as soon as Python 3.13, it will be converted to SyntaxError
that you are seeing.
So I'm guessing you have a nox/test setup stricter than Python default -- and converting warnings to errors.
Perhaps you've set PYTHONWARNINGS to "error"
. More details here.
Your code presents some invalid escape sequences that are considered errors from python 11. Please check: https://docs.astral.sh/ruff/rules/invalid-escape-sequence/.
Steps To Reproduce With CI workflow for analyzing the code, errors like:
E SyntaxError: invalid escape sequence '\?'
rises in the comment lines
Expected Behavior A clear and concise description of what you expected to happen.
Environment