Skip to content

Commit 623cf19

Browse files
David-Wu1119claude
andauthored
Fix four error messages that printed their placeholders (pytorch#23104)
### Summary Four raised errors were plain strings, not f-strings, so users see the literal placeholder instead of the value: | File | Message | |---|---| | `exir/passes/quantize_io_pass.py` | `Output {output_index} is not a dequantize op` | | `exir/dialects/edge/dtype/runner.py` | `Type {t.name} does not have dtype` | | `backends/cortex_m/quantizer_reporter.py` | `Node {node.name} reported as annotated but has no quantization annotation.` | | `backends/arm/_passes/insert_table_ops.py` | `Table op for {target} does not exist` | For example, asking `QuantizeOutputs` to quantize an output that isn't a dequantize op raises `ValueError: Output {output_index} is not a dequantize op`. That doesn't say which output. Each fix adds the missing `f` prefix, and no other code changes. ### Test plan - Each changed line only adds an `f` prefix, and every variable it names is in scope at the `raise`. All four files compile. - `black` 24.4.2 and `flake8` 6.1.0, the lintrunner pins, pass on the changed files. `ruff` 0.15.4 reports the same pre-existing findings as `main`, all docstring rules, and nothing new. This PR was authored with AI assistance (Claude Code). I found these with a scan for string literals that contain `{name}` placeholders but are never formatted. 🤖 Generated with [Claude Code](https://claude.com/claude-code) cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e07f9df commit 623cf19

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎backends/arm/_passes/insert_table_ops.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def __getitem__(self, node: Node):
130130
# Op must be handled if it's inside self.special_ops
131131
raise AssertionError("Unhandled table operation")
132132
else:
133-
raise KeyError("Table op for {target} does not exist")
133+
raise KeyError(f"Table op for {target} does not exist")
134134

135135
@staticmethod
136136
def included_ops() -> Iterator[EdgeOpOverload]:

‎backends/cortex_m/quantizer_reporter.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def report_accept(self, pattern: List[Node]) -> None:
130130
for node in pattern:
131131
if Q_ANNOTATION_KEY not in node.meta:
132132
raise ValueError(
133-
"Node {node.name} reported as annotated but has no quantization annotation."
133+
f"Node {node.name} reported as annotated but has no quantization annotation."
134134
)
135135
annotation = cast(
136136
QuantizationAnnotation | None, node.meta.get(Q_ANNOTATION_KEY)

‎exir/dialects/edge/dtype/runner.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def mapping(t):
6363
elif t.is_scalar_type() or t.is_tensor() or t.is_tensor_list():
6464
return type_dtypes + self.tensor_dtypes
6565
else:
66-
raise ValueError("Type {t.name} does not have dtype")
66+
raise ValueError(f"Type {t.name} does not have dtype")
6767

6868
return list(map(mapping, types))
6969

‎exir/passes/quantize_io_pass.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def quantize_output(exported_program, output_index):
165165
exir_ops.edge.quantized_decomposed.dequantize_per_tensor.default,
166166
torch.ops.quantized_decomposed.dequantize_per_tensor.default,
167167
]:
168-
raise ValueError("Output {output_index} is not a dequantize op")
168+
raise ValueError(f"Output {output_index} is not a dequantize op")
169169

170170
dequant = target_output
171171
output_list[output_index] = dequant.args[0]

0 commit comments

Comments
 (0)