Skip to content

Docstrings with backslash escapes raise SyntaxWarning on import (a SyntaxError under -W error) #43

Description

@thorwhalen

Some docstrings in cw 0.1.4 (the PyPI release and the current source) are not raw strings but contain reST escapes such as Sequence\ s. Python 3.12 prints SyntaxWarning: invalid escape sequence '\ ' the first time the module is compiled (a fresh virtualenv, or no cached bytecode). With warnings treated as errors (python -W error, pytest -W error::SyntaxWarning), compiling the module is a SyntaxError.

Modules that do not compile with SyntaxWarning as an error:

  • cw/grammar.py line 482: invalid escape sequence '\ '

Why it matters

Every consumer's first command prints the warning. Found while verifying a clean PyPI install of acquaint 0.0.2 (thorwhalen/acquaint), which depends on cw: the first acquaint call in a new virtualenv prints it before its own output.

Fix

Make those docstrings raw (r"""…""") or double the backslashes. A test that compiles every module with SyntaxWarning as an error would keep it from coming back.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions