fix(types): annotate rank_rules_for_draft to satisfy pyright#82
fix(types): annotate rank_rules_for_draft to satisfy pyright#82
Conversation
The return type was list[tuple[object, float]] which made pyright reject attribute access on the unpacked rule (r.state, r.confidence, etc). Switch to the actual Lesson type (or Any if Lesson import is awkward). Unblocks PR #76 (cloud-split) which inherits this CI failure. Signed-off-by: Oliver Le <oliver@gradata.ai>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
🧰 Additional context used📓 Path-based instructions (1)src/gradata/**/*.py⚙️ CodeRabbit configuration file
Files:
🔇 Additional comments (1)
📝 Walkthrough
WalkthroughUpdate narrows type annotations to use the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Gradata has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Deploying gradata-dashboard with
|
| Latest commit: |
6a0c44e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b14232e4.gradata-dashboard.pages.dev |
| Branch Preview URL: | https://fix-pyright-jit-inject.gradata-dashboard.pages.dev |
- Move Lesson import into TYPE_CHECKING block (ruff TC001) - Cast scope-applies expression to bool to satisfy pyright reportReturnType - rule_context fix is pre-existing on main, blocking the same CI as PR #76 Signed-off-by: Oliver Le <oliver@gradata.ai>
There was a problem hiding this comment.
Gradata has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Signed-off-by: Oliver Le <oliver@gradata.ai>
There was a problem hiding this comment.
Gradata has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/gradata/rules/rule_context.py`:
- Line 67: The return expression currently uses redundant checks and a bool()
wrapper; simplify the logic in rule_context.py by replacing "return applies ==
domain_norm or bool(applies and applies.startswith(f\"{domain_norm}:\"))" with
"return applies == domain_norm or applies.startswith(f\"{domain_norm}:\")" since
applies is already a str and startswith() yields a bool; update the return in
the function where the variables applies and domain_norm are used accordingly.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 03e7ffc8-56b0-41c6-bdb8-c10ecdc5a788
📒 Files selected for processing (2)
src/gradata/hooks/jit_inject.pysrc/gradata/rules/rule_context.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: Test (Python 3.11)
- GitHub Check: Test (Python 3.12)
- GitHub Check: test (3.13)
- GitHub Check: test (3.11)
- GitHub Check: test (3.12)
- GitHub Check: Python 3.12
- GitHub Check: Python 3.11
- GitHub Check: Test (Python 3.11)
- GitHub Check: Test (Python 3.12)
- GitHub Check: Cloudflare Pages
- GitHub Check: Python 3.12
- GitHub Check: Python 3.11
🧰 Additional context used
📓 Path-based instructions (2)
src/gradata/**/*.py
⚙️ CodeRabbit configuration file
src/gradata/**/*.py: This is the core SDK. Check for: type safety (from future import annotations required), no print()
statements (use logging), all functions accepting BrainContext where DB access occurs, no hardcoded paths. Severity
scoring must clamp to [0,1]. Confidence values must be in [0.0, 1.0].
Files:
src/gradata/rules/rule_context.pysrc/gradata/hooks/jit_inject.py
src/gradata/hooks/**
⚙️ CodeRabbit configuration file
src/gradata/hooks/**: JavaScript hooks for Claude Code integration. Check for: no shell injection (no execSync with user
input), temp files must use per-user subdirectory, HTTP calls must have timeouts, errors must be silent (never block
the tool chain).
Files:
src/gradata/hooks/jit_inject.py
🔇 Additional comments (3)
src/gradata/hooks/jit_inject.py (3)
28-35: Type-onlyLessonimport is correctly structured.Good use of
TYPE_CHECKINGwith postponed annotations to keep runtime imports clean while satisfying static analysis.
103-109:rank_rules_for_drafttyping now matches real usage.This is the right narrowing: callers/tests treat ranked items as
Lesson, so this signature fixes the previous type mismatch cleanly.
124-124: Accumulator annotation is consistent with the updated contract.Nice follow-through on internal typing; this keeps inference stable and avoids regressions in strict pyright mode.
startswith() already returns bool; the 'and applies' short-circuit is also redundant since startswith() on empty string is False for any non-empty pattern. Signed-off-by: Oliver Le <oliver@gradata.ai>
There was a problem hiding this comment.
Gradata has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Fixes 4 pyright errors at
src/gradata/hooks/jit_inject.py:216that have been blocking main CI. Pre-existing — not introduced by this PR.Switches the return type from
list[tuple[object, float]]to the actualLessontype (imported fromgradata._types). Approach (a) — clean import, no circular issues.Local pyright on
src/gradata/hooks/jit_inject.py:0 errors, 0 warnings, 0 informations.Unblocks PR #76 (cloud-split) which inherits this failure.