Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use exported ruff types in vm/**
  • Loading branch information
ShaharNaveh committed Jul 22, 2025
commit 4c78ceaddbffe7ae193851bff65160fd37d03645
2 changes: 1 addition & 1 deletion vm/src/builtins/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{
};
use malachite_bigint::BigInt;
use num_traits::Zero;
use ruff_source_file::OneIndexed;
use rustpython_compiler_core::OneIndexed;
use std::{borrow::Borrow, fmt, ops::Deref};

#[derive(FromArgs)]
Expand Down
2 changes: 1 addition & 1 deletion vm/src/builtins/traceback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::{
Context, Py, PyPayload, PyRef, PyResult, VirtualMachine, class::PyClassImpl, frame::FrameRef,
types::Constructor,
};
use ruff_source_file::OneIndexed;
use rustpython_common::lock::PyMutex;
use rustpython_compiler_core::OneIndexed;

#[pyclass(module = false, name = "traceback", traverse)]
#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion vm/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use crate::{
};
use indexmap::IndexMap;
use itertools::Itertools;
use ruff_source_file::SourceLocation;
use rustpython_common::wtf8::Wtf8Buf;
use rustpython_compiler_core::SourceLocation;
#[cfg(feature = "threading")]
use std::sync::atomic;
use std::{fmt, iter::zip};
Expand Down
7 changes: 7 additions & 0 deletions vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ pub mod compiler;
pub mod convert;
mod coroutine;
mod dict_inner;

#[cfg(feature = "rustpython-compiler")]
pub mod eval;

pub mod exceptions;
pub mod format;
pub mod frame;
Expand All @@ -61,13 +63,17 @@ pub mod import;
mod intern;
pub mod iter;
pub mod object;

#[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
pub mod ospath;

pub mod prelude;
pub mod protocol;
pub mod py_io;

#[cfg(feature = "serde")]
pub mod py_serde;

pub mod readline;
pub mod recursion;
pub mod scope;
Expand All @@ -81,6 +87,7 @@ pub mod utils;
pub mod version;
pub mod vm;
pub mod warn;

#[cfg(windows)]
pub mod windows;

Expand Down
4 changes: 3 additions & 1 deletion vm/src/stdlib/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ use crate::{
};
use node::Node;
use ruff_python_ast as ruff;
use ruff_source_file::{LineIndex, OneIndexed, SourceFile, SourceFileBuilder, SourceLocation};
use ruff_text_size::{Ranged, TextRange, TextSize};
use rustpython_compiler_core::{
LineIndex, OneIndexed, SourceFile, SourceFileBuilder, SourceLocation,
};

#[cfg(feature = "parser")]
use ruff_python_parser as parser;
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/ast/argument.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use ruff_source_file::SourceFile;
use rustpython_compiler_core::SourceFile;

pub(super) struct PositionalArguments {
pub range: TextRange,
Expand Down
5 changes: 2 additions & 3 deletions vm/src/stdlib/ast/basic.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use ruff_source_file::SourceFile;
use rustpython_codegen::compile::ruff_int_to_bigint;

use super::*;
use rustpython_codegen::compile::ruff_int_to_bigint;
use rustpython_compiler_core::SourceFile;

impl Node for ruff::Identifier {
fn ast_to_object(self, vm: &VirtualMachine, _source_file: &SourceFile) -> PyObjectRef {
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/ast/constant.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::*;
use crate::builtins::{PyComplex, PyFrozenSet, PyTuple};
use ruff::str_prefix::StringLiteralPrefix;
use ruff_source_file::SourceFile;
use rustpython_compiler_core::SourceFile;

#[derive(Debug)]
pub(super) struct Constant {
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/ast/elif_else_clause.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use ruff_source_file::SourceFile;
use rustpython_compiler_core::SourceFile;

pub(super) fn ast_to_object(
clause: ruff::ElifElseClause,
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/ast/exception.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use ruff_source_file::SourceFile;
use rustpython_compiler_core::SourceFile;

// sum
impl Node for ruff::ExceptHandler {
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/ast/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::stdlib::ast::{
constant::Constant,
string::JoinedStr,
};
use ruff_source_file::SourceFile;
use rustpython_compiler_core::SourceFile;

// sum
impl Node for ruff::Expr {
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/ast/module.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;
use crate::stdlib::ast::type_ignore::TypeIgnore;
use ruff_source_file::SourceFile;
use rustpython_compiler_core::SourceFile;

/// Represents the different types of Python module structures.
///
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/ast/node.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{PyObjectRef, PyResult, VirtualMachine};
use ruff_source_file::SourceFile;
use rustpython_compiler_core::SourceFile;

pub(crate) trait Node: Sized {
fn ast_to_object(self, vm: &VirtualMachine, source_file: &SourceFile) -> PyObjectRef;
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/ast/operator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use ruff_source_file::SourceFile;
use rustpython_compiler_core::SourceFile;

// sum
impl Node for ruff::BoolOp {
Expand Down
3 changes: 1 addition & 2 deletions vm/src/stdlib/ast/other.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use super::*;
use num_traits::ToPrimitive;
use ruff_source_file::SourceFile;
use rustpython_compiler_core::bytecode;
use rustpython_compiler_core::{SourceFile, bytecode};

impl Node for ruff::ConversionFlag {
fn ast_to_object(self, vm: &VirtualMachine, _source_file: &SourceFile) -> PyObjectRef {
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/ast/parameter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use ruff_source_file::SourceFile;
use rustpython_compiler_core::SourceFile;

// product
impl Node for ruff::Parameters {
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/ast/pattern.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use ruff_source_file::SourceFile;
use rustpython_compiler_core::SourceFile;

// product
impl Node for ruff::MatchCase {
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/ast/statement.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;
use crate::stdlib::ast::argument::{merge_class_def_args, split_class_def_args};
use ruff_source_file::SourceFile;
use rustpython_compiler_core::SourceFile;

// sum
impl Node for ruff::Stmt {
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/ast/type_ignore.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use ruff_source_file::SourceFile;
use rustpython_compiler_core::SourceFile;

pub(super) enum TypeIgnore {
TypeIgnore(TypeIgnoreTypeIgnore),
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/ast/type_parameters.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use ruff_source_file::SourceFile;
use rustpython_compiler_core::SourceFile;

impl Node for ruff::TypeParams {
fn ast_to_object(self, vm: &VirtualMachine, source_file: &SourceFile) -> PyObjectRef {
Expand Down
3 changes: 1 addition & 2 deletions vm/src/vm/vm_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
scope::Scope,
vm::VirtualMachine,
};
use rustpython_compiler_core::SourceLocation;

macro_rules! define_exception_fn {
(
Expand Down Expand Up @@ -286,8 +287,6 @@ impl VirtualMachine {
source: Option<&str>,
allow_incomplete: bool,
) -> PyBaseExceptionRef {
use ruff_source_file::SourceLocation;

let syntax_error_type = match &error {
#[cfg(feature = "parser")]
// FIXME: this condition will cause TabError even when the matching actual error is IndentationError
Expand Down