From 22639c5a2aabb21b97b1f3b6366e1fe5d300d572 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Wed, 8 May 2024 10:56:50 +0200 Subject: [PATCH] Move all module from the AST to the semantic crate (#11330) --- crates/ruff_linter/src/checkers/ast/analyze/definitions.rs | 3 ++- crates/ruff_linter/src/checkers/ast/mod.rs | 2 +- crates/ruff_python_ast/src/lib.rs | 1 - crates/{ruff_python_ast => ruff_python_semantic}/src/all.rs | 5 ++--- crates/ruff_python_semantic/src/binding.rs | 2 +- crates/ruff_python_semantic/src/definition.rs | 3 ++- crates/ruff_python_semantic/src/lib.rs | 1 + 7 files changed, 9 insertions(+), 8 deletions(-) rename crates/{ruff_python_ast => ruff_python_semantic}/src/all.rs (99%) diff --git a/crates/ruff_linter/src/checkers/ast/analyze/definitions.rs b/crates/ruff_linter/src/checkers/ast/analyze/definitions.rs index 53a5df9c50..4bff13ac69 100644 --- a/crates/ruff_linter/src/checkers/ast/analyze/definitions.rs +++ b/crates/ruff_linter/src/checkers/ast/analyze/definitions.rs @@ -1,6 +1,7 @@ -use ruff_python_ast::{all::DunderAllName, str::raw_contents_range}; +use ruff_python_ast::str::raw_contents_range; use ruff_text_size::{Ranged, TextRange}; +use ruff_python_semantic::all::DunderAllName; use ruff_python_semantic::{ BindingKind, ContextualizedDefinition, Definition, Export, Member, MemberKind, }; diff --git a/crates/ruff_linter/src/checkers/ast/mod.rs b/crates/ruff_linter/src/checkers/ast/mod.rs index 259eda1bde..46c5430460 100644 --- a/crates/ruff_linter/src/checkers/ast/mod.rs +++ b/crates/ruff_linter/src/checkers/ast/mod.rs @@ -38,7 +38,6 @@ use ruff_text_size::{Ranged, TextRange, TextSize}; use ruff_diagnostics::{Diagnostic, IsolationLevel}; use ruff_notebook::{CellOffsets, NotebookIndex}; -use ruff_python_ast::all::{extract_all_names, DunderAllDefinition, DunderAllFlags}; use ruff_python_ast::helpers::{ collect_import_from_member, extract_handled_exceptions, is_docstring_stmt, to_module_path, }; @@ -50,6 +49,7 @@ use ruff_python_ast::{helpers, str, visitor, PySourceType}; use ruff_python_codegen::{Generator, Stylist}; use ruff_python_index::Indexer; use ruff_python_parser::typing::{parse_type_annotation, AnnotationKind}; +use ruff_python_semantic::all::{extract_all_names, DunderAllDefinition, DunderAllFlags}; use ruff_python_semantic::analyze::{imports, typing}; use ruff_python_semantic::{ BindingFlags, BindingId, BindingKind, Exceptions, Export, FromImport, Globals, Import, Module, diff --git a/crates/ruff_python_ast/src/lib.rs b/crates/ruff_python_ast/src/lib.rs index 52729e1981..ad284e70fe 100644 --- a/crates/ruff_python_ast/src/lib.rs +++ b/crates/ruff_python_ast/src/lib.rs @@ -5,7 +5,6 @@ pub use int::*; pub use node::{AnyNode, AnyNodeRef, AstNode, NodeKind}; pub use nodes::*; -pub mod all; pub mod comparable; pub mod docstrings; mod expression; diff --git a/crates/ruff_python_ast/src/all.rs b/crates/ruff_python_semantic/src/all.rs similarity index 99% rename from crates/ruff_python_ast/src/all.rs rename to crates/ruff_python_semantic/src/all.rs index 4a5899ce17..7b1204fe09 100644 --- a/crates/ruff_python_ast/src/all.rs +++ b/crates/ruff_python_semantic/src/all.rs @@ -1,8 +1,7 @@ use bitflags::bitflags; -use ruff_text_size::{Ranged, TextRange}; -use crate::helpers::map_subscript; -use crate::{self as ast, Expr, Stmt}; +use ruff_python_ast::{self as ast, helpers::map_subscript, Expr, Stmt}; +use ruff_text_size::{Ranged, TextRange}; bitflags! { #[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] diff --git a/crates/ruff_python_semantic/src/binding.rs b/crates/ruff_python_semantic/src/binding.rs index 9b791653ff..287fcc8627 100644 --- a/crates/ruff_python_semantic/src/binding.rs +++ b/crates/ruff_python_semantic/src/binding.rs @@ -3,8 +3,8 @@ use std::ops::{Deref, DerefMut}; use bitflags::bitflags; +use crate::all::DunderAllName; use ruff_index::{newtype_index, IndexSlice, IndexVec}; -use ruff_python_ast::all::DunderAllName; use ruff_python_ast::name::QualifiedName; use ruff_python_ast::Stmt; use ruff_source_file::Locator; diff --git a/crates/ruff_python_semantic/src/definition.rs b/crates/ruff_python_semantic/src/definition.rs index 90e24fbfe0..08e68552fd 100644 --- a/crates/ruff_python_semantic/src/definition.rs +++ b/crates/ruff_python_semantic/src/definition.rs @@ -5,8 +5,9 @@ use std::fmt::Debug; use std::ops::Deref; use std::path::Path; +use crate::all::DunderAllName; use ruff_index::{newtype_index, IndexSlice, IndexVec}; -use ruff_python_ast::{self as ast, all::DunderAllName, Stmt}; +use ruff_python_ast::{self as ast, Stmt}; use ruff_text_size::{Ranged, TextRange}; use crate::analyze::visibility::{ diff --git a/crates/ruff_python_semantic/src/lib.rs b/crates/ruff_python_semantic/src/lib.rs index ce45050239..daafde8ad6 100644 --- a/crates/ruff_python_semantic/src/lib.rs +++ b/crates/ruff_python_semantic/src/lib.rs @@ -1,3 +1,4 @@ +pub mod all; pub mod analyze; mod binding; mod branches;