fix: use presence tests for loads() kwargs and reject invalid ones - #361
fix: use presence tests for loads() kwargs and reject invalid ones#361ryanhill1 wants to merge 2 commits into
Conversation
Six documented loads() kwargs were stored behind a walrus truthiness test, so falsy caller values were silently discarded. All kwargs now use presence tests; unknown kwarg names raise TypeError and non-positive numeric values raise ValueError, so mistakes fail at the call site. Fixes #356
Argus reviewAuto-review is off for this repo. Tick the box below to run a review on this PR.
Estimated cost
Tip: you can also comment |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@Argus-Eye review |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🔎 Argus · 9/10 — Loads kwargs validation is cleaner, with one compatibility warning to resolve
🔍 PR intent vs diff (LLM analysis)
Argus read the diff against the stated intent. This is not an execution log — reviewer still needs to test behavior.
Goal: Ensure loads() preserves falsy kwargs and rejects unknown or invalid values at the call site.
Stated acceptance criteria (from PR/issue — not independently verified):
- All documented loads() kwargs are handled with presence tests so falsy values are preserved.
- Unknown loads() kwarg names raise TypeError.
- Non-positive device_qubits, device_cycle_time, compiler_angle_type_size, and frame_limit_per_port raise ValueError at load time.
- An explicit None kwarg value is treated as not passed.
- The kwarg-to-attribute map replaces the seven hand-written if blocks.
⚠️ Intent not delivered
Although src/pyqasm/entrypoint.py adds loads() kwarg handling and tests, finding 0 identifies that explicit None values are stored rather than treated as omitted. This fails the stated explicit-None acceptance criterion for API validation.
Unmet criteria:
- An explicit None kwarg value is treated as not passed.
Verdict: This PR centralizes loads() kwarg handling, preserves falsy values, and adds call-site validation. It is close to merge-ready once the compatibility concern is addressed.
🟡 1 P1 · 3 files reviewed
Architecture: The map-based validation replaces repetitive branching cleanly; we should ensure its stricter behavior remains compatible with existing callers.
1 finding · 1 inline · 0 folded
🔢 81.0k tokens · $0.2005 total
| Stage | Tokens | Cost |
|---|---|---|
| Intent | 2.7k | $0.0000 |
| Triage | 3.0k | $0.0000 |
| Lead agent | 1.4k | $0.0000 |
| Review · bug_hunter | 15.0k | $0.0523 |
| Review · security | 14.9k | $0.0451 |
| Review · architecture | 14.8k | $0.0512 |
| Review · regression | 15.1k | $0.0519 |
| Review | 11.3k | $0.0000 |
| Acceptance | 1.0k | $0.0000 |
| Scoring | 901 | $0.0000 |
| Synthesis | 893 | $0.0000 |
Contract: production/full · checked: bug_hunter, security, architecture, regression · review took 1m7s
Dashboard → · React 👎 to dismiss · Reply to any inline comment or use @argus-eye help to chat
An explicit None no longer clobbers non-None defaults like
extern_functions={} or frame_in_def_cal=True.
Fixes #356
Six documented
loads()kwargs were stored behind a walrus truthiness test (if dev_qbts := kwargs.get("device_qubits")), so any falsy caller value was silently treated as "not passed". Both adjacent gaps from the issue are closed as well:loads(src, devise_qubits=5)) raiseTypeErrordevice_qubits/device_cycle_time/compiler_angle_type_size/frame_limit_per_portraiseValueErrorat load time, instead of surfacing later as a confusing validation message (an explicitNonestill means "not passed")The kwarg→attribute map replaces the seven hand-written
ifblocks.Also in this PR:
Nonevalues for supportedloads()kwargs in the load configuration.loads() Kwarg Handling
Auto-enriched by Argus