Type probe pipeline internals: ProbeTarget, frozen ProbeHit, typed diff, validated PollResult#91
Type probe pipeline internals: ProbeTarget, frozen ProbeHit, typed diff, validated PollResult#91henry0816191 wants to merge 3 commits into
Conversation
…ff, validated PollResult
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR replaces tuple-based probe entries with a typed ChangesTyped probe pipeline refactor
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/test_monitor.py`:
- Around line 205-228: The pytest assertions in test_rejects_invalid_diff_type,
test_rejects_invalid_probe_hit_element,
test_rejects_invalid_dp_transition_element, and
test_rejects_invalid_per_user_matches_value use raw regex patterns where the dot
in PollResult.* is being treated as a metacharacter. Update each match= string
to escape literal punctuation, or build the pattern with re.escape, so the
exception checks in PollResult and its related constructors are explicit and
unambiguous.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 211de7e1-331e-4459-aabb-3a526b509e6c
📒 Files selected for processing (6)
src/paperscout/models.pysrc/paperscout/monitor.pysrc/paperscout/protocols.pysrc/paperscout/sources.pytests/test_monitor.pytests/test_sources.py
Summary
Replace untyped/mutable probe pipeline internals with named, validated types so callers cannot couple to bare tuples or silently mutate probe results.
ProbeTargetdataclass and remove the bare_Entry6-tuple; update_build_probe_list,_build_hot_list,_build_cold_slice, andrun_cycleto use named fieldsDataSource.diffasSourceDiff(DiffResult | list[ProbeHit] | list[OpenStdEntry]) and annotateWG21Index.diff→DiffResult(withTYPE_CHECKINGimport to preserve thesources ↔ monitorcycle break)ProbeHit(@dataclass(frozen=True, slots=True))PollResultto a validated dataclass with__post_init__checks fordiff,probe_hits,dp_transitions, andper_user_matchesTest plan
uv run pytest -q— 418 passed, 2 skippeduv run pytest tests/ --cov=paperscout --cov-fail-under=90— 93.55% coverageuv run mypy src/paperscout/protocols.py src/paperscout/monitor.py src/paperscout/__main__.py— strict gate cleanuv run ruff check src tests— cleanuv run ruff format --check src tests— cleanpre-commit run --all-filesRelated issues
Summary by CodeRabbit