schrodinger / pymol-open-source

Open-source foundation of the user-sponsored PyMOL molecular visualization system.
https://pymol.org/
Other
1.2k stars 281 forks source link

Invalid escape sequences (W605) #321

Closed speleo3 closed 11 months ago

speleo3 commented 11 months ago

Invalid escape sequences are deprecated since Python 3.6 and will eventually become a SyntaxError. They can be identified using a linter like ruff or flake8 with the W605 rule:

ruff check --select W605 modules
flake8 --select W605 modules
modules/chempy/sdf.py:23:32: W605 invalid escape sequence '\s'
modules/chempy/sdf.py:24:32: W605 invalid escape sequence '\s'
modules/chempy/sdf.py:24:42: W605 invalid escape sequence '\s'
modules/chempy/sdf.py:24:45: W605 invalid escape sequence '\('
modules/chempy/sdf.py:24:51: W605 invalid escape sequence '\)'
modules/pmg_tk/skins/normal/__init__.py:852:57: W605 invalid escape sequence '\.'
modules/pmg_tk/skins/normal/__init__.py:892:27: W605 invalid escape sequence '\.'
modules/pmg_tk/skins/normal/__init__.py:892:35: W605 invalid escape sequence '\.'
modules/pymol/internal.py:252:29: W605 invalid escape sequence '\.'
modules/pymol/internal.py:253:35: W605 invalid escape sequence '\.'
modules/pymol/internal.py:254:29: W605 invalid escape sequence '\.'
modules/pymol/internal.py:257:35: W605 invalid escape sequence '\.'
modules/pymol/movie.py:819:16: W605 invalid escape sequence '\W'
modules/pymol/movie.py:819:24: W605 invalid escape sequence '\S'
modules/pymol/movie.py:819:33: W605 invalid escape sequence '\c'
modules/pymol/moving.py:733:29: W605 invalid escape sequence '\s'
modules/pymol/parser.py:48:35: W605 invalid escape sequence '\['
modules/pymol/parser.py:48:39: W605 invalid escape sequence '\]'
modules/pymol/parser.py:48:43: W605 invalid escape sequence '\]'
modules/pymol/parser.py:408:55: W605 invalid escape sequence '\.'
modules/pymol/parser.py:408:61: W605 invalid escape sequence '\.'
modules/pymol/plugins/installation.py:25:14: W605 invalid escape sequence '\p'
modules/pymol/plugins/installation.py:25:20: W605 invalid escape sequence '\s'
modules/pymol/viewing.py:939:36: W605 invalid escape sequence '\.'
modules/pymol/viewing.py:952:48: W605 invalid escape sequence '\.'
modules/pymol/viewing.py:954:48: W605 invalid escape sequence '\.'
modules/pymol/wizard/pseudoatom.py:13:40: W605 invalid escape sequence '\8'

These strings should use raw string syntax (r prefix) or the backslashes should be escaped.

JarrettSJohnson commented 11 months ago

Thanks! We just need to cherry pick the relevant commit from incentive. @TstewDev

JarrettSJohnson commented 11 months ago

Fixed via c3e298356a13f93fce939f860800625272754c97

Thanks for catching this. We're behind on some cherrypicking; will try to update by year's end.