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 sequence warnings while running the test suite #2059

Closed
mgorny opened this issue Aug 15, 2023 · 3 comments
Closed

Invalid escape sequence warnings while running the test suite #2059

mgorny opened this issue Aug 15, 2023 · 3 comments

Comments

@mgorny
Copy link

mgorny commented Aug 15, 2023

When running the test suite via pytest, I've noticed a bunch of warnings about invalid escape sequences:

========================================================== warnings summary ===========================================================
tests/dialects/test_bigquery.py:252
  /tmp/sqlglot/tests/dialects/test_bigquery.py:252: DeprecationWarning: invalid escape sequence '\y'
    "bigquery": "'x\\\y'",

tests/dialects/test_hive.py:723
  /tmp/sqlglot/tests/dialects/test_hive.py:723: DeprecationWarning: invalid escape sequence '\z'
    self.validate_identity("'\z'")

tests/dialects/test_hive.py:725
  /tmp/sqlglot/tests/dialects/test_hive.py:725: DeprecationWarning: invalid escape sequence '\z'
    self.validate_identity("'\\\z'")

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

Note that Python outputs these when compiling .py into .pyc, so you need to remove existing .pyc files in order for them to be produced. The usual solution to these is to use raw strings (i.e. r"") but to be honest, I'm completely confused by the escape sequences there.

Fully reproducible code snippet

git clean -dfx
python3.11 -m pytest tests/dialects/

Official Documentation
n/a

@tobymao
Copy link
Owner

tobymao commented Aug 15, 2023

we don’t use pytest, does this repro on unittest?

@mgorny
Copy link
Author

mgorny commented Aug 15, 2023

Yes.

$ python -m unittest discover -s tests/dialects/
/tmp/sqlglot/tests/dialects/test_bigquery.py:252: SyntaxWarning: invalid escape sequence '\y'
  "bigquery": "'x\\\y'",
Unable to set __version__, run `pip install -e .` or `python setup.py develop` first.
/tmp/sqlglot/tests/dialects/test_hive.py:723: SyntaxWarning: invalid escape sequence '\z'
  self.validate_identity("'\z'")
/tmp/sqlglot/tests/dialects/test_hive.py:725: SyntaxWarning: invalid escape sequence '\z'
  self.validate_identity("'\\\z'")
...................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 211 tests in 0.931s

OK

@tobymao
Copy link
Owner

tobymao commented Aug 15, 2023

i couldn't reproduce it, but i modified those tests

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