GeezerVison is showing github.com — Add RustPython runtime AST fields by youknowone · Pull Request #2 · RustPython/ruff
Conversation
youknowone
commented
Jun 25, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Test Plan
Summary by CodeRabbit
-
New Features
- Added support for constant expressions across parsing, traversal, and comparison logic.
- Expanded syntax handling for f-strings, t-strings, match patterns, and several statement forms with richer runtime-aware AST coverage.
-
Bug Fixes
- Improved handling of boolean,
None, and ellipsis-style constants in expression analysis and precedence detection.
- Fixed source-order and transform traversal so constant expressions are processed consistently.
- Updated relocation and parsing paths to preserve the new AST structure during edits and recovery.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Jun 25, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Caution
Review failed
The pull request is closed.
📝 Walkthrough
Walkthrough
The AST schema adds ConstantValue, ExprConstant, and runtime_* storage across statements, expressions, patterns, and modules. Parsers initialize the new fields, and visitors, helpers, precedence, relocation, and comparable-node code add handling for Expr::Constant.
Changes
Constant AST runtime support
| Layer / File(s) |
Summary |
AST field contracts crates/ruff_python_ast/ast.toml, crates/ruff_python_ast/src/nodes.rs, crates/ruff_python_ast/generate.py, crates/ruff_python_ast/src/generated.rs |
ConstantValue and the new runtime_* fields are declared across AST schema and generated node structs, and the generator prefix list is extended for ConstantValue. |
Constant expression wrappers crates/ruff_python_ast/src/generated.rs |
ExprConstant is wired through the generated expression wrappers, refs, node kinds, accessors, and root-node conversion APIs. |
Expression parser runtime data crates/ruff_python_parser/src/parser/expression.rs, crates/ruff_python_parser/src/parser/helpers.rs, crates/ruff_python_parser/src/parser/recovery.rs |
Expression parser paths initialize runtime_* fields for args, containers, strings, comparisons, and comprehensions, and constant literals are recognized in parser helpers and recovery. |
Statements, module, and pattern runtime data crates/ruff_python_parser/src/parser/mod.rs, crates/ruff_python_parser/src/parser/statement.rs, crates/ruff_python_parser/src/parser/pattern.rs |
Module, statement, and pattern parsing paths initialize the corresponding runtime_* fields on bodies, decorators, targets, match patterns, parameters, and type parameters. |
Constant-aware semantics crates/ruff_python_ast/src/comparable.rs, crates/ruff_python_ast/src/helpers.rs, crates/ruff_python_ast/src/operator_precedence.rs, crates/ruff_python_ast/src/relocate.rs |
Comparable and helper logic treat Expr::Constant and ConstantValue as literal-like values for comparison, hashing, truthiness, singleton detection, operator precedence, and relocation. |
Traversal and visitor updates crates/ruff_python_ast/src/node.rs, crates/ruff_python_ast/src/visitor.rs, crates/ruff_python_ast/src/visitor/source_order.rs, crates/ruff_python_ast/src/visitor/transformer.rs, crates/ruff_python_ast/src/generated.rs |
Traversal code visits Expr::Constant and broadens struct patterns to ignore the added runtime_* fields in source-order, walker, and transformer paths. |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~60 minutes
Poem
I hopped through Expr::Constant with a twitching nose,
And tucked runtime_* carrots where the AST grows.
I nibbled truthiness, then bounded through the trees,
While visitors and parsers rustled in the breeze.
🐇✨
✨ Finishing Touches
📝 Generate docstrings
- Create stacked PR
- Commit on current branch
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
runtime-field
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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|