fix(types): pyright cleanup on jit_inject + rule_context#83
fix(types): pyright cleanup on jit_inject + rule_context#83
Conversation
Two type errors broke main's pyright job after PR #78 landed: 1. src/gradata/hooks/jit_inject.py — `rank_rules_for_draft` returned `list[tuple[object, float]]`, so the main() list comp's `r.state.name` etc. accessed attributes on `object`. Tightened the parameter + return-type annotations to `list[Lesson]` / `list[tuple[Lesson, float]]` and added the `Lesson` import. Tuple invariance forced the propagation. 2. src/gradata/rules/rule_context.py — `_rule_matches_domain` returned `bool | Literal['']` because `applies and applies.startswith(...)` short-circuits to the empty string when `applies == ""`. Wrapped in `bool(applies) and applies.startswith(...)` and split into two statements so pyright sees a clean `bool` return. Both files pass pyright cleanly. No behaviour change. Co-Authored-By: Gradata <noreply@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.
Deploying gradata-dashboard with
|
| Latest commit: |
4df48af
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://76874309.gradata-dashboard.pages.dev |
| Branch Preview URL: | https://hotfix-pyright-cleanup.gradata-dashboard.pages.dev |
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 5 minutes and 51 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
Restore green pyright on main. Two type errors slipped in via PR #68 (jit-rule-injection) and PR #78 (scoped brains).
Errors fixed
src/gradata/hooks/jit_inject.py:216—r.state.nameetc. accessed attributes onobjectbecauserank_rules_for_draftreturnedlist[tuple[object, float]]. Tightened tolist[tuple[Lesson, float]]pluslessons: list[Lesson]parameter + Lesson import. Tuple invariance forced clean propagation.src/gradata/rules/rule_context.py:67—_rule_matches_domainreturnedbool | Literal['']becauseapplies and applies.startswith(...)short-circuits to empty string. Wrapped inbool(applies) and ...and split into two statements for a cleanboolreturn.Side fix
uv.lockgot auto-created by the local pyright run; added to.gitignore(not previously listed; not in main).Verify
uv run pyright src/gradata/hooks/jit_inject.py src/gradata/rules/rule_context.py-> 0 errors.No behavior change.
Co-Authored-By: Gradata noreply@gradata.ai