Skip to content

Export ruff_source_file types in rustpython_compiler_core #6020

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

Merged
merged 3 commits into from
Jul 23, 2025

Conversation

ShaharNaveh
Copy link
Contributor

@ShaharNaveh ShaharNaveh commented Jul 22, 2025

Motivation: #6016 (review)

Summary by CodeRabbit

  • Refactor

    • Updated import sources throughout the codebase to use types from a different internal library, improving consistency and maintainability.
    • Removed unused dependencies from configuration files.
    • Enhanced code readability by reorganizing and consolidating import statements and adding spacing between module declarations.
  • Style

    • Improved formatting in module declarations for better visual clarity.

No changes to user-facing features or functionality.

Copy link
Contributor

coderabbitai bot commented Jul 22, 2025

Walkthrough

This change refactors imports across multiple Rust project modules, replacing usage of types such as SourceFile, SourceLocation, and OneIndexed from the ruff_source_file crate with imports from rustpython_compiler_core. It also removes the ruff_source_file dependency from relevant Cargo.toml files and updates public re-exports accordingly. No functional or logic changes are introduced.

Changes

Files/Paths Change Summary
compiler/codegen/Cargo.toml, vm/Cargo.toml Remove ruff_source_file dependency from dependencies.
compiler/core/src/lib.rs Publicly re-export LineIndex, OneIndexed, SourceFile, SourceFileBuilder, SourceLocation from ruff_source_file.
compiler/codegen/src/compile.rs, error.rs, symboltable.rs, unparse.rs Refactor imports: use types from rustpython_compiler_core instead of ruff_source_file.
compiler/codegen/src/ir.rs Reorganize and consolidate imports for clarity; add blank lines for readability.
compiler/core/src/bytecode.rs, marshal.rs Change imports of OneIndexed and SourceLocation to local crate or rustpython_compiler_core.
vm/src/builtins/code.rs, traceback.rs, frame.rs Change imports of OneIndexed/SourceLocation to rustpython_compiler_core.
vm/src/lib.rs Add blank lines for formatting between module declarations.
vm/src/stdlib/ast.rs, ast/argument.rs, ast/basic.rs, ast/constant.rs, ast/elif_else_clause.rs, ast/exception.rs, ast/expression.rs, ast/module.rs, ast/node.rs, ast/operator.rs, ast/other.rs, ast/parameter.rs, ast/pattern.rs, ast/statement.rs, ast/type_ignore.rs, ast/type_parameters.rs Change SourceFile (and related) imports to rustpython_compiler_core.
vm/src/vm/vm_new.rs Remove unused import; import SourceLocation from rustpython_compiler_core at module level.

Sequence Diagram(s)

No sequence diagram generated as the changes are limited to import refactoring and do not affect control flow or introduce new features.

Estimated code review effort

1 (~8 minutes)

Possibly related PRs

  • RustPython/RustPython#6016: Refactors source representation types, switching from internal modules to ruff_source_file::SourceFile. Both PRs involve changes to source file abstractions, but focus on different crates and abstraction layers.

Poem

In the warren, imports hop and play,
From ruff_source_file, they leap away.
Now in the core, their home anew,
With tidy lines and modules too.
The carrots of clarity, crisp and bright—
This rabbit’s code feels just right! 🥕

✨ 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (4)
vm/src/stdlib/ast/type_ignore.rs (1)

2-2: Consistent crate migration

The import is updated exactly as in other modules. Good.

vm/src/stdlib/ast/argument.rs (1)

2-2: Import realigned

Nothing further; implementation remains unchanged.

vm/src/stdlib/ast/exception.rs (1)

2-2: Import realigned

Matches the new crate structure.

vm/src/stdlib/ast/module.rs (1)

3-3: Import realigned

Consistent with the rest of the refactor.

🧹 Nitpick comments (4)
compiler/codegen/src/error.rs (1)

20-20: Stale commented-out type alias
// pub type CodegenError = rustpython_parser_core::source_code::LocatedError<…> is no longer accurate and can be misleading after the crate reshuffle. Consider deleting or updating.

-// pub type CodegenError = rustpython_parser_core::source_code::LocatedError<CodegenErrorType>;
+// (outdated alias removed – `SourceLocation` is now provided by `rustpython_compiler_core`)
compiler/core/src/marshal.rs (1)

1-1: Consider replacing the glob import for bytecode

bytecode::* brings the entire module into scope, which can mask name clashes and hurts traceability.
If only a handful of symbols are required, import them explicitly.

-use crate::{OneIndexed, SourceLocation, bytecode::*};
+use crate::{
+    OneIndexed,
+    SourceLocation,
+    bytecode::{CodeObject, CodeUnit, Instruction, OpArgByte, CodeFlags},
+};
compiler/codegen/src/compile.rs (2)

632-635: Avoid the unnecessary unwrap() in constant construction

OneIndexed::new(1).unwrap() can never fail, therefore the call to unwrap() only adds panic potential for future refactors. Prefer the already-available constant to make the intent explicit and remove fallible code:

-            column: OneIndexed::new(1).unwrap(),
+            column: OneIndexed::MIN,

(The same pattern appears a few lines below; apply the same replacement there.)


770-773: Same unwrap() pattern – apply the constant here as well

-            column: OneIndexed::MIN,
+            column: OneIndexed::MIN,  // already fixed above, keep consistent

No functional change, just consistency with the previous suggestion.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba22ad2 and d65dfc6.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (31)
  • compiler/codegen/Cargo.toml (0 hunks)
  • compiler/codegen/src/compile.rs (4 hunks)
  • compiler/codegen/src/error.rs (1 hunks)
  • compiler/codegen/src/ir.rs (4 hunks)
  • compiler/codegen/src/symboltable.rs (1 hunks)
  • compiler/codegen/src/unparse.rs (1 hunks)
  • compiler/core/src/bytecode.rs (1 hunks)
  • compiler/core/src/lib.rs (1 hunks)
  • compiler/core/src/marshal.rs (1 hunks)
  • vm/Cargo.toml (0 hunks)
  • vm/src/builtins/code.rs (1 hunks)
  • vm/src/builtins/traceback.rs (1 hunks)
  • vm/src/frame.rs (1 hunks)
  • vm/src/lib.rs (3 hunks)
  • vm/src/stdlib/ast.rs (1 hunks)
  • vm/src/stdlib/ast/argument.rs (1 hunks)
  • vm/src/stdlib/ast/basic.rs (1 hunks)
  • vm/src/stdlib/ast/constant.rs (1 hunks)
  • vm/src/stdlib/ast/elif_else_clause.rs (1 hunks)
  • vm/src/stdlib/ast/exception.rs (1 hunks)
  • vm/src/stdlib/ast/expression.rs (1 hunks)
  • vm/src/stdlib/ast/module.rs (1 hunks)
  • vm/src/stdlib/ast/node.rs (1 hunks)
  • vm/src/stdlib/ast/operator.rs (1 hunks)
  • vm/src/stdlib/ast/other.rs (1 hunks)
  • vm/src/stdlib/ast/parameter.rs (1 hunks)
  • vm/src/stdlib/ast/pattern.rs (1 hunks)
  • vm/src/stdlib/ast/statement.rs (1 hunks)
  • vm/src/stdlib/ast/type_ignore.rs (1 hunks)
  • vm/src/stdlib/ast/type_parameters.rs (1 hunks)
  • vm/src/vm/vm_new.rs (1 hunks)
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

