GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add RustPython runtime AST fields by youknowone · Pull Request #2 · RustPython/ruff

Conversation

@youknowone

@youknowone youknowone commented Jun 25, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

All reactions
@youknowone
Add RustPython runtime AST fields
6fa1f8c
@coderabbitai

coderabbitai Bot commented Jun 25, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Review Change Stack

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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone merged commit 3c1ab2d into main Jun 25, 2026
1 check was pending

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone deleted the runtime-field branch June 25, 2026 04:47
@youknowone youknowone mentioned this pull request Jun 25, 2026
Update ruff to 0.15.19, use it from crates.io RustPython/RustPython#8160
Draft
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

1 participant

@youknowone
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.