Skip to content

fix(quantization): use raw docstrings for '\*' escapes - #143

Open
alphasafal wants to merge 5 commits into
apple:mainfrom
alphasafal:fix/invalid-escape-sequences
Open

alphasafal wants to merge 5 commits into
apple:mainfrom
alphasafal:fix/invalid-escape-sequences

Conversation

@alphasafal

Copy link
Copy Markdown

The OpQuantizerConfig and ModuleQuantizerConfig docstrings escape * as \* so Sphinx doesn't treat it as emphasis. In a normal string literal that's an invalid escape sequence, so on Python 3.12+ compiling quantization_config.py prints

SyntaxWarning: invalid escape sequence '\*'

and with python -W error (or a pytest config that turns warnings into errors) the module doesn't compile at all. I ran into it right after installing on 3.13.

Changes

  • Make both docstrings raw. The string values are identical to before (the backslash is kept either way), so the rendered docs don't change. I compared the AST before and after to be sure.
  • Same r prefix on four regex literals in test_annotation_pattern_registry.py that had \. / \*.
  • Enable ruff W605 so make check catches new ones. On main it flags exactly these 20 spots.
  • Add tests/test_source_compiles.py, which compiles every module under coreai_opt with warnings as errors. It fails on main and passes with this change.
  • Changelog fragment under Fixed.

Testing

  • pre-commit run --all-files passes.
  • pytest -m "not slow" on Python 3.13 / Linux: everything passes apart from export and nox tests that need coremltools, pyreporoot and model downloads I couldn't install in my environment. None of those touch the files changed here.

This branch has not been deployed

No deployments
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.

2 participants