From 16387a5de88fe30b5f34cfc314948f422dada539 Mon Sep 17 00:00:00 2001 From: Safal Gupta <148842438+alphasafal@users.noreply.github.com> Date: Sat, 17 Oct 2026 22:02:38 +0530 Subject: [PATCH 1/5] fix(quantization): use raw docstrings for '\*' escapes --- src/coreai_opt/quantization/config/quantization_config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreai_opt/quantization/config/quantization_config.py b/src/coreai_opt/quantization/config/quantization_config.py index e63858c3..0d434fcc 100644 --- a/src/coreai_opt/quantization/config/quantization_config.py +++ b/src/coreai_opt/quantization/config/quantization_config.py @@ -169,7 +169,7 @@ def __init__(self, execution_mode: object) -> None: class OpQuantizerConfig(OpCompressionConfig[QuantizationSpec]): - """ + r""" Configuration class for quantization at the operation level. This class specifies quantization settings for inputs, outputs, and state @@ -271,7 +271,7 @@ def get_default_state_spec(cls) -> dict[str, QuantizationSpec | None]: @final class ModuleQuantizerConfig(ModuleCompressionConfig[OpQuantizerConfig, QuantizationSpec]): - """ + r""" Configuration class for quantization at the module level. This class manages quantization settings for an entire module, including: From b60c4c937d147e036ac2560c81d2c398af058a13 Mon Sep 17 00:00:00 2001 From: Safal Gupta <148842438+alphasafal@users.noreply.github.com> Date: Sat, 17 Oct 2026 22:03:21 +0530 Subject: [PATCH 2/5] test: use raw strings for regex patterns --- tests/quantization/test_annotation_pattern_registry.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/quantization/test_annotation_pattern_registry.py b/tests/quantization/test_annotation_pattern_registry.py index 66b006a8..c1906dcf 100644 --- a/tests/quantization/test_annotation_pattern_registry.py +++ b/tests/quantization/test_annotation_pattern_registry.py @@ -3414,7 +3414,7 @@ def test_none_configs(self, config, expected): QuantizerConfig( global_config=None, module_name_configs={ - "inner_module\.linear_out.*": ModuleQuantizerConfig( + r"inner_module\.linear_out.*": ModuleQuantizerConfig( op_state_spec=None, module_state_spec={"weight": default_weight_quantization_spec()}, ) @@ -3508,7 +3508,7 @@ def test_module_level_setting_precedence(self): ) }, module_name_configs={ - "inner_module\.linear_out1": ModuleQuantizerConfig( + r"inner_module\.linear_out1": ModuleQuantizerConfig( op_input_spec=None, op_output_spec=None, op_state_spec=None, @@ -4156,7 +4156,7 @@ def test_shared_param_precedence( ) }, ), - "Only integer indices or '\*' are supported", + r"Only integer indices or '\*' are supported", ), ( QuantizerConfig( @@ -4167,7 +4167,7 @@ def test_shared_param_precedence( ) }, ), - "Only integer indices or '\*' are supported", + r"Only integer indices or '\*' are supported", ), ( QuantizerConfig( From bd8508320ae329266e66b30a466c5336fe4ca9ad Mon Sep 17 00:00:00 2001 From: Safal Gupta <148842438+alphasafal@users.noreply.github.com> Date: Sat, 17 Oct 2026 22:03:53 +0530 Subject: [PATCH 3/5] test: check package source compiles without warnings --- tests/test_source_compiles.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/test_source_compiles.py diff --git a/tests/test_source_compiles.py b/tests/test_source_compiles.py new file mode 100644 index 00000000..09cbe5a4 --- /dev/null +++ b/tests/test_source_compiles.py @@ -0,0 +1,25 @@ +# Copyright 2026 Apple Inc. +# +# Use of this source code is governed by a BSD-3-Clause license that can +# be found in the LICENSE file or at https://opensource.org/licenses/BSD-3-Clause + +"""Check that the package source compiles without warnings.""" + +import warnings +from pathlib import Path + +import pytest + +import coreai_opt + +_SRC_ROOT = Path(coreai_opt.__file__).parent +_SOURCE_FILES = sorted(_SRC_ROOT.rglob("*.py")) + + +@pytest.mark.parametrize("path", _SOURCE_FILES, ids=lambda p: str(p.relative_to(_SRC_ROOT.parent))) +def test_source_compiles_without_warnings(path: Path) -> None: + # Things like invalid escape sequences only warn at compile time, and the + # warning is lost once a .pyc is cached, so compile from source directly. + with warnings.catch_warnings(): + warnings.simplefilter("error") + compile(path.read_text(encoding="utf-8"), str(path), "exec") From 5b6d3c2a7baf893b331828ecd0709c65c13f0591 Mon Sep 17 00:00:00 2001 From: Safal Gupta <148842438+alphasafal@users.noreply.github.com> Date: Sat, 17 Oct 2026 22:04:25 +0530 Subject: [PATCH 4/5] docs: add changelog fragment --- changelog.d/+invalid-escape-sequences.fixed | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/+invalid-escape-sequences.fixed diff --git a/changelog.d/+invalid-escape-sequences.fixed b/changelog.d/+invalid-escape-sequences.fixed new file mode 100644 index 00000000..f89789c4 --- /dev/null +++ b/changelog.d/+invalid-escape-sequences.fixed @@ -0,0 +1 @@ +Fix `SyntaxWarning: invalid escape sequence '\*'` emitted when `coreai_opt.quantization.config` is compiled on Python 3.12+ (and a `SyntaxError` under `python -W error`). From d71ceeaa0f5f980845e6df20e2bbc9dd0f29c412 Mon Sep 17 00:00:00 2001 From: Safal Gupta <148842438+alphasafal@users.noreply.github.com> Date: Sat, 17 Oct 2026 22:04:56 +0530 Subject: [PATCH 5/5] chore(lint): enable ruff W605 --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 23eb9e2b..f79a5734 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -263,6 +263,7 @@ select = [ "RUF100", # remove unused noqa pragmas "TC004", # catch runtime imports in TYPE_CHECKING blocks "UP", # apply pyupgrade modernization rules + "W605", # invalid escape sequences (SyntaxWarning since Python 3.12) ] ignore = [ "ANN401", # allow type `Any`.