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

invalid escape sequences #62

Open
DeborahVolpe opened this issue Jun 3, 2024 · 3 comments
Open

invalid escape sequences #62

DeborahVolpe opened this issue Jun 3, 2024 · 3 comments

Comments

@DeborahVolpe
Copy link

DeborahVolpe commented Jun 3, 2024

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

  • for all the OS
  • for python in range 3.9 to 3.12
@randomir
Copy link
Member

randomir commented Jun 4, 2024

@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.

@DeborahVolpe
Copy link
Author

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

:math:`O(|V|*log|V|)` for initialization and :math:`O(max\_degree * log|V|)`
.

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.

@randomir
Copy link
Member

randomir commented Jun 5, 2024

@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.

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

2 participants