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

pvextractor/pvregions.py: SyntaxError: invalid escape sequence '\(' #124

Open
Hellseher opened this issue Aug 3, 2024 · 0 comments
Open

Comments

@Hellseher
Copy link

Hellseher commented Aug 3, 2024

Hi,

During packaging glue-qt for Guix I came across that I need pvextractor to be
packed as well, but during check phase I faced with an issue of failing
test initialisation, please see the error trace:

ImportError while loading conftest '/tmp/guix-build-python-pvextractor-0.4.drv-0/pvextractor-0.4/pvextractor/conftest.py'.
pvextractor/__init__.py:7: in <module>
    from .pvregions import paths_from_regfile
E     File "/tmp/guix-build-python-pvextractor-0.4.drv-0/pvextractor-0.4/pvextractor/pvregions.py", line 43
E       coordre = re.compile("^[a-z]*\((.*)\)")
E                            ^^^^^^^^^^^^^^^^^
E   SyntaxError: invalid escape sequence '\('

I've run flake8 over that file and it's confirmed an issue:

~$: guix shell python python-flake8 -- flake8 pvextractor/pvregions.py
The following derivation will be built:
  /gnu/store/5ns96n9f5jyigznyavbpw037fb79cil8-profile.drv

applying 4 grafts for python-pycodestyle-2.8.0 ...
applying 3 grafts for python-pyflakes-2.4.0 ...
applying 6 grafts for python-flake8-4.0.1 ...
building CA certificate bundle...
listing Emacs sub-directories...
building fonts directory...
building directory of Info manuals...
building profile with 2 packages...
pvextractor/pvregions.py:7:23: E231 missing whitespace after ':'
pvextractor/pvregions.py:8:18: E231 missing whitespace after ':'
pvextractor/pvregions.py:9:18: E231 missing whitespace after ':'
pvextractor/pvregions.py:10:19: E231 missing whitespace after ':'
pvextractor/pvregions.py:11:21: E231 missing whitespace after ','
pvextractor/pvregions.py:11:27: E231 missing whitespace after ','
pvextractor/pvregions.py:14:38: E231 missing whitespace after ','
pvextractor/pvregions.py:14:46: E231 missing whitespace after ','
pvextractor/pvregions.py:16:1: E302 expected 2 blank lines, found 1
pvextractor/pvregions.py:30:1: E302 expected 2 blank lines, found 1
pvextractor/pvregions.py:43:34: W605 invalid escape sequence '\('
pvextractor/pvregions.py:43:40: W605 invalid escape sequence '\)'
pvextractor/pvregions.py:51:11: E231 missing whitespace after ','
pvextractor/pvregions.py:76:1: E302 expected 2 blank lines, found 1
pvextractor/pvregions.py:77:20: E231 missing whitespace after ','
pvextractor/pvregions.py:81:1: E302 expected 2 blank lines, found 1
pvextractor/pvregions.py:93:1: W293 blank line contains whitespace
pvextractor/pvregions.py:102:6: E231 missing whitespace after ','
pvextractor/pvregions.py:102:15: E231 missing whitespace after ','
pvextractor/pvregions.py:108:25: E231 missing whitespace after ','
pvextractor/pvregions.py:109:17: E741 ambiguous variable name 'l'
pvextractor/pvregions.py:111:17: E741 ambiguous variable name 'l'
pvextractor/pvregions.py:113:25: E231 missing whitespace after ','
pvextractor/pvregions.py:118:29: E231 missing whitespace after ','
pvextractor/pvregions.py:118:50: E231 missing whitespace after ','
pvextractor/pvregions.py:120:36: E231 missing whitespace after ','
pvextractor/pvregions.py:121:18: E231 missing whitespace after ','
pvextractor/pvregions.py:121:27: E231 missing whitespace after ','
pvextractor/pvregions.py:126:46: E231 missing whitespace after ','
pvextractor/pvregions.py:126:64: E231 missing whitespace after ','
pvextractor/pvregions.py:134:1: E302 expected 2 blank lines, found 1
pvextractor/pvregions.py:141:6: E231 missing whitespace after ','
pvextractor/pvregions.py:144:1: W293 blank line contains whitespace
pvextractor/pvregions.py:146:7: E231 missing whitespace after ','
pvextractor/pvregions.py:148:80: E501 line too long (91 > 79 characters)
pvextractor/pvregions.py:150:67: E231 missing whitespace after ','
pvextractor/pvregions.py:150:80: E501 line too long (95 > 79 characters)
pvextractor/pvregions.py:151:67: E231 missing whitespace after ','
pvextractor/pvregions.py:151:80: E501 line too long (95 > 79 characters)
pvextractor/pvregions.py:157:1: E305 expected 2 blank lines after class or function definition, found 1
pvextractor/pvregions.py:157:28: E231 missing whitespace after ':'
pvextractor/pvregions.py:157:52: E231 missing whitespace after ':'
pvextractor/pvregions.py:158:30: E231 missing whitespace after ':'
pvextractor/pvregions.py:160:1: E302 expected 2 blank lines, found 1
pvextractor/pvregions.py:169:5: E265 block comment should start with '# '
pvextractor/pvregions.py:170:5: E265 block comment should start with '# '
pvextractor/pvregions.py:174:1: E302 expected 2 blank lines, found 1

Espessialy these two:

pvextractor/pvregions.py:43:34: W605 invalid escape sequence '\('
pvextractor/pvregions.py:43:40: W605 invalid escape sequence '\)'

As of Python 3.6, a backslash-character pair that is not a valid escape sequence now generates a DeprecationWarning. This will eventually become a SyntaxError.

https://www.flake8rules.com/rules/W605.html

Regular expressions use the backslash character ('\') to indicate special forms or to allow special characters to be used without invoking their special meaning. This collides with Python’s usage of the same character for the same purpose in string literals; for example, to match a literal backslash, one might have to write '\\\\' as the pattern string, because the regular expression must be \\, and each backslash must be expressed as \\ inside a regular Python string literal. Also, please note that any invalid escape sequences in Python’s usage of the backslash in string literals now generate a DeprecationWarning and in the future this will become a SyntaxError. This behaviour will happen even if it is a valid escape sequence for a regular expression.

https://docs.python.org/3.10/library/re.html

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

1 participant