Repository navigation
fix(docs): resolve the three references to a document that was never committed, and enforce the rule one of them was deferring (#716) - #747
Merged
Conversation
…committed, and enforce the rule one of them was deferring (#716) `pyproject.toml` (twice) and `tests/README_integration.md` cited `dev/PUNCHLIST.md` as the authority for a decision. `dev/` is gitignored, `PUNCHLIST.md` was never committed on any branch, and -- checked while fixing this -- no copy of it survives in any working tree here either. So the three references did not point somewhere private; they pointed nowhere, and there was nothing left to commit. Two of them were carrying the justification for a policy that shapes the codebase, which made that policy unauditable rather than merely undocumented. Rather than restate two rationales in place, each reference is resolved on its own terms. **E722 is now enforced instead of explained.** The ignore read "bare except: tracked as ROB-4 in dev/PUNCHLIST.md (behavioral fix)". ROB-4's principle -- a catch-all reports a failure, it does not intercept the user asking to stop -- had already landed for `main()`'s post-run cleanup (`tests/test_pybnf_cleanup.py`). What was left was a single site: the catch-all around network generation in `_initialize_models`. A bare `except:` there caught `KeyboardInterrupt`, printed "Unknown error occurred during network generation... exiting", and turned Ctrl-C into `SystemExit(1)` -- during what is often the longest unattended stretch of a fit's startup, and therefore exactly when a user interrupts. Narrowed to `except Exception:`, so an interrupt propagates and the `finally` still restores the working directory. With the last site gone the rule is removed from the ignore list and gated: `ruff check .` now fails on a new bare except. **F841's rationale now stands on its own.** It read "several are CQ-5 dead code (tracked)". Audited: there are 20 sites, 18 in tests, and none of them is dead code anyone is going to delete. Most are a call made for its effect with a name attached to say what was called; one is a fixture script that must stay broken; the two outside tests are an attribute lookup performed as a guard and a symbol bound to mirror a published formula. The comment now says that, so a reviewer can check it against the tree. **The slow tier's pass criterion is restated in terms of the criterion.** It defined itself as the check "for the algorithm patches in dev/PUNCHLIST.md", which made a normative testing requirement unresolvable. It now applies to any change to a sampler or optimizer, and says what a contributor has to claim. Swept in with it, the same defect class that #716 flagged as related: `CONTRIBUTING.md` asserted "the project uses a populated `uv.lock`", which `.gitignore` contradicts -- a clone has no lock at all. The `.pre-commit-config.yaml` comment contradicted it in the other direction, claiming a sync would fail because the lock "isn't fully resolved in this repo". Both checked: a fresh resolve from `pyproject.toml` succeeds (87 packages) and `uv lock --check` on the working copy is clean, so neither claim was true. Each now describes what the repository actually does. Tests: `TestNetworkGenerationErrorHandling` pins the narrowed handler -- a KeyboardInterrupt propagates (with the bare clause it raised `SystemExit(1)`), an ordinary exception is still reported and still exits 1, and the working directory is restored either way.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #716.
What the audit turned up
dev/PUNCHLIST.mdis not merely gitignored — it is gone. Never committed on any branch, and no copy survives in any working tree here. So the three tracked references did not point somewhere private; they pointed nowhere, and option 1 from the issue ("commit it") had nothing to commit.That leaves resolving each reference on its own terms, which turns out to be better than restating two rationales in place.
E722: enforced instead of explained
The ignore read
bare except: tracked as ROB-4 in dev/PUNCHLIST.md (behavioral fix).That principle — a catch-all reports a failure, it does not intercept the user asking to stop — had already landed for
main()'s post-run cleanup (tests/test_pybnf_cleanup.py). What was left was exactly one site repo-wide: the catch-all around network generation in_initialize_models.A bare
except:there caughtKeyboardInterrupt, printed "Unknown error occurred during network generation, see log... exiting", and turned Ctrl-C intoSystemExit(1)— during what is often the longest unattended stretch of a fit's startup, and therefore exactly when a user interrupts. Narrowed toexcept Exception:, so an interrupt propagates; thefinallystill restores the working directory.With the last site gone, E722 is removed from the ignore list and gated:
ruff check .now fails on a new bare except. An enforced rule needs no rationale to audit.F841: the rationale now stands on its own
It read
unused locals: several are CQ-5 dead code (tracked); common bind-then-assert in tests.Audited all 20 sites. None is dead code anyone is going to delete:
pytest.raisesblock is asserting on) with a name attached to say what was called; one istests/bngl_files/special_cases/postprocess/bugscript.py, a fixture that must stay broken.config.pybinds an attribute lookup performed for its own sake as a guard on a user-supplied postprocessing script;benchmarks/run_benchmark.pybinds thedof the Laloy & Vrugt distance metric so the code reads like the formula quoted beside it.Ruff's fix in every case is to delete the binding, which loses the intent — so the rule stays off repo-wide, and the comment now says why in terms a reviewer can check against the tree.
The slow tier's pass criterion
tests/README_integration.mddefined the tier as the check "for the algorithm patches indev/PUNCHLIST.md", which made a normative testing requirement unresolvable. It now applies to any change to a sampler or optimizer, and states what a contributor has to claim (efficiency/diagnostic → moments unchanged; correctness → moments move toward analytical truth).Swept in: the
uv.lockcontradictionThe issue flagged this as the same defect class, and it is — a tracked file describing a state of the repo that is not true, in both directions:
CONTRIBUTING.mdasserted "the project uses a populateduv.lock" — but.gitignoreexcludes it, so a clone has no lock at all..pre-commit-config.yamlclaimed a sync would fail because the lock "isn't fully resolved in this repo".Both checked. A fresh resolve from
pyproject.tomlsucceeds (Resolved 87 packages in 1.22s) anduv lock --checkon the working copy is clean, so neither claim held. Each comment now describes what the repository actually does;--no-syncstays, for the reason that actually applies to a push hook.Tests
TestNetworkGenerationErrorHandlingpins the narrowed handler:KeyboardInterruptpropagates — mutation-distinguishing, since with the bare clause this raisedSystemExit(1)with the "Unknown error" message;Full suite green locally with
BNGPATHset: 5195 passed, 25 skipped, 0 failed.uvx ruff@0.15.14 check .passes with E722 now enforced.Note on one reference left alone
tests/test_pybnf_cleanup.pystill says "ROB-4" three times, and that is deliberate: its module docstring states the principle in full in the same breath, so the tag there is a label rather than a pointer. The new comments in this PR name the principle and the covering test file instead of the tag.