diff --git a/crates/ruff/src/checkers/ast/deferred.rs b/crates/ruff/src/checkers/ast/deferred.rs index ab74d51234..e72f7dbd46 100644 --- a/crates/ruff/src/checkers/ast/deferred.rs +++ b/crates/ruff/src/checkers/ast/deferred.rs @@ -1,7 +1,7 @@ use ruff_text_size::TextRange; use rustpython_parser::ast::Expr; -use ruff_python_semantic::model::Snapshot; +use ruff_python_semantic::Snapshot; /// A collection of AST nodes that are deferred for later analysis. /// Used to, e.g., store functions, whose bodies shouldn't be analyzed until all diff --git a/crates/ruff/src/checkers/ast/mod.rs b/crates/ruff/src/checkers/ast/mod.rs index 3940ee8e16..6fa683363c 100644 --- a/crates/ruff/src/checkers/ast/mod.rs +++ b/crates/ruff/src/checkers/ast/mod.rs @@ -18,19 +18,13 @@ use ruff_python_ast::types::Node; use ruff_python_ast::typing::{parse_type_annotation, AnnotationKind}; use ruff_python_ast::visitor::{walk_excepthandler, walk_pattern, Visitor}; use ruff_python_ast::{cast, helpers, str, visitor}; -use ruff_python_semantic::analyze; -use ruff_python_semantic::analyze::branch_detection; -use ruff_python_semantic::analyze::typing::{Callable, SubscriptKind}; -use ruff_python_semantic::analyze::visibility::ModuleSource; -use ruff_python_semantic::binding::{ - Binding, BindingFlags, BindingId, BindingKind, Exceptions, Export, FromImportation, - Importation, StarImportation, SubmoduleImportation, +use ruff_python_semantic::analyze::{branch_detection, typing, visibility}; +use ruff_python_semantic::{ + Binding, BindingFlags, BindingId, BindingKind, ContextualizedDefinition, Exceptions, + ExecutionContext, Export, FromImportation, Globals, Importation, Module, ModuleKind, + ResolvedRead, Scope, ScopeId, ScopeKind, SemanticModel, SemanticModelFlags, StarImportation, + SubmoduleImportation, }; -use ruff_python_semantic::context::ExecutionContext; -use ruff_python_semantic::definition::{ContextualizedDefinition, Module, ModuleKind}; -use ruff_python_semantic::globals::Globals; -use ruff_python_semantic::model::{ResolvedRead, SemanticModel, SemanticModelFlags}; -use ruff_python_semantic::scope::{Scope, ScopeId, ScopeKind}; use ruff_python_stdlib::builtins::{BUILTINS, MAGIC_GLOBALS}; use ruff_python_stdlib::path::is_python_stub_file; @@ -2079,7 +2073,7 @@ where ) => { self.visit_boolean_test(test); - if analyze::typing::is_type_checking_block(stmt_if, &self.semantic_model) { + if typing::is_type_checking_block(stmt_if, &self.semantic_model) { if self.semantic_model.at_top_level() { self.importer.visit_type_checking_block(stmt); } @@ -2179,7 +2173,7 @@ where Rule::NonPEP604Annotation, ]) { if let Some(operator) = - analyze::typing::to_pep604_operator(value, slice, &self.semantic_model) + typing::to_pep604_operator(value, slice, &self.semantic_model) { if self.enabled(Rule::FutureRewritableTypeAnnotation) { if self.settings.target_version < PythonVersion::Py310 @@ -2211,7 +2205,7 @@ where if self.settings.target_version < PythonVersion::Py39 && !self.semantic_model.future_annotations() && self.semantic_model.in_annotation() - && analyze::typing::is_pep585_generic(value, &self.semantic_model) + && typing::is_pep585_generic(value, &self.semantic_model) { flake8_future_annotations::rules::future_required_type_annotation( self, @@ -2284,7 +2278,7 @@ where Rule::NonPEP585Annotation, ]) { if let Some(replacement) = - analyze::typing::to_pep585_generic(expr, &self.semantic_model) + typing::to_pep585_generic(expr, &self.semantic_model) { if self.enabled(Rule::FutureRewritableTypeAnnotation) { if self.settings.target_version < PythonVersion::Py39 @@ -2360,8 +2354,7 @@ where Rule::FutureRewritableTypeAnnotation, Rule::NonPEP585Annotation, ]) { - if let Some(replacement) = - analyze::typing::to_pep585_generic(expr, &self.semantic_model) + if let Some(replacement) = typing::to_pep585_generic(expr, &self.semantic_model) { if self.enabled(Rule::FutureRewritableTypeAnnotation) { if self.settings.target_version < PythonVersion::Py39 @@ -3576,27 +3569,27 @@ where .semantic_model .match_typing_call_path(&call_path, "cast") { - Some(Callable::Cast) + Some(typing::Callable::Cast) } else if self .semantic_model .match_typing_call_path(&call_path, "NewType") { - Some(Callable::NewType) + Some(typing::Callable::NewType) } else if self .semantic_model .match_typing_call_path(&call_path, "TypeVar") { - Some(Callable::TypeVar) + Some(typing::Callable::TypeVar) } else if self .semantic_model .match_typing_call_path(&call_path, "NamedTuple") { - Some(Callable::NamedTuple) + Some(typing::Callable::NamedTuple) } else if self .semantic_model .match_typing_call_path(&call_path, "TypedDict") { - Some(Callable::TypedDict) + Some(typing::Callable::TypedDict) } else if [ "Arg", "DefaultArg", @@ -3608,15 +3601,15 @@ where .iter() .any(|target| call_path.as_slice() == ["mypy_extensions", target]) { - Some(Callable::MypyExtension) + Some(typing::Callable::MypyExtension) } else if call_path.as_slice() == ["", "bool"] { - Some(Callable::Bool) + Some(typing::Callable::Bool) } else { None } }); match callable { - Some(Callable::Bool) => { + Some(typing::Callable::Bool) => { self.visit_expr(func); let mut args = args.iter(); if let Some(arg) = args.next() { @@ -3626,7 +3619,7 @@ where self.visit_expr(arg); } } - Some(Callable::Cast) => { + Some(typing::Callable::Cast) => { self.visit_expr(func); let mut args = args.iter(); if let Some(arg) = args.next() { @@ -3636,7 +3629,7 @@ where self.visit_expr(arg); } } - Some(Callable::NewType) => { + Some(typing::Callable::NewType) => { self.visit_expr(func); let mut args = args.iter(); if let Some(arg) = args.next() { @@ -3646,7 +3639,7 @@ where self.visit_type_definition(arg); } } - Some(Callable::TypeVar) => { + Some(typing::Callable::TypeVar) => { self.visit_expr(func); let mut args = args.iter(); if let Some(arg) = args.next() { @@ -3670,7 +3663,7 @@ where } } } - Some(Callable::NamedTuple) => { + Some(typing::Callable::NamedTuple) => { self.visit_expr(func); // Ex) NamedTuple("a", [("a", int)]) @@ -3707,7 +3700,7 @@ where self.visit_type_definition(value); } } - Some(Callable::TypedDict) => { + Some(typing::Callable::TypedDict) => { self.visit_expr(func); // Ex) TypedDict("a", {"a": int}) @@ -3739,7 +3732,7 @@ where self.visit_type_definition(value); } } - Some(Callable::MypyExtension) => { + Some(typing::Callable::MypyExtension) => { self.visit_expr(func); let mut args = args.iter(); @@ -3801,7 +3794,7 @@ where self.semantic_model.flags |= SemanticModelFlags::SUBSCRIPT; visitor::walk_expr(self, expr); } else { - match analyze::typing::match_annotated_subscript( + match typing::match_annotated_subscript( value, &self.semantic_model, self.settings.typing_modules.iter().map(String::as_str), @@ -3810,13 +3803,13 @@ where Some(subscript) => { match subscript { // Ex) Optional[int] - SubscriptKind::AnnotatedSubscript => { + typing::SubscriptKind::AnnotatedSubscript => { self.visit_expr(value); self.visit_type_definition(slice); self.visit_expr_context(ctx); } // Ex) Annotated[int, "Hello, world!"] - SubscriptKind::PEP593AnnotatedSubscript => { + typing::SubscriptKind::PEP593AnnotatedSubscript => { // First argument is a type (including forward references); the // rest are arbitrary Python objects. self.visit_expr(value); @@ -4291,7 +4284,7 @@ impl<'a> Checker<'a> { && binding.redefines(shadowed) && (!self.settings.dummy_variable_rgx.is_match(name) || shadows_import) && !(shadowed.kind.is_function_definition() - && analyze::visibility::is_overload( + && visibility::is_overload( &self.semantic_model, cast::decorator_list( self.semantic_model.stmts[shadowed.source.unwrap()], @@ -5298,9 +5291,9 @@ pub(crate) fn check_ast( ModuleKind::Module }, source: if let Some(module_path) = module_path.as_ref() { - ModuleSource::Path(module_path) + visibility::ModuleSource::Path(module_path) } else { - ModuleSource::File(path) + visibility::ModuleSource::File(path) }, python_ast, }; diff --git a/crates/ruff/src/docstrings/extraction.rs b/crates/ruff/src/docstrings/extraction.rs index aa64249425..d4ae103b2f 100644 --- a/crates/ruff/src/docstrings/extraction.rs +++ b/crates/ruff/src/docstrings/extraction.rs @@ -2,7 +2,7 @@ use rustpython_parser::ast::{self, Constant, Expr, Stmt}; -use ruff_python_semantic::definition::{Definition, DefinitionId, Definitions, Member, MemberKind}; +use ruff_python_semantic::{Definition, DefinitionId, Definitions, Member, MemberKind}; /// Extract a docstring from a function or class body. pub(crate) fn docstring_from(suite: &[Stmt]) -> Option<&Expr> { diff --git a/crates/ruff/src/docstrings/mod.rs b/crates/ruff/src/docstrings/mod.rs index b9df42d415..3103aa5a62 100644 --- a/crates/ruff/src/docstrings/mod.rs +++ b/crates/ruff/src/docstrings/mod.rs @@ -4,7 +4,7 @@ use std::ops::Deref; use ruff_text_size::{TextRange, TextSize}; use rustpython_parser::ast::{Expr, Ranged}; -use ruff_python_semantic::definition::Definition; +use ruff_python_semantic::Definition; pub(crate) mod extraction; pub(crate) mod google; diff --git a/crates/ruff/src/importer/mod.rs b/crates/ruff/src/importer/mod.rs index 53b7fbb597..b31d97a066 100644 --- a/crates/ruff/src/importer/mod.rs +++ b/crates/ruff/src/importer/mod.rs @@ -10,7 +10,7 @@ use rustpython_parser::ast::{self, Ranged, Stmt, Suite}; use ruff_diagnostics::Edit; use ruff_python_ast::imports::{AnyImport, Import, ImportFrom}; use ruff_python_ast::source_code::{Locator, Stylist}; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use ruff_textwrap::indent; use crate::autofix; diff --git a/crates/ruff/src/rules/flake8_2020/helpers.rs b/crates/ruff/src/rules/flake8_2020/helpers.rs index e5bb8fd4b6..81f3e83383 100644 --- a/crates/ruff/src/rules/flake8_2020/helpers.rs +++ b/crates/ruff/src/rules/flake8_2020/helpers.rs @@ -1,6 +1,7 @@ -use ruff_python_semantic::model::SemanticModel; use rustpython_parser::ast::Expr; +use ruff_python_semantic::SemanticModel; + pub(super) fn is_sys(model: &SemanticModel, expr: &Expr, target: &str) -> bool { model .resolve_call_path(expr) diff --git a/crates/ruff/src/rules/flake8_annotations/helpers.rs b/crates/ruff/src/rules/flake8_annotations/helpers.rs index 82732c5819..7a3bd1bb15 100644 --- a/crates/ruff/src/rules/flake8_annotations/helpers.rs +++ b/crates/ruff/src/rules/flake8_annotations/helpers.rs @@ -2,8 +2,7 @@ use rustpython_parser::ast::{self, Arguments, Expr, Stmt}; use ruff_python_ast::cast; use ruff_python_semantic::analyze::visibility; -use ruff_python_semantic::definition::{Definition, Member, MemberKind}; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::{Definition, Member, MemberKind, SemanticModel}; pub(super) fn match_function_def( stmt: &Stmt, diff --git a/crates/ruff/src/rules/flake8_annotations/rules/definition.rs b/crates/ruff/src/rules/flake8_annotations/rules/definition.rs index 492be79613..53498e5058 100644 --- a/crates/ruff/src/rules/flake8_annotations/rules/definition.rs +++ b/crates/ruff/src/rules/flake8_annotations/rules/definition.rs @@ -6,9 +6,7 @@ use ruff_python_ast::helpers::ReturnStatementVisitor; use ruff_python_ast::statement_visitor::StatementVisitor; use ruff_python_ast::{cast, helpers}; use ruff_python_semantic::analyze::visibility; -use ruff_python_semantic::analyze::visibility::Visibility; -use ruff_python_semantic::definition::{Definition, Member, MemberKind}; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::{Definition, Member, MemberKind, SemanticModel}; use ruff_python_stdlib::typing::SIMPLE_MAGIC_RETURN_TYPES; use crate::checkers::ast::Checker; @@ -453,7 +451,7 @@ fn check_dynamically_typed( pub(crate) fn definition( checker: &Checker, definition: &Definition, - visibility: Visibility, + visibility: visibility::Visibility, ) -> Vec { // TODO(charlie): Consider using the AST directly here rather than `Definition`. // We could adhere more closely to `flake8-annotations` by defining public @@ -705,7 +703,7 @@ pub(crate) fn definition( } } else { match visibility { - Visibility::Public => { + visibility::Visibility::Public => { if checker.enabled(Rule::MissingReturnTypeUndocumentedPublicFunction) { diagnostics.push(Diagnostic::new( MissingReturnTypeUndocumentedPublicFunction { @@ -715,7 +713,7 @@ pub(crate) fn definition( )); } } - Visibility::Private => { + visibility::Visibility::Private => { if checker.enabled(Rule::MissingReturnTypePrivateFunction) { diagnostics.push(Diagnostic::new( MissingReturnTypePrivateFunction { diff --git a/crates/ruff/src/rules/flake8_bandit/helpers.rs b/crates/ruff/src/rules/flake8_bandit/helpers.rs index 37b0d6d745..dc6aa6dcdb 100644 --- a/crates/ruff/src/rules/flake8_bandit/helpers.rs +++ b/crates/ruff/src/rules/flake8_bandit/helpers.rs @@ -2,7 +2,7 @@ use once_cell::sync::Lazy; use regex::Regex; use rustpython_parser::ast::{self, Constant, Expr}; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; static PASSWORD_CANDIDATE_REGEX: Lazy = Lazy::new(|| { Regex::new(r"(^|_)(?i)(pas+wo?r?d|pass(phrase)?|pwd|token|secrete?)($|_)").unwrap() diff --git a/crates/ruff/src/rules/flake8_bandit/rules/shell_injection.rs b/crates/ruff/src/rules/flake8_bandit/rules/shell_injection.rs index 6eb6c9f5e2..c5d97d7e0b 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/shell_injection.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/shell_injection.rs @@ -5,7 +5,7 @@ use rustpython_parser::ast::{self, Constant, Expr, Keyword, Ranged}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::Truthiness; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::{ checkers::ast::Checker, registry::Rule, rules::flake8_bandit::helpers::string_literal, diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/abstract_base_class.rs b/crates/ruff/src/rules/flake8_bugbear/rules/abstract_base_class.rs index 59ea9cc665..f8bd621178 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/abstract_base_class.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/abstract_base_class.rs @@ -4,7 +4,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::identifier_range; use ruff_python_semantic::analyze::visibility::{is_abstract, is_overload}; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/cached_instance_method.rs b/crates/ruff/src/rules/flake8_bugbear/rules/cached_instance_method.rs index d16bfabf1f..ff5d889ace 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/cached_instance_method.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/cached_instance_method.rs @@ -2,7 +2,7 @@ use rustpython_parser::ast::{self, Decorator, Expr, Ranged}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/function_call_argument_default.rs b/crates/ruff/src/rules/flake8_bugbear/rules/function_call_argument_default.rs index a36b571c12..bf2cf7b7a5 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/function_call_argument_default.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/function_call_argument_default.rs @@ -8,7 +8,7 @@ use ruff_python_ast::call_path::{compose_call_path, from_qualified_name, CallPat use ruff_python_ast::visitor; use ruff_python_ast::visitor::Visitor; use ruff_python_semantic::analyze::typing::is_immutable_func; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::checkers::ast::Checker; use crate::rules::flake8_bugbear::rules::mutable_argument_default::is_mutable_func; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/mutable_argument_default.rs b/crates/ruff/src/rules/flake8_bugbear/rules/mutable_argument_default.rs index 19698f8120..b4fb273aa8 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/mutable_argument_default.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/mutable_argument_default.rs @@ -3,7 +3,7 @@ use rustpython_parser::ast::{self, Arguments, Expr, Ranged}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_semantic::analyze::typing::is_immutable_annotation; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/zip_without_explicit_strict.rs b/crates/ruff/src/rules/flake8_bugbear/rules/zip_without_explicit_strict.rs index 3bbc2efbac..be3570d8fd 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/zip_without_explicit_strict.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/zip_without_explicit_strict.rs @@ -3,7 +3,7 @@ use rustpython_parser::ast::{self, Expr, Keyword, Ranged}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_none; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_django/rules/helpers.rs b/crates/ruff/src/rules/flake8_django/rules/helpers.rs index 3dc1353045..b12419a808 100644 --- a/crates/ruff/src/rules/flake8_django/rules/helpers.rs +++ b/crates/ruff/src/rules/flake8_django/rules/helpers.rs @@ -1,6 +1,6 @@ use rustpython_parser::ast::Expr; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; /// Return `true` if a Python class appears to be a Django model, based on its base classes. pub(super) fn is_model(model: &SemanticModel, base: &Expr) -> bool { diff --git a/crates/ruff/src/rules/flake8_django/rules/locals_in_render_function.rs b/crates/ruff/src/rules/flake8_django/rules/locals_in_render_function.rs index 469ff81eb6..0779e7462b 100644 --- a/crates/ruff/src/rules/flake8_django/rules/locals_in_render_function.rs +++ b/crates/ruff/src/rules/flake8_django/rules/locals_in_render_function.rs @@ -2,7 +2,7 @@ use rustpython_parser::ast::{self, Expr, Keyword, Ranged}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_django/rules/model_without_dunder_str.rs b/crates/ruff/src/rules/flake8_django/rules/model_without_dunder_str.rs index 5e07cbfa53..586928fa00 100644 --- a/crates/ruff/src/rules/flake8_django/rules/model_without_dunder_str.rs +++ b/crates/ruff/src/rules/flake8_django/rules/model_without_dunder_str.rs @@ -2,7 +2,7 @@ use rustpython_parser::ast::{self, Constant, Expr, Ranged, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_django/rules/unordered_body_content_in_model.rs b/crates/ruff/src/rules/flake8_django/rules/unordered_body_content_in_model.rs index 857ebc96ee..b3b198624c 100644 --- a/crates/ruff/src/rules/flake8_django/rules/unordered_body_content_in_model.rs +++ b/crates/ruff/src/rules/flake8_django/rules/unordered_body_content_in_model.rs @@ -4,7 +4,7 @@ use rustpython_parser::ast::{self, Expr, Ranged, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_logging_format/rules/logging_call.rs b/crates/ruff/src/rules/flake8_logging_format/rules/logging_call.rs index dceee291b9..cd92ae23a7 100644 --- a/crates/ruff/src/rules/flake8_logging_format/rules/logging_call.rs +++ b/crates/ruff/src/rules/flake8_logging_format/rules/logging_call.rs @@ -4,7 +4,6 @@ use rustpython_parser::ast::{self, Constant, Expr, Keyword, Operator, Ranged}; use ruff_diagnostics::{Diagnostic, Edit, Fix}; use ruff_python_ast::helpers::{find_keyword, SimpleCallArgs}; use ruff_python_semantic::analyze::logging; -use ruff_python_semantic::analyze::logging::exc_info; use ruff_python_stdlib::logging::LoggingLevel; use crate::checkers::ast::Checker; @@ -197,7 +196,7 @@ pub(crate) fn logging_call( if !checker.semantic_model().in_exception_handler() { return; } - let Some(exc_info) = exc_info(keywords, checker.semantic_model()) else { + let Some(exc_info) = logging::exc_info(keywords, checker.semantic_model()) else { return; }; if let LoggingCallType::LevelCall(logging_level) = logging_call_type { diff --git a/crates/ruff/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs b/crates/ruff/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs index ce9b587379..b60b500afb 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs @@ -4,7 +4,7 @@ use rustpython_parser::ast::{Ranged, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::prelude::Expr; -use ruff_python_semantic::definition::{Definition, Member, MemberKind}; +use ruff_python_semantic::{Definition, Member, MemberKind}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/non_self_return_type.rs b/crates/ruff/src/rules/flake8_pyi/rules/non_self_return_type.rs index a5dd877d44..fdaeb56510 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/non_self_return_type.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/non_self_return_type.rs @@ -4,8 +4,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::{identifier_range, map_subscript}; use ruff_python_semantic::analyze::visibility::{is_abstract, is_final, is_overload}; -use ruff_python_semantic::model::SemanticModel; -use ruff_python_semantic::scope::ScopeKind; +use ruff_python_semantic::{ScopeKind, SemanticModel}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/simple_defaults.rs b/crates/ruff/src/rules/flake8_pyi/rules/simple_defaults.rs index 609602beab..eff56ed300 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/simple_defaults.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/simple_defaults.rs @@ -3,8 +3,7 @@ use rustpython_parser::ast::{self, Arguments, Constant, Expr, Operator, Ranged, use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::source_code::Locator; -use ruff_python_semantic::model::SemanticModel; -use ruff_python_semantic::scope::ScopeKind; +use ruff_python_semantic::{ScopeKind, SemanticModel}; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/fixture.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/fixture.rs index c0c53e8e3a..6542628bf8 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/fixture.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/fixture.rs @@ -14,7 +14,7 @@ use ruff_python_ast::source_code::Locator; use ruff_python_ast::visitor::Visitor; use ruff_python_ast::{helpers, visitor}; use ruff_python_semantic::analyze::visibility::is_abstract; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::autofix::edits::remove_argument; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/helpers.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/helpers.rs index f753163036..826dbfd530 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/helpers.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/helpers.rs @@ -2,7 +2,7 @@ use rustpython_parser::ast::{self, Constant, Decorator, Expr, Keyword}; use ruff_python_ast::call_path::{collect_call_path, CallPath}; use ruff_python_ast::helpers::map_callable; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use ruff_python_whitespace::PythonWhitespace; pub(super) fn get_mark_decorators( diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs index dc79b82839..e2c25bf154 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs @@ -4,7 +4,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::format_call_path; use ruff_python_ast::call_path::from_qualified_name; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/flake8_return/rules/function.rs b/crates/ruff/src/rules/flake8_return/rules/function.rs index 8f5e3aaf88..25b50a8162 100644 --- a/crates/ruff/src/rules/flake8_return/rules/function.rs +++ b/crates/ruff/src/rules/flake8_return/rules/function.rs @@ -10,7 +10,7 @@ use ruff_python_ast::helpers::elif_else_range; use ruff_python_ast::helpers::is_const_none; use ruff_python_ast::visitor::Visitor; use ruff_python_ast::whitespace::indentation; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::autofix::edits; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_self/rules/private_member_access.rs b/crates/ruff/src/rules/flake8_self/rules/private_member_access.rs index 40ebfdf1ab..fb8412aaf8 100644 --- a/crates/ruff/src/rules/flake8_self/rules/private_member_access.rs +++ b/crates/ruff/src/rules/flake8_self/rules/private_member_access.rs @@ -3,7 +3,7 @@ use rustpython_parser::ast::{self, Expr, Ranged}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::collect_call_path; -use ruff_python_semantic::scope::ScopeKind; +use ruff_python_semantic::ScopeKind; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_if.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_if.rs index 431838a350..096bb354d0 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_if.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_if.rs @@ -9,7 +9,7 @@ use ruff_python_ast::comparable::{ComparableConstant, ComparableExpr, Comparable use ruff_python_ast::helpers::{ any_over_expr, contains_effect, first_colon_range, has_comments, has_comments_in, }; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use ruff_python_whitespace::UniversalNewlines; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_unary_op.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_unary_op.rs index 35e4c620a7..9d04312b70 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_unary_op.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_unary_op.rs @@ -3,7 +3,7 @@ use rustpython_parser::ast::{self, Cmpop, Expr, ExprContext, Ranged, Stmt, Unary use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::scope::ScopeKind; +use ruff_python_semantic::ScopeKind; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs b/crates/ruff/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs index 8d10ddb424..ac19d8f374 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs @@ -2,7 +2,7 @@ use rustpython_parser::ast::{self, Expr, Ranged, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_type_checking/helpers.rs b/crates/ruff/src/rules/flake8_type_checking/helpers.rs index b8d399aa01..085f89d029 100644 --- a/crates/ruff/src/rules/flake8_type_checking/helpers.rs +++ b/crates/ruff/src/rules/flake8_type_checking/helpers.rs @@ -2,9 +2,7 @@ use rustpython_parser::ast; use ruff_python_ast::call_path::from_qualified_name; use ruff_python_ast::helpers::map_callable; -use ruff_python_semantic::binding::{Binding, BindingKind}; -use ruff_python_semantic::model::SemanticModel; -use ruff_python_semantic::scope::ScopeKind; +use ruff_python_semantic::{Binding, BindingKind, ScopeKind, SemanticModel}; pub(crate) fn is_valid_runtime_import(semantic_model: &SemanticModel, binding: &Binding) -> bool { if matches!( diff --git a/crates/ruff/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs b/crates/ruff/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs index 7706c1ae51..659e59ac2c 100644 --- a/crates/ruff/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs +++ b/crates/ruff/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs @@ -4,9 +4,7 @@ use rustc_hash::FxHashMap; use ruff_diagnostics::{AutofixKind, Diagnostic, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::node::NodeId; -use ruff_python_semantic::reference::ReferenceId; -use ruff_python_semantic::scope::Scope; +use ruff_python_semantic::{NodeId, ReferenceId, Scope}; use crate::autofix; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs b/crates/ruff/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs index 87acdf2b1f..97afe9c500 100644 --- a/crates/ruff/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs +++ b/crates/ruff/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs @@ -4,10 +4,7 @@ use rustc_hash::FxHashMap; use ruff_diagnostics::{AutofixKind, Diagnostic, DiagnosticKind, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::binding::Binding; -use ruff_python_semantic::node::NodeId; -use ruff_python_semantic::reference::ReferenceId; -use ruff_python_semantic::scope::Scope; +use ruff_python_semantic::{Binding, NodeId, ReferenceId, Scope}; use crate::autofix; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_unused_arguments/rules/unused_arguments.rs b/crates/ruff/src/rules/flake8_unused_arguments/rules/unused_arguments.rs index 5e571e2d59..eb1c845bd8 100644 --- a/crates/ruff/src/rules/flake8_unused_arguments/rules/unused_arguments.rs +++ b/crates/ruff/src/rules/flake8_unused_arguments/rules/unused_arguments.rs @@ -7,11 +7,8 @@ use rustpython_parser::ast::{Arg, Arguments}; use ruff_diagnostics::DiagnosticKind; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::analyze::function_type; -use ruff_python_semantic::analyze::function_type::FunctionType; -use ruff_python_semantic::analyze::visibility; -use ruff_python_semantic::model::SemanticModel; -use ruff_python_semantic::scope::{Scope, ScopeKind}; +use ruff_python_semantic::analyze::{function_type, visibility}; +use ruff_python_semantic::{Scope, ScopeKind, SemanticModel}; use crate::checkers::ast::Checker; use crate::registry::Rule; @@ -327,7 +324,7 @@ pub(crate) fn unused_arguments( &checker.settings.pep8_naming.classmethod_decorators, &checker.settings.pep8_naming.staticmethod_decorators, ) { - FunctionType::Function => { + function_type::FunctionType::Function => { if checker.enabled(Argumentable::Function.rule_code()) && !visibility::is_overload(checker.semantic_model(), decorator_list) { @@ -346,7 +343,7 @@ pub(crate) fn unused_arguments( vec![] } } - FunctionType::Method => { + function_type::FunctionType::Method => { if checker.enabled(Argumentable::Method.rule_code()) && !helpers::is_empty(body) && (!visibility::is_magic(name) @@ -372,7 +369,7 @@ pub(crate) fn unused_arguments( vec![] } } - FunctionType::ClassMethod => { + function_type::FunctionType::ClassMethod => { if checker.enabled(Argumentable::ClassMethod.rule_code()) && !helpers::is_empty(body) && (!visibility::is_magic(name) @@ -398,7 +395,7 @@ pub(crate) fn unused_arguments( vec![] } } - FunctionType::StaticMethod => { + function_type::FunctionType::StaticMethod => { if checker.enabled(Argumentable::StaticMethod.rule_code()) && !helpers::is_empty(body) && (!visibility::is_magic(name) diff --git a/crates/ruff/src/rules/pandas_vet/helpers.rs b/crates/ruff/src/rules/pandas_vet/helpers.rs index d011be8daf..45240028d9 100644 --- a/crates/ruff/src/rules/pandas_vet/helpers.rs +++ b/crates/ruff/src/rules/pandas_vet/helpers.rs @@ -1,8 +1,7 @@ use rustpython_parser::ast; use rustpython_parser::ast::Expr; -use ruff_python_semantic::binding::{BindingKind, Importation}; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::{BindingKind, Importation, SemanticModel}; pub(super) enum Resolution { /// The expression resolves to an irrelevant expression type (e.g., a constant). diff --git a/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs b/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs index ebb56710ce..7b87ccc3b9 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs @@ -2,7 +2,7 @@ use rustpython_parser::ast::{self, Constant, Expr, Keyword, Ranged}; use ruff_diagnostics::{AutofixKind, Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::binding::{BindingKind, Importation}; +use ruff_python_semantic::{BindingKind, Importation}; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pep8_naming/helpers.rs b/crates/ruff/src/rules/pep8_naming/helpers.rs index 72efccade2..05de2560a3 100644 --- a/crates/ruff/src/rules/pep8_naming/helpers.rs +++ b/crates/ruff/src/rules/pep8_naming/helpers.rs @@ -1,7 +1,7 @@ use itertools::Itertools; use rustpython_parser::ast::{self, Expr, Stmt}; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use ruff_python_stdlib::str::{is_lower, is_upper}; pub(super) fn is_camelcase(name: &str) -> bool { diff --git a/crates/ruff/src/rules/pep8_naming/rules/dunder_function_name.rs b/crates/ruff/src/rules/pep8_naming/rules/dunder_function_name.rs index 2f94ee0d7b..6067a04839 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/dunder_function_name.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/dunder_function_name.rs @@ -4,7 +4,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::identifier_range; use ruff_python_ast::source_code::Locator; -use ruff_python_semantic::scope::{Scope, ScopeKind}; +use ruff_python_semantic::{Scope, ScopeKind}; use crate::settings::types::IdentifierPattern; diff --git a/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs b/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs index e181cfd37c..66e9a597cb 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs @@ -3,7 +3,7 @@ use rustpython_parser::ast::{Arguments, Decorator, Ranged}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_semantic::analyze::function_type; -use ruff_python_semantic::scope::Scope; +use ruff_python_semantic::Scope; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs b/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs index b9c198d1ca..bb1fb0a520 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs @@ -3,7 +3,7 @@ use rustpython_parser::ast::{Arguments, Decorator, Ranged}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_semantic::analyze::function_type; -use ruff_python_semantic::scope::Scope; +use ruff_python_semantic::Scope; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pep8_naming/rules/invalid_function_name.rs b/crates/ruff/src/rules/pep8_naming/rules/invalid_function_name.rs index 4e2b9c8867..1f8a41887d 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/invalid_function_name.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/invalid_function_name.rs @@ -5,7 +5,7 @@ use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::identifier_range; use ruff_python_ast::source_code::Locator; use ruff_python_semantic::analyze::visibility; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::settings::types::IdentifierPattern; diff --git a/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs b/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs index bca493a8d8..3982031e3e 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs @@ -5,7 +5,7 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::{has_leading_content, has_trailing_content}; use ruff_python_ast::source_code::Generator; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use ruff_python_whitespace::{leading_indentation, UniversalNewlines}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pydocstyle/helpers.rs b/crates/ruff/src/rules/pydocstyle/helpers.rs index 774fd1ff57..00d0eb8b93 100644 --- a/crates/ruff/src/rules/pydocstyle/helpers.rs +++ b/crates/ruff/src/rules/pydocstyle/helpers.rs @@ -4,8 +4,7 @@ use ruff_python_ast::call_path::from_qualified_name; use ruff_python_ast::cast; use ruff_python_ast::helpers::map_callable; use ruff_python_ast::str::is_implicit_concatenation; -use ruff_python_semantic::definition::{Definition, Member, MemberKind}; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::{Definition, Member, MemberKind, SemanticModel}; use ruff_python_whitespace::UniversalNewlines; /// Return the index of the first logical line in a string. diff --git a/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs b/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs index 17d106d550..5b1a46a174 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs @@ -3,7 +3,7 @@ use rustpython_parser::ast::Ranged; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::definition::{Definition, Member, MemberKind}; +use ruff_python_semantic::{Definition, Member, MemberKind}; use ruff_python_whitespace::{PythonWhitespace, UniversalNewlineIterator, UniversalNewlines}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_function.rs b/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_function.rs index d8c52c5b66..47aa4e32e1 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_function.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_function.rs @@ -5,7 +5,7 @@ use rustpython_parser::ast::Ranged; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::definition::{Definition, Member, MemberKind}; +use ruff_python_semantic::{Definition, Member, MemberKind}; use ruff_python_whitespace::{PythonWhitespace, UniversalNewlineIterator, UniversalNewlines}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pydocstyle/rules/capitalized.rs b/crates/ruff/src/rules/pydocstyle/rules/capitalized.rs index 7a77ddcd7f..739cf7a44b 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/capitalized.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/capitalized.rs @@ -3,7 +3,7 @@ use rustpython_parser::ast::Ranged; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::definition::{Definition, Member, MemberKind}; +use ruff_python_semantic::{Definition, Member, MemberKind}; use crate::checkers::ast::Checker; use crate::docstrings::Docstring; diff --git a/crates/ruff/src/rules/pydocstyle/rules/if_needed.rs b/crates/ruff/src/rules/pydocstyle/rules/if_needed.rs index 1ef2016d5a..c612aad519 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/if_needed.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/if_needed.rs @@ -3,7 +3,7 @@ use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::cast; use ruff_python_ast::helpers::identifier_range; use ruff_python_semantic::analyze::visibility::is_overload; -use ruff_python_semantic::definition::{Definition, Member, MemberKind}; +use ruff_python_semantic::{Definition, Member, MemberKind}; use crate::checkers::ast::Checker; use crate::docstrings::Docstring; diff --git a/crates/ruff/src/rules/pydocstyle/rules/multi_line_summary_start.rs b/crates/ruff/src/rules/pydocstyle/rules/multi_line_summary_start.rs index 8453973125..2288843805 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/multi_line_summary_start.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/multi_line_summary_start.rs @@ -4,7 +4,7 @@ use rustpython_parser::ast::Ranged; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::str::{is_triple_quote, leading_quote}; -use ruff_python_semantic::definition::{Definition, Member}; +use ruff_python_semantic::{Definition, Member}; use ruff_python_whitespace::{NewlineWithTrailingNewline, UniversalNewlineIterator}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pydocstyle/rules/no_signature.rs b/crates/ruff/src/rules/pydocstyle/rules/no_signature.rs index bbca269d99..1ae23355ba 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/no_signature.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/no_signature.rs @@ -2,7 +2,7 @@ use rustpython_parser::ast::{self, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::definition::{Definition, Member, MemberKind}; +use ruff_python_semantic::{Definition, Member, MemberKind}; use ruff_python_whitespace::UniversalNewlines; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pydocstyle/rules/non_imperative_mood.rs b/crates/ruff/src/rules/pydocstyle/rules/non_imperative_mood.rs index 5459f09512..91b67899bb 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/non_imperative_mood.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/non_imperative_mood.rs @@ -8,7 +8,7 @@ use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::{from_qualified_name, CallPath}; use ruff_python_ast::cast; use ruff_python_semantic::analyze::visibility::{is_property, is_test}; -use ruff_python_semantic::definition::{Definition, Member, MemberKind}; +use ruff_python_semantic::{Definition, Member, MemberKind}; use ruff_python_whitespace::UniversalNewlines; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pydocstyle/rules/not_missing.rs b/crates/ruff/src/rules/pydocstyle/rules/not_missing.rs index a4ecde3e00..a1cbdb4412 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/not_missing.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/not_missing.rs @@ -7,7 +7,7 @@ use ruff_python_ast::helpers::identifier_range; use ruff_python_semantic::analyze::visibility::{ is_call, is_init, is_magic, is_new, is_overload, is_override, Visibility, }; -use ruff_python_semantic::definition::{Definition, Member, MemberKind, Module, ModuleKind}; +use ruff_python_semantic::{Definition, Member, MemberKind, Module, ModuleKind}; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/pydocstyle/rules/sections.rs b/crates/ruff/src/rules/pydocstyle/rules/sections.rs index f101a18246..66f77fcade 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/sections.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/sections.rs @@ -12,7 +12,7 @@ use ruff_python_ast::cast; use ruff_python_ast::docstrings::{clean_space, leading_space}; use ruff_python_ast::helpers::identifier_range; use ruff_python_semantic::analyze::visibility::is_staticmethod; -use ruff_python_semantic::definition::{Definition, Member, MemberKind}; +use ruff_python_semantic::{Definition, Member, MemberKind}; use ruff_python_whitespace::NewlineWithTrailingNewline; use ruff_textwrap::dedent; diff --git a/crates/ruff/src/rules/pyflakes/rules/return_outside_function.rs b/crates/ruff/src/rules/pyflakes/rules/return_outside_function.rs index c41d3a0aaa..b30512b0b9 100644 --- a/crates/ruff/src/rules/pyflakes/rules/return_outside_function.rs +++ b/crates/ruff/src/rules/pyflakes/rules/return_outside_function.rs @@ -2,7 +2,7 @@ use rustpython_parser::ast::{Ranged, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::scope::ScopeKind; +use ruff_python_semantic::ScopeKind; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyflakes/rules/undefined_export.rs b/crates/ruff/src/rules/pyflakes/rules/undefined_export.rs index e4edea697d..46e9cc5a87 100644 --- a/crates/ruff/src/rules/pyflakes/rules/undefined_export.rs +++ b/crates/ruff/src/rules/pyflakes/rules/undefined_export.rs @@ -2,7 +2,7 @@ use ruff_text_size::TextRange; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::scope::Scope; +use ruff_python_semantic::Scope; /// ## What it does /// Checks for undefined names in `__all__`. diff --git a/crates/ruff/src/rules/pyflakes/rules/unused_annotation.rs b/crates/ruff/src/rules/pyflakes/rules/unused_annotation.rs index 1691dbe01e..55c524edca 100644 --- a/crates/ruff/src/rules/pyflakes/rules/unused_annotation.rs +++ b/crates/ruff/src/rules/pyflakes/rules/unused_annotation.rs @@ -1,6 +1,6 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::scope::ScopeId; +use ruff_python_semantic::ScopeId; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyflakes/rules/unused_import.rs b/crates/ruff/src/rules/pyflakes/rules/unused_import.rs index 09d4b98ad0..5471c84c63 100644 --- a/crates/ruff/src/rules/pyflakes/rules/unused_import.rs +++ b/crates/ruff/src/rules/pyflakes/rules/unused_import.rs @@ -4,9 +4,7 @@ use rustc_hash::FxHashMap; use ruff_diagnostics::{AutofixKind, Diagnostic, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::binding::Exceptions; -use ruff_python_semantic::node::NodeId; -use ruff_python_semantic::scope::Scope; +use ruff_python_semantic::{Exceptions, NodeId, Scope}; use crate::autofix; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyflakes/rules/unused_variable.rs b/crates/ruff/src/rules/pyflakes/rules/unused_variable.rs index 6ffa78fae6..193a37255b 100644 --- a/crates/ruff/src/rules/pyflakes/rules/unused_variable.rs +++ b/crates/ruff/src/rules/pyflakes/rules/unused_variable.rs @@ -7,7 +7,7 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::contains_effect; use ruff_python_ast::source_code::Locator; -use ruff_python_semantic::scope::ScopeId; +use ruff_python_semantic::ScopeId; use crate::autofix::edits::delete_stmt; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyflakes/rules/yield_outside_function.rs b/crates/ruff/src/rules/pyflakes/rules/yield_outside_function.rs index baa6cc3b93..d86faeb118 100644 --- a/crates/ruff/src/rules/pyflakes/rules/yield_outside_function.rs +++ b/crates/ruff/src/rules/pyflakes/rules/yield_outside_function.rs @@ -4,7 +4,7 @@ use rustpython_parser::ast::{Expr, Ranged}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::scope::ScopeKind; +use ruff_python_semantic::ScopeKind; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/helpers.rs b/crates/ruff/src/rules/pylint/helpers.rs index 306737b28c..4e5dba75da 100644 --- a/crates/ruff/src/rules/pylint/helpers.rs +++ b/crates/ruff/src/rules/pylint/helpers.rs @@ -1,10 +1,10 @@ -use ruff_python_semantic::analyze::function_type; -use ruff_python_semantic::analyze::function_type::FunctionType; -use ruff_python_semantic::model::SemanticModel; -use ruff_python_semantic::scope::ScopeKind; +use std::fmt; + use rustpython_parser::ast; use rustpython_parser::ast::Cmpop; -use std::fmt; + +use ruff_python_semantic::analyze::function_type; +use ruff_python_semantic::{ScopeKind, SemanticModel}; use crate::settings::Settings; @@ -40,7 +40,7 @@ pub(super) fn in_dunder_init(model: &SemanticModel, settings: &Settings) -> bool &settings.pep8_naming.classmethod_decorators, &settings.pep8_naming.staticmethod_decorators, ), - FunctionType::Method + function_type::FunctionType::Method ) { return false; } diff --git a/crates/ruff/src/rules/pylint/rules/nested_min_max.rs b/crates/ruff/src/rules/pylint/rules/nested_min_max.rs index 3c5aee7852..4eab1a008d 100644 --- a/crates/ruff/src/rules/pylint/rules/nested_min_max.rs +++ b/crates/ruff/src/rules/pylint/rules/nested_min_max.rs @@ -4,7 +4,7 @@ use rustpython_parser::ast::{self, Expr, Keyword, Ranged}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::has_comments; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::{checkers::ast::Checker, registry::AsRule}; diff --git a/crates/ruff/src/rules/pylint/rules/redefined_loop_name.rs b/crates/ruff/src/rules/pylint/rules/redefined_loop_name.rs index 8964206d1c..dce30a8956 100644 --- a/crates/ruff/src/rules/pylint/rules/redefined_loop_name.rs +++ b/crates/ruff/src/rules/pylint/rules/redefined_loop_name.rs @@ -8,7 +8,7 @@ use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::comparable::ComparableExpr; use ruff_python_ast::statement_visitor::{walk_stmt, StatementVisitor}; use ruff_python_ast::types::Node; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs b/crates/ruff/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs index f9f86618f8..b2fac6b580 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs @@ -7,7 +7,7 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_dunder; use ruff_python_ast::source_code::Generator; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use ruff_python_stdlib::identifiers::is_identifier; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs b/crates/ruff/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs index 50ae7304f4..adaf6b033b 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs @@ -7,7 +7,7 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_dunder; use ruff_python_ast::source_code::Generator; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use ruff_python_stdlib::identifiers::is_identifier; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyupgrade/rules/os_error_alias.rs b/crates/ruff/src/rules/pyupgrade/rules/os_error_alias.rs index 82a3da68ba..890dd665ed 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/os_error_alias.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/os_error_alias.rs @@ -4,7 +4,7 @@ use rustpython_parser::ast::{self, Excepthandler, Expr, ExprContext, Ranged}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::compose_call_path; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/ruff/rules/helpers.rs b/crates/ruff/src/rules/ruff/rules/helpers.rs index fca12bfd2a..751bf32326 100644 --- a/crates/ruff/src/rules/ruff/rules/helpers.rs +++ b/crates/ruff/src/rules/ruff/rules/helpers.rs @@ -1,7 +1,7 @@ use ruff_python_ast::helpers::map_callable; use rustpython_parser::ast::{self, Expr}; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; pub(super) fn is_mutable_expr(expr: &Expr) -> bool { matches!( diff --git a/crates/ruff/src/rules/ruff/rules/implicit_optional.rs b/crates/ruff/src/rules/ruff/rules/implicit_optional.rs index 166a032ba3..0b00b3adbf 100644 --- a/crates/ruff/src/rules/ruff/rules/implicit_optional.rs +++ b/crates/ruff/src/rules/ruff/rules/implicit_optional.rs @@ -5,7 +5,7 @@ use rustpython_parser::ast::{self, Arguments, Constant, Expr, Operator, Ranged}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; use ruff_text_size::TextRange; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/tryceratops/helpers.rs b/crates/ruff/src/rules/tryceratops/helpers.rs index e7067a9eee..2581f86e0c 100644 --- a/crates/ruff/src/rules/tryceratops/helpers.rs +++ b/crates/ruff/src/rules/tryceratops/helpers.rs @@ -3,7 +3,7 @@ use rustpython_parser::ast::{self, Expr}; use ruff_python_ast::visitor; use ruff_python_ast::visitor::Visitor; use ruff_python_semantic::analyze::logging; -use ruff_python_semantic::model::SemanticModel; +use ruff_python_semantic::SemanticModel; /// Collect `logging`-like calls from an AST. pub(super) struct LoggerCandidateVisitor<'a, 'b> { diff --git a/crates/ruff_python_semantic/src/lib.rs b/crates/ruff_python_semantic/src/lib.rs index e876f26181..e47b73ca16 100644 --- a/crates/ruff_python_semantic/src/lib.rs +++ b/crates/ruff_python_semantic/src/lib.rs @@ -1,9 +1,18 @@ pub mod analyze; -pub mod binding; -pub mod context; -pub mod definition; -pub mod globals; -pub mod model; -pub mod node; -pub mod reference; -pub mod scope; +mod binding; +mod context; +mod definition; +mod globals; +mod model; +mod node; +mod reference; +mod scope; + +pub use binding::*; +pub use context::*; +pub use definition::*; +pub use globals::*; +pub use model::*; +pub use node::*; +pub use reference::*; +pub use scope::*;