**/*.rs: Follow the default rustfmt code style (cargo fmt to format)
Always run clippy to lint code (cargo clippy) before completing tasks. Fix any warnings or lints that are introduced by your 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:

  • vm/src/builtins/traceback.rs
  • vm/src/stdlib/ast/exception.rs
  • vm/src/stdlib/ast/type_parameters.rs
  • vm/src/stdlib/ast/parameter.rs
  • vm/src/stdlib/ast/constant.rs
  • vm/src/stdlib/ast/node.rs
  • vm/src/stdlib/ast/operator.rs
  • compiler/codegen/src/error.rs
  • vm/src/stdlib/ast.rs
  • vm/src/stdlib/ast/type_ignore.rs
  • vm/src/stdlib/ast/elif_else_clause.rs
  • vm/src/stdlib/ast/pattern.rs
  • vm/src/builtins/code.rs
  • vm/src/stdlib/ast/argument.rs
  • vm/src/stdlib/ast/module.rs
  • vm/src/stdlib/ast/basic.rs
  • vm/src/stdlib/ast/statement.rs
  • vm/src/stdlib/ast/other.rs
  • compiler/codegen/src/ir.rs
  • compiler/core/src/bytecode.rs
  • vm/src/vm/vm_new.rs
  • compiler/core/src/marshal.rs
  • compiler/codegen/src/unparse.rs
  • vm/src/stdlib/ast/expression.rs
  • compiler/core/src/lib.rs
  • vm/src/frame.rs
  • compiler/codegen/src/symboltable.rs
  • vm/src/lib.rs
  • compiler/codegen/src/compile.rs
💤 Files with no reviewable changes (2)
  • vm/Cargo.toml
  • compiler/codegen/Cargo.toml
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

**/*.rs: Follow the default rustfmt code style (cargo fmt to format)
Always run clippy to lint code (cargo clippy) before completing tasks. Fix any warnings or lints that are introduced by your 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:

  • vm/src/builtins/traceback.rs
  • vm/src/stdlib/ast/exception.rs
  • vm/src/stdlib/ast/type_parameters.rs
  • vm/src/stdlib/ast/parameter.rs
  • vm/src/stdlib/ast/constant.rs
  • vm/src/stdlib/ast/node.rs
  • vm/src/stdlib/ast/operator.rs
  • compiler/codegen/src/error.rs
  • vm/src/stdlib/ast.rs
  • vm/src/stdlib/ast/type_ignore.rs
  • vm/src/stdlib/ast/elif_else_clause.rs
  • vm/src/stdlib/ast/pattern.rs
  • vm/src/builtins/code.rs
  • vm/src/stdlib/ast/argument.rs
  • vm/src/stdlib/ast/module.rs
  • vm/src/stdlib/ast/basic.rs
  • vm/src/stdlib/ast/statement.rs
  • vm/src/stdlib/ast/other.rs
  • compiler/codegen/src/ir.rs
  • compiler/core/src/bytecode.rs
  • vm/src/vm/vm_new.rs
  • compiler/core/src/marshal.rs
  • compiler/codegen/src/unparse.rs
  • vm/src/stdlib/ast/expression.rs
  • compiler/core/src/lib.rs
  • vm/src/frame.rs
  • compiler/codegen/src/symboltable.rs
  • vm/src/lib.rs
  • compiler/codegen/src/compile.rs
🔇 Additional comments (28)
vm/src/lib.rs (1)

54-57: Stylistic newline insertions look fine

The added blank lines around selected pub mod declarations improve visual grouping and do not affect behaviour. cargo fmt will keep this layout stable, so no further action needed.

Also applies to: 67-70, 73-76, 90-93

compiler/codegen/src/ir.rs (2)

3-10: Import consolidation is correct and follows the new re-export path

Switching to rustpython_compiler_core::{ OneIndexed, SourceLocation, bytecode::… } removes the external ruff_source_file dependency and matches the core crate’s public re-exports. No functional impact; compilation should succeed as long as rustpython_compiler_core is in the workspace members list.


39-40: Whitespace tweaks only

The extra blank lines between impl blocks aid readability and are neutral regarding generated code.

Also applies to: 48-49, 54-55, 62-63, 85-86, 117-118

vm/src/builtins/traceback.rs (1)

7-8: Updated import path is accurate

