Skip to content

fix(types): pyright cleanup on jit_inject + rule_context#83

Closed
Gradata wants to merge 1 commit intomainfrom
hotfix/pyright-cleanup
Closed

fix(types): pyright cleanup on jit_inject + rule_context#83
Gradata wants to merge 1 commit intomainfrom
hotfix/pyright-cleanup

Conversation

@Gradata
Copy link
Copy Markdown
Owner

@Gradata Gradata commented Apr 15, 2026

Summary

Restore green pyright on main. Two type errors slipped in via PR #68 (jit-rule-injection) and PR #78 (scoped brains).

Errors fixed

  1. src/gradata/hooks/jit_inject.py:216r.state.name etc. accessed attributes on object because rank_rules_for_draft returned list[tuple[object, float]]. Tightened to list[tuple[Lesson, float]] plus lessons: list[Lesson] parameter + Lesson import. Tuple invariance forced clean propagation.
  2. src/gradata/rules/rule_context.py:67_rule_matches_domain returned bool | Literal[''] because applies and applies.startswith(...) short-circuits to empty string. Wrapped in bool(applies) and ... and split into two statements for a clean bool return.

Side fix

uv.lock got 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

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>
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gradata has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying gradata-dashboard with  Cloudflare Pages  Cloudflare Pages

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

View logs

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

Warning

Rate limit exceeded

@Gradata has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 51 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7c867aef-9a84-4a37-b2aa-f69964df3ab9

📥 Commits

Reviewing files that changed from the base of the PR and between f1fc674 and 4df48af.

📒 Files selected for processing (3)
  • .gitignore
  • src/gradata/hooks/jit_inject.py
  • src/gradata/rules/rule_context.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/pyright-cleanup

Comment @coderabbitai help to get the list of available commands and usage tips.

@Gradata
Copy link
Copy Markdown
Owner Author

Gradata commented Apr 15, 2026

Superseded by #82 (functionally identical pyright fix; #82 was APPROVED already and merged ahead of this one). Branch deleted.

@Gradata Gradata closed this Apr 15, 2026
@Gradata Gradata deleted the hotfix/pyright-cleanup branch April 17, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant