-
Notifications
You must be signed in to change notification settings - Fork 1.4k
impl more ast #6419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl more ast #6419
Conversation
WalkthroughThis PR refactors AST pattern handling in the Rust VM stdlib, replacing placeholder implementations with concrete vector-based structs. Three Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
crates/vm/src/stdlib/ast/pattern.rs (1)
566-577: Consider adding a debug assertion for length mismatch.The
zip()will silently truncate ifkwd_attrsandkwd_patternshave different lengths, which could mask upstream bugs or malformed AST input. Adebug_assert_eq!would catch this during development without runtime cost in release builds.fn merge_pattern_match_class( patterns: PatternMatchClassPatterns, kwd_attrs: PatternMatchClassKeywordAttributes, kwd_patterns: PatternMatchClassKeywordPatterns, ) -> (Vec<ruff::Pattern>, Vec<ruff::PatternKeyword>) { + debug_assert_eq!( + kwd_attrs.0.len(), + kwd_patterns.0.len(), + "kwd_attrs and kwd_patterns length mismatch" + ); let keywords = kwd_attrs .0 .into_iter() .zip(kwd_patterns.0)
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
crates/vm/src/stdlib/ast/pattern.rs(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style by runningcargo fmtto format Rust code
Always run clippy to lint Rust code (cargo clippy) before completing tasks and fix any warnings or lints introduced by changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass,pymodule,pyfunction, etc.) when implementing Python functionality in Rust
Files:
crates/vm/src/stdlib/ast/pattern.rs
🧬 Code graph analysis (1)
crates/vm/src/stdlib/ast/pattern.rs (4)
crates/vm/src/stdlib/itertools.rs (1)
None(1152-1152)crates/vm/src/builtins/genericalias.rs (1)
arguments(66-66)crates/vm/src/frame.rs (1)
kwd_attrs(1122-1122)crates/vm/src/stdlib/functools.rs (1)
keywords(72-74)
⏰ 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). (10)
- GitHub Check: Ensure compilation on various targets
- GitHub Check: Run snippets and cpython tests (windows-latest)
- GitHub Check: Run snippets and cpython tests (macos-latest)
- GitHub Check: Check the WASM package and demo
- GitHub Check: Run rust tests (windows-latest)
- GitHub Check: Run rust tests (macos-latest)
- GitHub Check: Check Rust code with clippy
- GitHub Check: Run rust tests (ubuntu-latest)
- GitHub Check: Run snippets and cpython tests (ubuntu-latest)
- GitHub Check: Run snippets and cpython tests on wasm-wasi
🔇 Additional comments (2)
crates/vm/src/stdlib/ast/pattern.rs (2)
201-228: LGTM! Clean implementation of Singleton conversion.The identity-based checks using
object.is()forTrueandFalseare correct for Python singletons, andvm.is_none()properly handles theNonecase.
390-436: LGTM! Clean newtype wrapper pattern.The tuple structs provide type-safe wrappers around the vectors, and the
Nodeimplementations correctly delegate to the inner collection's serialization/deserialization.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.