OneIndexed now comes from rustpython_compiler_core; the rest of the file already depends on that crate via other modules. 👍

vm/src/builtins/code.rs (2)

18-18: Import path change acknowledged

The switch to rustpython_compiler_core::OneIndexed is consistent with the global refactor.


358-361: Type consistency remains intact

OneIndexed::new(first_line_number as _) still yields an Option<OneIndexed>, matching the first_line_number field’s type; no further change required.

vm/src/stdlib/ast/node.rs (1)

2-2: Import source relocation is correct

SourceFile is now re-exported from rustpython_compiler_core; the rest of the AST helpers remain unchanged.

compiler/codegen/src/error.rs (2)

1-1: Import path update looks correct
Switching to rustpython_compiler_core::SourceLocation aligns with the new re-export strategy. No further action needed here.


1-1: Replace remaining ruff_source_file imports

We still have direct references to the old crate throughout the workspace. Please update these to use the rustpython_compiler_core exports and remove the ruff_source_file dependency:

• Files importing from ruff_source_file:

  • compiler/core/src/lib.rs
  • compiler/src/lib.rs
  • compiler/source/src/lib.rs

Change, for example:

pub use ruff_source_file::{LineIndex, OneIndexed, SourceFile, SourceFileBuilder, SourceLocation};

to

pub use rustpython_compiler_core::{LineIndex, OneIndexed, SourceFile, SourceFileBuilder, SourceLocation};

• Cargo.toml entries pulling in ruff_source_file:

  • Cargo.toml (root)
  • compiler/core/Cargo.toml
  • compiler/Cargo.toml
  • compiler/source/Cargo.toml

Remove the ruff_source_file = { … } lines and replace them with your local path or workspace reference to rustpython_compiler_core if needed.

After making these changes, run cargo update to regenerate Cargo.lock and verify that no ruff_source_file remains in your lock file.

⛔ Skipped due to learnings
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.py : Use ruff for linting Python code
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to Lib/test/**/*.py : When tests fail due to unsupported syntax, keep the test as `@unittest.expectedFailure`, document that it requires PEP 695 support, and focus on tests that can be fixed through Rust code changes only
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: In most cases, Python code should not be edited. Bug fixes should be made through Rust code modifications only
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Always run clippy to lint code (`cargo clippy`) before completing tasks. Fix any warnings or lints that are introduced by your changes
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Follow the default rustfmt code style (`cargo fmt` to format)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to Lib/**/*.py : Minimize modifications to CPython standard library files in `Lib/`
vm/src/stdlib/ast/constant.rs (1)

4-4: Import updated successfully

SourceFile is now taken from rustpython_compiler_core; matches the new public re-export.

vm/src/stdlib/ast/type_parameters.rs (1)

2-2: Consistent with refactor

Import path change looks good and keeps this module in sync with the rest of the tree.

vm/src/stdlib/ast/operator.rs (1)

2-2: LGTM

Import source updated; no further issues spotted.

vm/src/stdlib/ast/pattern.rs (1)

2-2: Import path aligned

Matches the crate consolidation; everything compiles as expected.

vm/src/stdlib/ast/statement.rs (1)

3-3: All SourceFile imports updated correctly

Ran rg -n "ruff_source_file::SourceFile" and found no remaining references to the old path. No further changes are needed in vm/src/stdlib/ast/statement.rs.
LGTM.

vm/src/stdlib/ast/parameter.rs (1)

2-2: Import path updated correctly

SourceFile now comes from rustpython_compiler_core, which matches the new re-export strategy. No further action required.

vm/src/stdlib/ast/elif_else_clause.rs (1)

2-2: Consistent migration to rustpython_compiler_core

The import swap is straightforward and keeps the file in sync with the rest of the workspace.

vm/src/stdlib/ast.rs (1)

25-27: Migrate residual ruff_source_file imports to rustpython_compiler_core

The search uncovered three remaining ruff_source_file:: imports that need updating. Please replace them with the corresponding rustpython_compiler_core re-exports:

• compiler/src/lib.rs:1

- use ruff_source_file::{SourceFile, SourceFileBuilder, SourceLocation};
+ use rustpython_compiler_core::{SourceFile, SourceFileBuilder, SourceLocation};

• compiler/source/src/lib.rs:1

- pub use ruff_source_file::{LineIndex, OneIndexed as LineNumber, SourceLocation};
+ pub use rustpython_compiler_core::{LineIndex, OneIndexed as LineNumber, SourceLocation};

• compiler/core/src/lib.rs:11

- pub use ruff_source_file::{LineIndex, OneIndexed, SourceFile, SourceFileBuilder, SourceLocation};
+ pub use rustpython_compiler_core::{LineIndex, OneIndexed, SourceFile, SourceFileBuilder, SourceLocation};

After making these changes, rerun your grep check to confirm no further ruff_source_file:: references remain.

⛔ Skipped due to learnings
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.py : Use ruff for linting Python code
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to Lib/test/**/*.py : When tests fail due to unsupported syntax, keep the test as `@unittest.expectedFailure`, document that it requires PEP 695 support, and focus on tests that can be fixed through Rust code changes only
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration using #ifdef checks rather than providing fallback values for other platforms.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: In most cases, Python code should not be edited. Bug fixes should be made through Rust code modifications only
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Follow the default rustfmt code style (`cargo fmt` to format)
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration rather than providing fallback values for other platforms.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to Lib/**/*.py : Minimize modifications to CPython standard library files in `Lib/`
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Always run clippy to lint code (`cargo clippy`) before completing tasks. Fix any warnings or lints that are introduced by your changes
vm/src/frame.rs (1)

25-25: Import aligns with the new core crate

SourceLocation now resolves via rustpython_compiler_core; looks good.

vm/src/vm/vm_new.rs (1)

15-15: Replace all remaining ruff_source_file imports with rustpython_compiler_core

The search revealed three straggling references that need updating:

  • compiler/src/lib.rs:1
  • compiler/core/src/lib.rs:11
  • compiler/source/src/lib.rs:1

Suggested replacements:

--- a/compiler/src/lib.rs
+++ b/compiler/src/lib.rs
-use ruff_source_file::{SourceFile, SourceFileBuilder, SourceLocation};
+use rustpython_compiler_core::{SourceFile, SourceFileBuilder, SourceLocation};
--- a/compiler/core/src/lib.rs
+++ b/compiler/core/src/lib.rs
-pub use ruff_source_file::{LineIndex, OneIndexed, SourceFile, SourceFileBuilder, SourceLocation};
+pub use rustpython_compiler_core::{LineIndex, OneIndexed, SourceFile, SourceFileBuilder, SourceLocation};
--- a/compiler/source/src/lib.rs
+++ b/compiler/source/src/lib.rs
-pub use ruff_source_file::{LineIndex, OneIndexed as LineNumber, SourceLocation};
+pub use rustpython_compiler_core::{LineIndex, OneIndexed as LineNumber, SourceLocation};

After applying these changes, rerun rg -n "ruff_source_file::" to verify no remaining references.

⛔ Skipped due to learnings
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.py : Use ruff for linting Python code
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to Lib/test/**/*.py : When tests fail due to unsupported syntax, keep the test as `@unittest.expectedFailure`, document that it requires PEP 695 support, and focus on tests that can be fixed through Rust code changes only
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Follow the default rustfmt code style (`cargo fmt` to format)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: In most cases, Python code should not be edited. Bug fixes should be made through Rust code modifications only
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration using #ifdef checks rather than providing fallback values for other platforms.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Always run clippy to lint code (`cargo clippy`) before completing tasks. Fix any warnings or lints that are introduced by your changes
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration rather than providing fallback values for other platforms.
vm/src/stdlib/ast/expression.rs (1)

7-7: Consistent crate swap – no further action required.

SourceFile is now re-exported from rustpython_compiler_core; all downstream calls remain unchanged, so the edit is correct.

vm/src/stdlib/ast/basic.rs (1)

2-3: Import additions align with usage.

ruff_int_to_bigint and the new SourceFile path are both consumed below, so clippy shouldn’t complain about unused imports.

compiler/codegen/src/unparse.rs (1)

1-4: Import refactor is correct – keep cargo fmt happy.

Switching to the granular ruff_python_ast list plus the new SourceFile path removes the dependency on ruff_source_file without changing behaviour. Make sure the long list still respects rustfmt’s line-wrap rules after reformatting.

Also applies to: 6-6

vm/src/stdlib/ast/other.rs (1)

3-3: Combined import is accurate.

Both SourceFile and bytecode are used below; combining into one line is stylistically fine.

compiler/core/src/bytecode.rs (1)

4-4: Import path switch looks good.

Moving OneIndexed & SourceLocation to crate::{…} correctly leverages the new re-exports and removes the external dependency from this module. No functional impact.

Also applies to: 10-10

compiler/codegen/src/symboltable.rs (1)

22-22: Correct crate switch; check that compiler/codegen no longer depends on ruff_source_file.

The new import matches the public re-exports in rustpython_compiler_core.
Verify that compiler/codegen/Cargo.toml had its ruff_source_file entry removed, otherwise the dependency graph will still include it unnecessarily.

compiler/core/src/lib.rs (1)

11-11: Public re-export is fine, but ensure ruff_source_file remains an explicit dependency of this crate.

rustpython_compiler_core now acts as the single import hub for these types—great for ergonomics.
However, because you’re re-exporting directly from ruff_source_file, compiler/core/Cargo.toml must still list that crate; otherwise downstream crates relying only on rustpython_compiler_core might build but the core crate itself will fail.

compiler/codegen/src/compile.rs (2)

34-36: Imports correctly re-pointed to rustpython_compiler_core

The switch from the external ruff_source_file crate to the public re-exports in rustpython_compiler_core looks clean and keeps the external surface unchanged at the call-sites. Good catch on importing Mode alongside the three re-exported types.


5843-5844: Test helper import LGTM

The tests now pull SourceFileBuilder from the unified crate; compilation path is consistent with the production code.

@@ -1,7 +1,6 @@
use crate::bytecode::*;
use crate::{OneIndexed, SourceLocation, bytecode::*};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

Verify root-level re-export of OneIndexed / SourceLocation

marshal.rs now pulls these types from crate, so rustpython_compiler_core::lib.rs must pub use them.
Please confirm with a quick search:


🏁 Script executed:

#!/bin/bash
# Ensure the symbols are publicly exposed at crate root
rg -n $'^\\s*pub\\s+use\\s+ruff_source_file::(OneIndexed|SourceLocation)' compiler/core/src/lib.rs

Length of output: 96


Add missing re-exports of OneIndexed and SourceLocation at crate root

The import in marshal.rs (use crate::{OneIndexed, SourceLocation, …};) will fail because these types aren’t publicly re-exported from the crate root.

• File needing update:

  • compiler/core/src/lib.rs – add the following alongside the other pub use statements.
diff --git a/compiler/core/src/lib.rs b/compiler/core/src/lib.rs
index abc1234..def5678 100644
--- a/compiler/core/src/lib.rs
+++ b/compiler/core/src/lib.rs
@@
 pub use bytecode::*;
+pub use ruff_source_file::{OneIndexed, SourceLocation};
🤖 Prompt for AI Agents
In compiler/core/src/lib.rs near the top where other pub use statements are, add
public re-exports for OneIndexed and SourceLocation to make them accessible from
the crate root. This will fix the import failure in marshal.rs by allowing these
types to be imported publicly from the crate.

Copy link
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@youknowone youknowone merged commit 96f47a4 into RustPython:main Jul 23, 2025
12 checks passed
@ShaharNaveh ShaharNaveh deleted the export-ruff-types branch July 23, 2025 08:58
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.

2 participants