Escape backslashes in coe.py and text.py string literals - #726
Merged
qtuantruong merged 1 commit intoSep 13, 2026
Merged
qtuantruong merged 1 commit into
qtuantruong merged 1 commit into
Conversation
cornac/models/coe/coe.py (a `\s`) and cornac/data/text.py (a `\]`) contain invalid escape sequences in non-raw strings, which raise `SyntaxWarning: invalid escape sequence` on Python 3.12+. Cornac's CI runs 3.10 through 3.13. Escaping the backslashes preserves the values. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014HBQNzAf5C2E3MiJC48HQw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Cornac has two non-raw string literals with unrecognised escapes:
\sincornac/models/coe/coe.pyand\]incornac/data/text.py. Importing either module under Python 3.12+ raisesSyntaxWarning: invalid escape sequence.Why it matters for Cornac
setup/packaging declaresrequires-python >=3.10and CI exercises 3.10 through 3.13, so the 3.12/3.13 runs emit these warnings when the affected modules are loaded.Fix
Add the missing backslash in each literal (
\s->\\s,\]->\\]). The decoded string is byte-for-byte the same; only the deprecation-path warning goes away. Equivalent to ruff's W605 fix.How I checked
Verified with
python3 -W error -m py_compile(raises before, clean after) and by diffingast.dump()of each module before and after the change - no AST difference.🤖 Generated with Claude Code
https://claude.ai/code/session_014HBQNzAf5C2E3MiJC48HQw