GeezerVison is showing github.com — import ruff_python_ast only and don't imort its subitems by youknowone · Pull Request #6769 · RustPython/RustPython
Conversation
youknowone
commented
Jan 18, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary by CodeRabbit
- Refactor
- Standardized internal AST type references across the codebase to improve consistency and maintainability.
✏️ Tip: You can customize this high-level summary in your review settings.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Jan 18, 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
A comprehensive type-system refactor replacing direct ruff_python_ast imports with a unified ast alias across the codegen and VM stdlib AST modules. All function signatures, type references, enums, and internal implementations consistently migrate from ruff::* to ast::* types without behavioral changes.
Changes
| Cohort / File(s) |
Summary |
Codegen compile module crates/codegen/src/compile.rs |
Function signatures and all internal type references updated from concrete AST types to ast::* equivalents. Public APIs like compile_top, compile_program, compile_expression now accept/return &ast::Mod, &ast::ModModule, &ast::ModExpression instead of prior types. All pattern-matching branches and helper functions migrated to ast::Stmt, ast::Expr, ast::Parameters, etc. |
Codegen utilities crates/codegen/src/lib.rs, crates/codegen/src/string_parser.rs, crates/codegen/src/symboltable.rs |
ToPythonName impl target changed to ast::Expr. String parser struct/function signatures updated to accept ast::AnyStringFlags. Symbol table public APIs (scan_program, scan_expr) and all internal helpers refactored to use ast::* types uniformly across 40+ type references. |
Codegen unparse module crates/codegen/src/unparse.rs |
Unparser method signatures updated: p_id, unparse_expr, unparse_arguments, and related methods now operate on ast::Identifier, ast::Expr, ast::Parameters, ast::Comprehension, ast::InterpolatedStringElement, and other ast::* types. UnparseExpr struct field and constructor updated to use &ast::Expr. |
VM stdlib AST core types crates/vm/src/stdlib/ast/argument.rs, crates/vm/src/stdlib/ast/basic.rs, crates/vm/src/stdlib/ast/module.rs, crates/vm/src/stdlib/ast/operator.rs |
Public structs and Node trait impls migrated from ruff::* to ast::*. PositionalArguments.args and KeywordArguments.keywords now store Box<[ast::Expr]> and Box<[ast::Keyword]>. Enum variants Mod::Module and Mod::Expression updated to use ast::ModModule and ast::ModExpression. Node impls for BoolOp, Operator, UnaryOp, CmpOp retargeted to ast::* equivalents. |
VM stdlib AST advanced types crates/vm/src/stdlib/ast/constant.rs, crates/vm/src/stdlib/ast/elif_else_clause.rs, crates/vm/src/stdlib/ast/exception.rs |
Constructor signatures and internal mappings updated: Constant::new_int accepts ast::Int; into_expr returns ast::Expr. ElifElseClause handling switched from ruff::* to ast::*. Node impls for ExceptHandler and ExceptHandlerExceptHandler retargeted to ast::*. All literal-to-object conversions refactored to use ast::ExprNumberLiteral, ast::ExprStringLiteral, ast::ExprBytesLiteral, etc. |
VM stdlib AST expressions & comprehensions crates/vm/src/stdlib/ast/expression.rs |
All 26+ Node impl blocks migrated from ruff::Expr* variants to ast::Expr*. Includes BoolOp, Named, BinOp, UnaryOp, Lambda, If, Dict, Set, ListComp, SetComp, DictComp, Generator, Await, Yield, YieldFrom, Compare, Call, Attribute, Subscript, Starred, Name, List, Tuple, Slice, Context, and Comprehension. DictItem usage switched to ast::DictItem. |
VM stdlib AST patterns & parameters crates/vm/src/stdlib/ast/pattern.rs, crates/vm/src/stdlib/ast/parameter.rs |
Pattern matching Node impls and helper structs (e.g., PatternMatchClassPatterns, PatternMatchClassKeywordAttributes) updated to use ast::Pattern, ast::Identifier. MatchCase and all pattern variant constructors (MatchValue, MatchSingleton, MatchSequence, MatchMapping, MatchClass, MatchStar, MatchAs, MatchOr) switched to ast::*. Parameter container structs (PositionalParameters, KeywordParameters, ParameterDefaults) updated to store Box<[ast::Parameter]> and Box<[Option<Box<ast::Expr>>]>. Parameter merge/extract functions now return Vec<ast::ParameterWithDefault>. |
VM stdlib AST statements & strings crates/vm/src/stdlib/ast/statement.rs, crates/vm/src/stdlib/ast/string.rs |
23+ statement Node impl blocks migrated from ruff::Stmt* to ast::Stmt* (FunctionDef, ClassDef, Return, Delete, Assign, TypeAlias, AugAssign, AnnAssign, For, While, If, With, Match, Raise, Try, Assert, Import, ImportFrom, Global, Nonlocal, Expr, Pass, Break, Continue). String/f-string handling updated: InterpolatedStringElement, InterpolatedStringFormatSpec, FStringPart, InterpolatedStringLiteralElement now use ast::* prefixes. FormattedValue and TStringInterpolation fields refactored to store Box<ast::Expr> and ast::ConversionFlag. |
VM stdlib AST type parameters & misc crates/vm/src/stdlib/ast/type_parameters.rs, crates/vm/src/stdlib/ast/other.rs |
TypeParams and TypeParam Node impls and all variant constructors (TypeParamTypeVar, TypeParamParamSpec, TypeParamTypeVarTuple) migrated to ast::*. ConversionFlag, Name, Decorator, Alias, WithItem Node impls retargeted to ast::* with added/updated ast_from_object implementations. |
VM stdlib AST entry point crates/vm/src/stdlib/ast.rs |
Import alias changed from ruff_python_ast as ruff to ruff_python_ast as ast. Top-level Mod variant matching and related AST module construction paths updated to use ast::Mod* instead of ruff::Mod*. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
- impl more ast #6419 — Modifies
crates/vm/src/stdlib/ast/pattern.rs for pattern-class handling and serialization, directly overlapping with pattern type migration in this PR.
fn unparse_expr -> UnparseExpr::new #6121 — Updates unparse_expr calls in compile.rs and UnparseExpr::new signature, affecting the same unparse API refactored here to use ast::Expr.
- Update ruff 0.14.1 #6195 — Comprehensive AST type/signature updates across compile.rs, unparse.rs, symboltable.rs, and VM stdlib modules, with node_index and interpolated-string type changes overlapping this refactor's scope.
Suggested reviewers
🐰 Hoppy refactoring day! ✨
Ruff types now dance as ast::*,
From compile to VM, consistent at last,
No logic changed, just names recast—
The AST unified, holding fast! 🎉
✨ Finishing touches
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.
|
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.
|