Skip to content

Conversation

@youknowone
Copy link
Member

@youknowone youknowone commented Jan 18, 2026

Summary by CodeRabbit

  • Refactor
    • Improved annotation collection to handle nested code blocks comprehensively.
    • Enhanced error handling with explicit error reporting during annotation extraction.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 18, 2026

📝 Walkthrough

Walkthrough

Expanded AST statement recognition in the compiler to include StmtFor, StmtIf, StmtMatch, StmtTry, StmtWhile, and StmtWith. Reworked the collect_simple_annotations function to perform depth-first traversal of nested blocks. Updated error handling in JIT test utilities to replace warnings with explicit panics on malformed annotation references.

Changes

Cohort / File(s) Summary
AST annotation collection
crates/codegen/src/compile.rs
Expanded statement variant imports to recognize nested control-flow structures. Refactored collect_simple_annotations to traverse entire AST in depth-first order, handling nested blocks (if/for/while/with/try/match/elif/else branches) instead of only top-level statements. Added documentation on synchronization and conditional annotation handling.
JIT test error handling
crates/jit/tests/common.rs
Replaced warning-based error paths with explicit panics on malformed/out-of-bounds annotation references. Changed Str constant fallback to lossy conversion. Simplified type\_name finalization by unconditionally inserting StackValue\\::String after obtaining concrete type\_name.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • PR #6755: Modifies annotation collection and conditional-block tracking in compile.rs with enter/leave hooks, complementary to this PR's depth-first AST traversal enhancement.

Poem

🐰 Through nested blocks we hop and leap,
Annotations gathered, nested deep,
Error warnings banished from our sight,
Panic messages shining bright!
The rabbit's AST walk goes on,
From dusk till dawn! 🌙

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly reflects the main objective of the changeset: expanding annotation collection to support nested blocks (if/for/while/with/try/match) rather than just top-level statements.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

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

@youknowone youknowone marked this pull request as ready for review January 18, 2026 06:20
@youknowone youknowone merged commit eb50246 into RustPython:main Jan 18, 2026
13 checks passed
@youknowone youknowone deleted the annotation branch January 18, 2026 06:24
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