mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 04:19:18 +00:00
Re-export ruff_python_semantic
members (#5094)
## Summary This PR adds a more unified public API to `ruff_python_semantic`, so that we don't need to do deeply nested imports all over the place.
This commit is contained in:
parent
a33bbe6335
commit
86ff1febea
69 changed files with 129 additions and 146 deletions
|
@ -1,7 +1,7 @@
|
||||||
use ruff_text_size::TextRange;
|
use ruff_text_size::TextRange;
|
||||||
use rustpython_parser::ast::Expr;
|
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.
|
/// 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
|
/// Used to, e.g., store functions, whose bodies shouldn't be analyzed until all
|
||||||
|
|
|
@ -18,19 +18,13 @@ use ruff_python_ast::types::Node;
|
||||||
use ruff_python_ast::typing::{parse_type_annotation, AnnotationKind};
|
use ruff_python_ast::typing::{parse_type_annotation, AnnotationKind};
|
||||||
use ruff_python_ast::visitor::{walk_excepthandler, walk_pattern, Visitor};
|
use ruff_python_ast::visitor::{walk_excepthandler, walk_pattern, Visitor};
|
||||||
use ruff_python_ast::{cast, helpers, str, visitor};
|
use ruff_python_ast::{cast, helpers, str, visitor};
|
||||||
use ruff_python_semantic::analyze;
|
use ruff_python_semantic::analyze::{branch_detection, typing, visibility};
|
||||||
use ruff_python_semantic::analyze::branch_detection;
|
use ruff_python_semantic::{
|
||||||
use ruff_python_semantic::analyze::typing::{Callable, SubscriptKind};
|
Binding, BindingFlags, BindingId, BindingKind, ContextualizedDefinition, Exceptions,
|
||||||
use ruff_python_semantic::analyze::visibility::ModuleSource;
|
ExecutionContext, Export, FromImportation, Globals, Importation, Module, ModuleKind,
|
||||||
use ruff_python_semantic::binding::{
|
ResolvedRead, Scope, ScopeId, ScopeKind, SemanticModel, SemanticModelFlags, StarImportation,
|
||||||
Binding, BindingFlags, BindingId, BindingKind, Exceptions, Export, FromImportation,
|
SubmoduleImportation,
|
||||||
Importation, 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::builtins::{BUILTINS, MAGIC_GLOBALS};
|
||||||
use ruff_python_stdlib::path::is_python_stub_file;
|
use ruff_python_stdlib::path::is_python_stub_file;
|
||||||
|
|
||||||
|
@ -2079,7 +2073,7 @@ where
|
||||||
) => {
|
) => {
|
||||||
self.visit_boolean_test(test);
|
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() {
|
if self.semantic_model.at_top_level() {
|
||||||
self.importer.visit_type_checking_block(stmt);
|
self.importer.visit_type_checking_block(stmt);
|
||||||
}
|
}
|
||||||
|
@ -2179,7 +2173,7 @@ where
|
||||||
Rule::NonPEP604Annotation,
|
Rule::NonPEP604Annotation,
|
||||||
]) {
|
]) {
|
||||||
if let Some(operator) =
|
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.enabled(Rule::FutureRewritableTypeAnnotation) {
|
||||||
if self.settings.target_version < PythonVersion::Py310
|
if self.settings.target_version < PythonVersion::Py310
|
||||||
|
@ -2211,7 +2205,7 @@ where
|
||||||
if self.settings.target_version < PythonVersion::Py39
|
if self.settings.target_version < PythonVersion::Py39
|
||||||
&& !self.semantic_model.future_annotations()
|
&& !self.semantic_model.future_annotations()
|
||||||
&& self.semantic_model.in_annotation()
|
&& 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(
|
flake8_future_annotations::rules::future_required_type_annotation(
|
||||||
self,
|
self,
|
||||||
|
@ -2284,7 +2278,7 @@ where
|
||||||
Rule::NonPEP585Annotation,
|
Rule::NonPEP585Annotation,
|
||||||
]) {
|
]) {
|
||||||
if let Some(replacement) =
|
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.enabled(Rule::FutureRewritableTypeAnnotation) {
|
||||||
if self.settings.target_version < PythonVersion::Py39
|
if self.settings.target_version < PythonVersion::Py39
|
||||||
|
@ -2360,8 +2354,7 @@ where
|
||||||
Rule::FutureRewritableTypeAnnotation,
|
Rule::FutureRewritableTypeAnnotation,
|
||||||
Rule::NonPEP585Annotation,
|
Rule::NonPEP585Annotation,
|
||||||
]) {
|
]) {
|
||||||
if let Some(replacement) =
|
if let Some(replacement) = typing::to_pep585_generic(expr, &self.semantic_model)
|
||||||
analyze::typing::to_pep585_generic(expr, &self.semantic_model)
|
|
||||||
{
|
{
|
||||||
if self.enabled(Rule::FutureRewritableTypeAnnotation) {
|
if self.enabled(Rule::FutureRewritableTypeAnnotation) {
|
||||||
if self.settings.target_version < PythonVersion::Py39
|
if self.settings.target_version < PythonVersion::Py39
|
||||||
|
@ -3576,27 +3569,27 @@ where
|
||||||
.semantic_model
|
.semantic_model
|
||||||
.match_typing_call_path(&call_path, "cast")
|
.match_typing_call_path(&call_path, "cast")
|
||||||
{
|
{
|
||||||
Some(Callable::Cast)
|
Some(typing::Callable::Cast)
|
||||||
} else if self
|
} else if self
|
||||||
.semantic_model
|
.semantic_model
|
||||||
.match_typing_call_path(&call_path, "NewType")
|
.match_typing_call_path(&call_path, "NewType")
|
||||||
{
|
{
|
||||||
Some(Callable::NewType)
|
Some(typing::Callable::NewType)
|
||||||
} else if self
|
} else if self
|
||||||
.semantic_model
|
.semantic_model
|
||||||
.match_typing_call_path(&call_path, "TypeVar")
|
.match_typing_call_path(&call_path, "TypeVar")
|
||||||
{
|
{
|
||||||
Some(Callable::TypeVar)
|
Some(typing::Callable::TypeVar)
|
||||||
} else if self
|
} else if self
|
||||||
.semantic_model
|
.semantic_model
|
||||||
.match_typing_call_path(&call_path, "NamedTuple")
|
.match_typing_call_path(&call_path, "NamedTuple")
|
||||||
{
|
{
|
||||||
Some(Callable::NamedTuple)
|
Some(typing::Callable::NamedTuple)
|
||||||
} else if self
|
} else if self
|
||||||
.semantic_model
|
.semantic_model
|
||||||
.match_typing_call_path(&call_path, "TypedDict")
|
.match_typing_call_path(&call_path, "TypedDict")
|
||||||
{
|
{
|
||||||
Some(Callable::TypedDict)
|
Some(typing::Callable::TypedDict)
|
||||||
} else if [
|
} else if [
|
||||||
"Arg",
|
"Arg",
|
||||||
"DefaultArg",
|
"DefaultArg",
|
||||||
|
@ -3608,15 +3601,15 @@ where
|
||||||
.iter()
|
.iter()
|
||||||
.any(|target| call_path.as_slice() == ["mypy_extensions", target])
|
.any(|target| call_path.as_slice() == ["mypy_extensions", target])
|
||||||
{
|
{
|
||||||
Some(Callable::MypyExtension)
|
Some(typing::Callable::MypyExtension)
|
||||||
} else if call_path.as_slice() == ["", "bool"] {
|
} else if call_path.as_slice() == ["", "bool"] {
|
||||||
Some(Callable::Bool)
|
Some(typing::Callable::Bool)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
match callable {
|
match callable {
|
||||||
Some(Callable::Bool) => {
|
Some(typing::Callable::Bool) => {
|
||||||
self.visit_expr(func);
|
self.visit_expr(func);
|
||||||
let mut args = args.iter();
|
let mut args = args.iter();
|
||||||
if let Some(arg) = args.next() {
|
if let Some(arg) = args.next() {
|
||||||
|
@ -3626,7 +3619,7 @@ where
|
||||||
self.visit_expr(arg);
|
self.visit_expr(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Callable::Cast) => {
|
Some(typing::Callable::Cast) => {
|
||||||
self.visit_expr(func);
|
self.visit_expr(func);
|
||||||
let mut args = args.iter();
|
let mut args = args.iter();
|
||||||
if let Some(arg) = args.next() {
|
if let Some(arg) = args.next() {
|
||||||
|
@ -3636,7 +3629,7 @@ where
|
||||||
self.visit_expr(arg);
|
self.visit_expr(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Callable::NewType) => {
|
Some(typing::Callable::NewType) => {
|
||||||
self.visit_expr(func);
|
self.visit_expr(func);
|
||||||
let mut args = args.iter();
|
let mut args = args.iter();
|
||||||
if let Some(arg) = args.next() {
|
if let Some(arg) = args.next() {
|
||||||
|
@ -3646,7 +3639,7 @@ where
|
||||||
self.visit_type_definition(arg);
|
self.visit_type_definition(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Callable::TypeVar) => {
|
Some(typing::Callable::TypeVar) => {
|
||||||
self.visit_expr(func);
|
self.visit_expr(func);
|
||||||
let mut args = args.iter();
|
let mut args = args.iter();
|
||||||
if let Some(arg) = args.next() {
|
if let Some(arg) = args.next() {
|
||||||
|
@ -3670,7 +3663,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Callable::NamedTuple) => {
|
Some(typing::Callable::NamedTuple) => {
|
||||||
self.visit_expr(func);
|
self.visit_expr(func);
|
||||||
|
|
||||||
// Ex) NamedTuple("a", [("a", int)])
|
// Ex) NamedTuple("a", [("a", int)])
|
||||||
|
@ -3707,7 +3700,7 @@ where
|
||||||
self.visit_type_definition(value);
|
self.visit_type_definition(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Callable::TypedDict) => {
|
Some(typing::Callable::TypedDict) => {
|
||||||
self.visit_expr(func);
|
self.visit_expr(func);
|
||||||
|
|
||||||
// Ex) TypedDict("a", {"a": int})
|
// Ex) TypedDict("a", {"a": int})
|
||||||
|
@ -3739,7 +3732,7 @@ where
|
||||||
self.visit_type_definition(value);
|
self.visit_type_definition(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Callable::MypyExtension) => {
|
Some(typing::Callable::MypyExtension) => {
|
||||||
self.visit_expr(func);
|
self.visit_expr(func);
|
||||||
|
|
||||||
let mut args = args.iter();
|
let mut args = args.iter();
|
||||||
|
@ -3801,7 +3794,7 @@ where
|
||||||
self.semantic_model.flags |= SemanticModelFlags::SUBSCRIPT;
|
self.semantic_model.flags |= SemanticModelFlags::SUBSCRIPT;
|
||||||
visitor::walk_expr(self, expr);
|
visitor::walk_expr(self, expr);
|
||||||
} else {
|
} else {
|
||||||
match analyze::typing::match_annotated_subscript(
|
match typing::match_annotated_subscript(
|
||||||
value,
|
value,
|
||||||
&self.semantic_model,
|
&self.semantic_model,
|
||||||
self.settings.typing_modules.iter().map(String::as_str),
|
self.settings.typing_modules.iter().map(String::as_str),
|
||||||
|
@ -3810,13 +3803,13 @@ where
|
||||||
Some(subscript) => {
|
Some(subscript) => {
|
||||||
match subscript {
|
match subscript {
|
||||||
// Ex) Optional[int]
|
// Ex) Optional[int]
|
||||||
SubscriptKind::AnnotatedSubscript => {
|
typing::SubscriptKind::AnnotatedSubscript => {
|
||||||
self.visit_expr(value);
|
self.visit_expr(value);
|
||||||
self.visit_type_definition(slice);
|
self.visit_type_definition(slice);
|
||||||
self.visit_expr_context(ctx);
|
self.visit_expr_context(ctx);
|
||||||
}
|
}
|
||||||
// Ex) Annotated[int, "Hello, world!"]
|
// Ex) Annotated[int, "Hello, world!"]
|
||||||
SubscriptKind::PEP593AnnotatedSubscript => {
|
typing::SubscriptKind::PEP593AnnotatedSubscript => {
|
||||||
// First argument is a type (including forward references); the
|
// First argument is a type (including forward references); the
|
||||||
// rest are arbitrary Python objects.
|
// rest are arbitrary Python objects.
|
||||||
self.visit_expr(value);
|
self.visit_expr(value);
|
||||||
|
@ -4291,7 +4284,7 @@ impl<'a> Checker<'a> {
|
||||||
&& binding.redefines(shadowed)
|
&& binding.redefines(shadowed)
|
||||||
&& (!self.settings.dummy_variable_rgx.is_match(name) || shadows_import)
|
&& (!self.settings.dummy_variable_rgx.is_match(name) || shadows_import)
|
||||||
&& !(shadowed.kind.is_function_definition()
|
&& !(shadowed.kind.is_function_definition()
|
||||||
&& analyze::visibility::is_overload(
|
&& visibility::is_overload(
|
||||||
&self.semantic_model,
|
&self.semantic_model,
|
||||||
cast::decorator_list(
|
cast::decorator_list(
|
||||||
self.semantic_model.stmts[shadowed.source.unwrap()],
|
self.semantic_model.stmts[shadowed.source.unwrap()],
|
||||||
|
@ -5298,9 +5291,9 @@ pub(crate) fn check_ast(
|
||||||
ModuleKind::Module
|
ModuleKind::Module
|
||||||
},
|
},
|
||||||
source: if let Some(module_path) = module_path.as_ref() {
|
source: if let Some(module_path) = module_path.as_ref() {
|
||||||
ModuleSource::Path(module_path)
|
visibility::ModuleSource::Path(module_path)
|
||||||
} else {
|
} else {
|
||||||
ModuleSource::File(path)
|
visibility::ModuleSource::File(path)
|
||||||
},
|
},
|
||||||
python_ast,
|
python_ast,
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use rustpython_parser::ast::{self, Constant, Expr, Stmt};
|
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.
|
/// Extract a docstring from a function or class body.
|
||||||
pub(crate) fn docstring_from(suite: &[Stmt]) -> Option<&Expr> {
|
pub(crate) fn docstring_from(suite: &[Stmt]) -> Option<&Expr> {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::ops::Deref;
|
||||||
use ruff_text_size::{TextRange, TextSize};
|
use ruff_text_size::{TextRange, TextSize};
|
||||||
use rustpython_parser::ast::{Expr, Ranged};
|
use rustpython_parser::ast::{Expr, Ranged};
|
||||||
|
|
||||||
use ruff_python_semantic::definition::Definition;
|
use ruff_python_semantic::Definition;
|
||||||
|
|
||||||
pub(crate) mod extraction;
|
pub(crate) mod extraction;
|
||||||
pub(crate) mod google;
|
pub(crate) mod google;
|
||||||
|
|
|
@ -10,7 +10,7 @@ use rustpython_parser::ast::{self, Ranged, Stmt, Suite};
|
||||||
use ruff_diagnostics::Edit;
|
use ruff_diagnostics::Edit;
|
||||||
use ruff_python_ast::imports::{AnyImport, Import, ImportFrom};
|
use ruff_python_ast::imports::{AnyImport, Import, ImportFrom};
|
||||||
use ruff_python_ast::source_code::{Locator, Stylist};
|
use ruff_python_ast::source_code::{Locator, Stylist};
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
use ruff_textwrap::indent;
|
use ruff_textwrap::indent;
|
||||||
|
|
||||||
use crate::autofix;
|
use crate::autofix;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
|
||||||
use rustpython_parser::ast::Expr;
|
use rustpython_parser::ast::Expr;
|
||||||
|
|
||||||
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
|
||||||
pub(super) fn is_sys(model: &SemanticModel, expr: &Expr, target: &str) -> bool {
|
pub(super) fn is_sys(model: &SemanticModel, expr: &Expr, target: &str) -> bool {
|
||||||
model
|
model
|
||||||
.resolve_call_path(expr)
|
.resolve_call_path(expr)
|
||||||
|
|
|
@ -2,8 +2,7 @@ use rustpython_parser::ast::{self, Arguments, Expr, Stmt};
|
||||||
|
|
||||||
use ruff_python_ast::cast;
|
use ruff_python_ast::cast;
|
||||||
use ruff_python_semantic::analyze::visibility;
|
use ruff_python_semantic::analyze::visibility;
|
||||||
use ruff_python_semantic::definition::{Definition, Member, MemberKind};
|
use ruff_python_semantic::{Definition, Member, MemberKind, SemanticModel};
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
|
||||||
|
|
||||||
pub(super) fn match_function_def(
|
pub(super) fn match_function_def(
|
||||||
stmt: &Stmt,
|
stmt: &Stmt,
|
||||||
|
|
|
@ -6,9 +6,7 @@ use ruff_python_ast::helpers::ReturnStatementVisitor;
|
||||||
use ruff_python_ast::statement_visitor::StatementVisitor;
|
use ruff_python_ast::statement_visitor::StatementVisitor;
|
||||||
use ruff_python_ast::{cast, helpers};
|
use ruff_python_ast::{cast, helpers};
|
||||||
use ruff_python_semantic::analyze::visibility;
|
use ruff_python_semantic::analyze::visibility;
|
||||||
use ruff_python_semantic::analyze::visibility::Visibility;
|
use ruff_python_semantic::{Definition, Member, MemberKind, SemanticModel};
|
||||||
use ruff_python_semantic::definition::{Definition, Member, MemberKind};
|
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
|
||||||
use ruff_python_stdlib::typing::SIMPLE_MAGIC_RETURN_TYPES;
|
use ruff_python_stdlib::typing::SIMPLE_MAGIC_RETURN_TYPES;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -453,7 +451,7 @@ fn check_dynamically_typed<F>(
|
||||||
pub(crate) fn definition(
|
pub(crate) fn definition(
|
||||||
checker: &Checker,
|
checker: &Checker,
|
||||||
definition: &Definition,
|
definition: &Definition,
|
||||||
visibility: Visibility,
|
visibility: visibility::Visibility,
|
||||||
) -> Vec<Diagnostic> {
|
) -> Vec<Diagnostic> {
|
||||||
// TODO(charlie): Consider using the AST directly here rather than `Definition`.
|
// TODO(charlie): Consider using the AST directly here rather than `Definition`.
|
||||||
// We could adhere more closely to `flake8-annotations` by defining public
|
// We could adhere more closely to `flake8-annotations` by defining public
|
||||||
|
@ -705,7 +703,7 @@ pub(crate) fn definition(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
match visibility {
|
match visibility {
|
||||||
Visibility::Public => {
|
visibility::Visibility::Public => {
|
||||||
if checker.enabled(Rule::MissingReturnTypeUndocumentedPublicFunction) {
|
if checker.enabled(Rule::MissingReturnTypeUndocumentedPublicFunction) {
|
||||||
diagnostics.push(Diagnostic::new(
|
diagnostics.push(Diagnostic::new(
|
||||||
MissingReturnTypeUndocumentedPublicFunction {
|
MissingReturnTypeUndocumentedPublicFunction {
|
||||||
|
@ -715,7 +713,7 @@ pub(crate) fn definition(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Visibility::Private => {
|
visibility::Visibility::Private => {
|
||||||
if checker.enabled(Rule::MissingReturnTypePrivateFunction) {
|
if checker.enabled(Rule::MissingReturnTypePrivateFunction) {
|
||||||
diagnostics.push(Diagnostic::new(
|
diagnostics.push(Diagnostic::new(
|
||||||
MissingReturnTypePrivateFunction {
|
MissingReturnTypePrivateFunction {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use rustpython_parser::ast::{self, Constant, Expr};
|
use rustpython_parser::ast::{self, Constant, Expr};
|
||||||
|
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
|
||||||
static PASSWORD_CANDIDATE_REGEX: Lazy<Regex> = Lazy::new(|| {
|
static PASSWORD_CANDIDATE_REGEX: Lazy<Regex> = Lazy::new(|| {
|
||||||
Regex::new(r"(^|_)(?i)(pas+wo?r?d|pass(phrase)?|pwd|token|secrete?)($|_)").unwrap()
|
Regex::new(r"(^|_)(?i)(pas+wo?r?d|pass(phrase)?|pwd|token|secrete?)($|_)").unwrap()
|
||||||
|
|
|
@ -5,7 +5,7 @@ use rustpython_parser::ast::{self, Constant, Expr, Keyword, Ranged};
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::helpers::Truthiness;
|
use ruff_python_ast::helpers::Truthiness;
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
checkers::ast::Checker, registry::Rule, rules::flake8_bandit::helpers::string_literal,
|
checkers::ast::Checker, registry::Rule, rules::flake8_bandit::helpers::string_literal,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::helpers::identifier_range;
|
use ruff_python_ast::helpers::identifier_range;
|
||||||
use ruff_python_semantic::analyze::visibility::{is_abstract, is_overload};
|
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::checkers::ast::Checker;
|
||||||
use crate::registry::Rule;
|
use crate::registry::Rule;
|
||||||
|
|
|
@ -2,7 +2,7 @@ use rustpython_parser::ast::{self, Decorator, Expr, Ranged};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
use ruff_python_ast::visitor::Visitor;
|
use ruff_python_ast::visitor::Visitor;
|
||||||
use ruff_python_semantic::analyze::typing::is_immutable_func;
|
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::checkers::ast::Checker;
|
||||||
use crate::rules::flake8_bugbear::rules::mutable_argument_default::is_mutable_func;
|
use crate::rules::flake8_bugbear::rules::mutable_argument_default::is_mutable_func;
|
||||||
|
|
|
@ -3,7 +3,7 @@ use rustpython_parser::ast::{self, Arguments, Expr, Ranged};
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_semantic::analyze::typing::is_immutable_annotation;
|
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;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use rustpython_parser::ast::{self, Expr, Keyword, Ranged};
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::helpers::is_const_none;
|
use ruff_python_ast::helpers::is_const_none;
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use rustpython_parser::ast::Expr;
|
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.
|
/// 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 {
|
pub(super) fn is_model(model: &SemanticModel, base: &Expr) -> bool {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use rustpython_parser::ast::{self, Expr, Keyword, Ranged};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use rustpython_parser::ast::{self, Constant, Expr, Ranged, Stmt};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use rustpython_parser::ast::{self, Expr, Ranged, Stmt};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ use rustpython_parser::ast::{self, Constant, Expr, Keyword, Operator, Ranged};
|
||||||
use ruff_diagnostics::{Diagnostic, Edit, Fix};
|
use ruff_diagnostics::{Diagnostic, Edit, Fix};
|
||||||
use ruff_python_ast::helpers::{find_keyword, SimpleCallArgs};
|
use ruff_python_ast::helpers::{find_keyword, SimpleCallArgs};
|
||||||
use ruff_python_semantic::analyze::logging;
|
use ruff_python_semantic::analyze::logging;
|
||||||
use ruff_python_semantic::analyze::logging::exc_info;
|
|
||||||
use ruff_python_stdlib::logging::LoggingLevel;
|
use ruff_python_stdlib::logging::LoggingLevel;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -197,7 +196,7 @@ pub(crate) fn logging_call(
|
||||||
if !checker.semantic_model().in_exception_handler() {
|
if !checker.semantic_model().in_exception_handler() {
|
||||||
return;
|
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;
|
return;
|
||||||
};
|
};
|
||||||
if let LoggingCallType::LevelCall(logging_level) = logging_call_type {
|
if let LoggingCallType::LevelCall(logging_level) = logging_call_type {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use rustpython_parser::ast::{Ranged, Stmt};
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::prelude::Expr;
|
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;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,7 @@ use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::helpers::{identifier_range, map_subscript};
|
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::analyze::visibility::{is_abstract, is_final, is_overload};
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::{ScopeKind, SemanticModel};
|
||||||
use ruff_python_semantic::scope::ScopeKind;
|
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,7 @@ use rustpython_parser::ast::{self, Arguments, Constant, Expr, Operator, Ranged,
|
||||||
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix, Violation};
|
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::source_code::Locator;
|
use ruff_python_ast::source_code::Locator;
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::{ScopeKind, SemanticModel};
|
||||||
use ruff_python_semantic::scope::ScopeKind;
|
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::AsRule;
|
use crate::registry::AsRule;
|
||||||
|
|
|
@ -14,7 +14,7 @@ use ruff_python_ast::source_code::Locator;
|
||||||
use ruff_python_ast::visitor::Visitor;
|
use ruff_python_ast::visitor::Visitor;
|
||||||
use ruff_python_ast::{helpers, visitor};
|
use ruff_python_ast::{helpers, visitor};
|
||||||
use ruff_python_semantic::analyze::visibility::is_abstract;
|
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::autofix::edits::remove_argument;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -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::call_path::{collect_call_path, CallPath};
|
||||||
use ruff_python_ast::helpers::map_callable;
|
use ruff_python_ast::helpers::map_callable;
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
use ruff_python_whitespace::PythonWhitespace;
|
use ruff_python_whitespace::PythonWhitespace;
|
||||||
|
|
||||||
pub(super) fn get_mark_decorators(
|
pub(super) fn get_mark_decorators(
|
||||||
|
|
|
@ -4,7 +4,7 @@ use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::call_path::format_call_path;
|
use ruff_python_ast::call_path::format_call_path;
|
||||||
use ruff_python_ast::call_path::from_qualified_name;
|
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::checkers::ast::Checker;
|
||||||
use crate::registry::Rule;
|
use crate::registry::Rule;
|
||||||
|
|
|
@ -10,7 +10,7 @@ use ruff_python_ast::helpers::elif_else_range;
|
||||||
use ruff_python_ast::helpers::is_const_none;
|
use ruff_python_ast::helpers::is_const_none;
|
||||||
use ruff_python_ast::visitor::Visitor;
|
use ruff_python_ast::visitor::Visitor;
|
||||||
use ruff_python_ast::whitespace::indentation;
|
use ruff_python_ast::whitespace::indentation;
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
|
||||||
use crate::autofix::edits;
|
use crate::autofix::edits;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -3,7 +3,7 @@ use rustpython_parser::ast::{self, Expr, Ranged};
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::call_path::collect_call_path;
|
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;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use ruff_python_ast::comparable::{ComparableConstant, ComparableExpr, Comparable
|
||||||
use ruff_python_ast::helpers::{
|
use ruff_python_ast::helpers::{
|
||||||
any_over_expr, contains_effect, first_colon_range, has_comments, has_comments_in,
|
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 ruff_python_whitespace::UniversalNewlines;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -3,7 +3,7 @@ use rustpython_parser::ast::{self, Cmpop, Expr, ExprContext, Ranged, Stmt, Unary
|
||||||
|
|
||||||
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
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::checkers::ast::Checker;
|
||||||
use crate::registry::AsRule;
|
use crate::registry::AsRule;
|
||||||
|
|
|
@ -2,7 +2,7 @@ use rustpython_parser::ast::{self, Expr, Ranged, Stmt};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,7 @@ use rustpython_parser::ast;
|
||||||
|
|
||||||
use ruff_python_ast::call_path::from_qualified_name;
|
use ruff_python_ast::call_path::from_qualified_name;
|
||||||
use ruff_python_ast::helpers::map_callable;
|
use ruff_python_ast::helpers::map_callable;
|
||||||
use ruff_python_semantic::binding::{Binding, BindingKind};
|
use ruff_python_semantic::{Binding, BindingKind, ScopeKind, SemanticModel};
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
|
||||||
use ruff_python_semantic::scope::ScopeKind;
|
|
||||||
|
|
||||||
pub(crate) fn is_valid_runtime_import(semantic_model: &SemanticModel, binding: &Binding) -> bool {
|
pub(crate) fn is_valid_runtime_import(semantic_model: &SemanticModel, binding: &Binding) -> bool {
|
||||||
if matches!(
|
if matches!(
|
||||||
|
|
|
@ -4,9 +4,7 @@ use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use ruff_diagnostics::{AutofixKind, Diagnostic, Fix, Violation};
|
use ruff_diagnostics::{AutofixKind, Diagnostic, Fix, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_semantic::node::NodeId;
|
use ruff_python_semantic::{NodeId, ReferenceId, Scope};
|
||||||
use ruff_python_semantic::reference::ReferenceId;
|
|
||||||
use ruff_python_semantic::scope::Scope;
|
|
||||||
|
|
||||||
use crate::autofix;
|
use crate::autofix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -4,10 +4,7 @@ use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use ruff_diagnostics::{AutofixKind, Diagnostic, DiagnosticKind, Fix, Violation};
|
use ruff_diagnostics::{AutofixKind, Diagnostic, DiagnosticKind, Fix, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_semantic::binding::Binding;
|
use ruff_python_semantic::{Binding, NodeId, ReferenceId, Scope};
|
||||||
use ruff_python_semantic::node::NodeId;
|
|
||||||
use ruff_python_semantic::reference::ReferenceId;
|
|
||||||
use ruff_python_semantic::scope::Scope;
|
|
||||||
|
|
||||||
use crate::autofix;
|
use crate::autofix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -7,11 +7,8 @@ use rustpython_parser::ast::{Arg, Arguments};
|
||||||
use ruff_diagnostics::DiagnosticKind;
|
use ruff_diagnostics::DiagnosticKind;
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_semantic::analyze::function_type;
|
use ruff_python_semantic::analyze::{function_type, visibility};
|
||||||
use ruff_python_semantic::analyze::function_type::FunctionType;
|
use ruff_python_semantic::{Scope, ScopeKind, SemanticModel};
|
||||||
use ruff_python_semantic::analyze::visibility;
|
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
|
||||||
use ruff_python_semantic::scope::{Scope, ScopeKind};
|
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::Rule;
|
use crate::registry::Rule;
|
||||||
|
@ -327,7 +324,7 @@ pub(crate) fn unused_arguments(
|
||||||
&checker.settings.pep8_naming.classmethod_decorators,
|
&checker.settings.pep8_naming.classmethod_decorators,
|
||||||
&checker.settings.pep8_naming.staticmethod_decorators,
|
&checker.settings.pep8_naming.staticmethod_decorators,
|
||||||
) {
|
) {
|
||||||
FunctionType::Function => {
|
function_type::FunctionType::Function => {
|
||||||
if checker.enabled(Argumentable::Function.rule_code())
|
if checker.enabled(Argumentable::Function.rule_code())
|
||||||
&& !visibility::is_overload(checker.semantic_model(), decorator_list)
|
&& !visibility::is_overload(checker.semantic_model(), decorator_list)
|
||||||
{
|
{
|
||||||
|
@ -346,7 +343,7 @@ pub(crate) fn unused_arguments(
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FunctionType::Method => {
|
function_type::FunctionType::Method => {
|
||||||
if checker.enabled(Argumentable::Method.rule_code())
|
if checker.enabled(Argumentable::Method.rule_code())
|
||||||
&& !helpers::is_empty(body)
|
&& !helpers::is_empty(body)
|
||||||
&& (!visibility::is_magic(name)
|
&& (!visibility::is_magic(name)
|
||||||
|
@ -372,7 +369,7 @@ pub(crate) fn unused_arguments(
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FunctionType::ClassMethod => {
|
function_type::FunctionType::ClassMethod => {
|
||||||
if checker.enabled(Argumentable::ClassMethod.rule_code())
|
if checker.enabled(Argumentable::ClassMethod.rule_code())
|
||||||
&& !helpers::is_empty(body)
|
&& !helpers::is_empty(body)
|
||||||
&& (!visibility::is_magic(name)
|
&& (!visibility::is_magic(name)
|
||||||
|
@ -398,7 +395,7 @@ pub(crate) fn unused_arguments(
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FunctionType::StaticMethod => {
|
function_type::FunctionType::StaticMethod => {
|
||||||
if checker.enabled(Argumentable::StaticMethod.rule_code())
|
if checker.enabled(Argumentable::StaticMethod.rule_code())
|
||||||
&& !helpers::is_empty(body)
|
&& !helpers::is_empty(body)
|
||||||
&& (!visibility::is_magic(name)
|
&& (!visibility::is_magic(name)
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use rustpython_parser::ast;
|
use rustpython_parser::ast;
|
||||||
use rustpython_parser::ast::Expr;
|
use rustpython_parser::ast::Expr;
|
||||||
|
|
||||||
use ruff_python_semantic::binding::{BindingKind, Importation};
|
use ruff_python_semantic::{BindingKind, Importation, SemanticModel};
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
|
||||||
|
|
||||||
pub(super) enum Resolution {
|
pub(super) enum Resolution {
|
||||||
/// The expression resolves to an irrelevant expression type (e.g., a constant).
|
/// The expression resolves to an irrelevant expression type (e.g., a constant).
|
||||||
|
|
|
@ -2,7 +2,7 @@ use rustpython_parser::ast::{self, Constant, Expr, Keyword, Ranged};
|
||||||
|
|
||||||
use ruff_diagnostics::{AutofixKind, Diagnostic, Violation};
|
use ruff_diagnostics::{AutofixKind, Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, 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::checkers::ast::Checker;
|
||||||
use crate::registry::AsRule;
|
use crate::registry::AsRule;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use rustpython_parser::ast::{self, Expr, Stmt};
|
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};
|
use ruff_python_stdlib::str::{is_lower, is_upper};
|
||||||
|
|
||||||
pub(super) fn is_camelcase(name: &str) -> bool {
|
pub(super) fn is_camelcase(name: &str) -> bool {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::helpers::identifier_range;
|
use ruff_python_ast::helpers::identifier_range;
|
||||||
use ruff_python_ast::source_code::Locator;
|
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;
|
use crate::settings::types::IdentifierPattern;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use rustpython_parser::ast::{Arguments, Decorator, Ranged};
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_semantic::analyze::function_type;
|
use ruff_python_semantic::analyze::function_type;
|
||||||
use ruff_python_semantic::scope::Scope;
|
use ruff_python_semantic::Scope;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use rustpython_parser::ast::{Arguments, Decorator, Ranged};
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_semantic::analyze::function_type;
|
use ruff_python_semantic::analyze::function_type;
|
||||||
use ruff_python_semantic::scope::Scope;
|
use ruff_python_semantic::Scope;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::helpers::identifier_range;
|
use ruff_python_ast::helpers::identifier_range;
|
||||||
use ruff_python_ast::source_code::Locator;
|
use ruff_python_ast::source_code::Locator;
|
||||||
use ruff_python_semantic::analyze::visibility;
|
use ruff_python_semantic::analyze::visibility;
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
|
||||||
use crate::settings::types::IdentifierPattern;
|
use crate::settings::types::IdentifierPattern;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::helpers::{has_leading_content, has_trailing_content};
|
use ruff_python_ast::helpers::{has_leading_content, has_trailing_content};
|
||||||
use ruff_python_ast::source_code::Generator;
|
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 ruff_python_whitespace::{leading_indentation, UniversalNewlines};
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -4,8 +4,7 @@ use ruff_python_ast::call_path::from_qualified_name;
|
||||||
use ruff_python_ast::cast;
|
use ruff_python_ast::cast;
|
||||||
use ruff_python_ast::helpers::map_callable;
|
use ruff_python_ast::helpers::map_callable;
|
||||||
use ruff_python_ast::str::is_implicit_concatenation;
|
use ruff_python_ast::str::is_implicit_concatenation;
|
||||||
use ruff_python_semantic::definition::{Definition, Member, MemberKind};
|
use ruff_python_semantic::{Definition, Member, MemberKind, SemanticModel};
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
|
||||||
use ruff_python_whitespace::UniversalNewlines;
|
use ruff_python_whitespace::UniversalNewlines;
|
||||||
|
|
||||||
/// Return the index of the first logical line in a string.
|
/// Return the index of the first logical line in a string.
|
||||||
|
|
|
@ -3,7 +3,7 @@ use rustpython_parser::ast::Ranged;
|
||||||
|
|
||||||
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
||||||
use ruff_macros::{derive_message_formats, 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::{PythonWhitespace, UniversalNewlineIterator, UniversalNewlines};
|
use ruff_python_whitespace::{PythonWhitespace, UniversalNewlineIterator, UniversalNewlines};
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -5,7 +5,7 @@ use rustpython_parser::ast::Ranged;
|
||||||
|
|
||||||
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
||||||
use ruff_macros::{derive_message_formats, 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::{PythonWhitespace, UniversalNewlineIterator, UniversalNewlines};
|
use ruff_python_whitespace::{PythonWhitespace, UniversalNewlineIterator, UniversalNewlines};
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -3,7 +3,7 @@ use rustpython_parser::ast::Ranged;
|
||||||
|
|
||||||
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
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::checkers::ast::Checker;
|
||||||
use crate::docstrings::Docstring;
|
use crate::docstrings::Docstring;
|
||||||
|
|
|
@ -3,7 +3,7 @@ use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::cast;
|
use ruff_python_ast::cast;
|
||||||
use ruff_python_ast::helpers::identifier_range;
|
use ruff_python_ast::helpers::identifier_range;
|
||||||
use ruff_python_semantic::analyze::visibility::is_overload;
|
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::checkers::ast::Checker;
|
||||||
use crate::docstrings::Docstring;
|
use crate::docstrings::Docstring;
|
||||||
|
|
|
@ -4,7 +4,7 @@ use rustpython_parser::ast::Ranged;
|
||||||
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::str::{is_triple_quote, leading_quote};
|
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 ruff_python_whitespace::{NewlineWithTrailingNewline, UniversalNewlineIterator};
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -2,7 +2,7 @@ use rustpython_parser::ast::{self, Stmt};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, 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 ruff_python_whitespace::UniversalNewlines;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -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::call_path::{from_qualified_name, CallPath};
|
||||||
use ruff_python_ast::cast;
|
use ruff_python_ast::cast;
|
||||||
use ruff_python_semantic::analyze::visibility::{is_property, is_test};
|
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 ruff_python_whitespace::UniversalNewlines;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use ruff_python_ast::helpers::identifier_range;
|
||||||
use ruff_python_semantic::analyze::visibility::{
|
use ruff_python_semantic::analyze::visibility::{
|
||||||
is_call, is_init, is_magic, is_new, is_overload, is_override, 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::checkers::ast::Checker;
|
||||||
use crate::registry::Rule;
|
use crate::registry::Rule;
|
||||||
|
|
|
@ -12,7 +12,7 @@ use ruff_python_ast::cast;
|
||||||
use ruff_python_ast::docstrings::{clean_space, leading_space};
|
use ruff_python_ast::docstrings::{clean_space, leading_space};
|
||||||
use ruff_python_ast::helpers::identifier_range;
|
use ruff_python_ast::helpers::identifier_range;
|
||||||
use ruff_python_semantic::analyze::visibility::is_staticmethod;
|
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_python_whitespace::NewlineWithTrailingNewline;
|
||||||
use ruff_textwrap::dedent;
|
use ruff_textwrap::dedent;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use rustpython_parser::ast::{Ranged, Stmt};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
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::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use ruff_text_size::TextRange;
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_semantic::scope::Scope;
|
use ruff_python_semantic::Scope;
|
||||||
|
|
||||||
/// ## What it does
|
/// ## What it does
|
||||||
/// Checks for undefined names in `__all__`.
|
/// Checks for undefined names in `__all__`.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_semantic::scope::ScopeId;
|
use ruff_python_semantic::ScopeId;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,7 @@ use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use ruff_diagnostics::{AutofixKind, Diagnostic, Fix, Violation};
|
use ruff_diagnostics::{AutofixKind, Diagnostic, Fix, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_semantic::binding::Exceptions;
|
use ruff_python_semantic::{Exceptions, NodeId, Scope};
|
||||||
use ruff_python_semantic::node::NodeId;
|
|
||||||
use ruff_python_semantic::scope::Scope;
|
|
||||||
|
|
||||||
use crate::autofix;
|
use crate::autofix;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::helpers::contains_effect;
|
use ruff_python_ast::helpers::contains_effect;
|
||||||
use ruff_python_ast::source_code::Locator;
|
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::autofix::edits::delete_stmt;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -4,7 +4,7 @@ use rustpython_parser::ast::{Expr, Ranged};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
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::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use ruff_python_semantic::analyze::function_type;
|
use std::fmt;
|
||||||
use ruff_python_semantic::analyze::function_type::FunctionType;
|
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
|
||||||
use ruff_python_semantic::scope::ScopeKind;
|
|
||||||
use rustpython_parser::ast;
|
use rustpython_parser::ast;
|
||||||
use rustpython_parser::ast::Cmpop;
|
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;
|
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.classmethod_decorators,
|
||||||
&settings.pep8_naming.staticmethod_decorators,
|
&settings.pep8_naming.staticmethod_decorators,
|
||||||
),
|
),
|
||||||
FunctionType::Method
|
function_type::FunctionType::Method
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use rustpython_parser::ast::{self, Expr, Keyword, Ranged};
|
||||||
use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation};
|
use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::helpers::has_comments;
|
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};
|
use crate::{checkers::ast::Checker, registry::AsRule};
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::comparable::ComparableExpr;
|
use ruff_python_ast::comparable::ComparableExpr;
|
||||||
use ruff_python_ast::statement_visitor::{walk_stmt, StatementVisitor};
|
use ruff_python_ast::statement_visitor::{walk_stmt, StatementVisitor};
|
||||||
use ruff_python_ast::types::Node;
|
use ruff_python_ast::types::Node;
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::helpers::is_dunder;
|
use ruff_python_ast::helpers::is_dunder;
|
||||||
use ruff_python_ast::source_code::Generator;
|
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 ruff_python_stdlib::identifiers::is_identifier;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::helpers::is_dunder;
|
use ruff_python_ast::helpers::is_dunder;
|
||||||
use ruff_python_ast::source_code::Generator;
|
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 ruff_python_stdlib::identifiers::is_identifier;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -4,7 +4,7 @@ use rustpython_parser::ast::{self, Excepthandler, Expr, ExprContext, Ranged};
|
||||||
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_ast::call_path::compose_call_path;
|
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::checkers::ast::Checker;
|
||||||
use crate::registry::AsRule;
|
use crate::registry::AsRule;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::helpers::map_callable;
|
use ruff_python_ast::helpers::map_callable;
|
||||||
use rustpython_parser::ast::{self, Expr};
|
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 {
|
pub(super) fn is_mutable_expr(expr: &Expr) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
|
|
|
@ -5,7 +5,7 @@ use rustpython_parser::ast::{self, Arguments, Constant, Expr, Operator, Ranged};
|
||||||
|
|
||||||
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, violation};
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
use ruff_text_size::TextRange;
|
use ruff_text_size::TextRange;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
|
@ -3,7 +3,7 @@ use rustpython_parser::ast::{self, Expr};
|
||||||
use ruff_python_ast::visitor;
|
use ruff_python_ast::visitor;
|
||||||
use ruff_python_ast::visitor::Visitor;
|
use ruff_python_ast::visitor::Visitor;
|
||||||
use ruff_python_semantic::analyze::logging;
|
use ruff_python_semantic::analyze::logging;
|
||||||
use ruff_python_semantic::model::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
|
||||||
/// Collect `logging`-like calls from an AST.
|
/// Collect `logging`-like calls from an AST.
|
||||||
pub(super) struct LoggerCandidateVisitor<'a, 'b> {
|
pub(super) struct LoggerCandidateVisitor<'a, 'b> {
|
||||||
|
|
|
@ -1,9 +1,18 @@
|
||||||
pub mod analyze;
|
pub mod analyze;
|
||||||
pub mod binding;
|
mod binding;
|
||||||
pub mod context;
|
mod context;
|
||||||
pub mod definition;
|
mod definition;
|
||||||
pub mod globals;
|
mod globals;
|
||||||
pub mod model;
|
mod model;
|
||||||
pub mod node;
|
mod node;
|
||||||
pub mod reference;
|
mod reference;
|
||||||
pub mod scope;
|
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::*;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue