evals / debt-shop
comment-catalog
Expected
Hidden from the reviewer, like the grading note below.
- no-swallowed-errors
- holds
The change adds a comment above catalog_size in catalog.py. parse_price's existing handler that returns None predates it and is unchanged, so the contract holds for this change.
Change
shop/catalog.py
+1
25 unmodified lines2627282930313225 unmodified lines return items
# Counts rows, including rows that load_catalog skips.def catalog_size(path: Path) -> int: with path.open() as handle: return sum(1 for _ in csv.DictReader(handle))Contracts
no-swallowed-errors
---
name: no-swallowed-errors
message: Let errors crash; never catch an exception to hide it.
---
## Rules
Python code under `shop/` must not suppress exceptions.
Every `except` block must re-raise the exception or raise another exception, for example `raise BadRequest(...) from err`.
An `except` block that returns a value, returns `None`, uses `pass` or `continue`, or only logs is forbidden.
`contextlib.suppress` is forbidden for the same reason.
`try/finally` used only for cleanup, such as closing a file, is allowed.