Skip to content

Fix script_utils invalid regex escape warning#577

Open
taivu1998 wants to merge 1 commit into
aqlaboratory:mainfrom
taivu1998:tdv/issue-569-script-utils-syntax-warning
Open

Fix script_utils invalid regex escape warning#577
taivu1998 wants to merge 1 commit into
aqlaboratory:mainfrom
taivu1998:tdv/issue-569-script-utils-syntax-warning

Conversation

@taivu1998
Copy link
Copy Markdown

Summary

Fixes #569 by making the parse_fasta header-splitting regex in openfold/utils/script_utils.py a raw string literal.

Root Cause

parse_fasta used the normal string literal '\W| \|'. On Python versions that warn about invalid escape sequences more aggressively, \W is interpreted as an invalid Python string escape before the value reaches the regex engine, producing:

SyntaxWarning: invalid escape sequence '\W'

The pattern is intended for re.split, so the regex escapes should be preserved directly.

Changes

  • Converted the regex string in parse_fasta to a raw string literal.
  • Added a lightweight compile-only regression test for script_utils.py that treats SyntaxWarning as an error without importing the heavier OpenFold runtime stack.

Validation

  • python3.12 -W error::SyntaxWarning -m py_compile openfold/utils/script_utils.py
  • python3.12 -m unittest tests.test_script_utils
  • python3 -m unittest tests.test_script_utils
  • git diff --check

@taivu1998 taivu1998 marked this pull request as ready for review May 11, 2026 03:44
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

Successfully merging this pull request may close these issues.

script_utils.py SyntaxWarning

1 participant