mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 15:15:33 +00:00
Split CallPath
into QualifiedName
and UnqualifiedName
(#10210)
## Summary Charlie can probably explain this better than I but it turns out, `CallPath` is used for two different things: * To represent unqualified names like `version` where `version` can be a local variable or imported (e.g. `from sys import version` where the full qualified name is `sys.version`) * To represent resolved, full qualified names This PR splits `CallPath` into two types to make this destinction clear. > Note: I haven't renamed all `call_path` variables to `qualified_name` or `unqualified_name`. I can do that if that's welcomed but I first want to get feedback on the approach and naming overall. ## Test Plan `cargo test`
This commit is contained in:
parent
ba4328226d
commit
a6d892b1f4
181 changed files with 1692 additions and 1412 deletions
|
@ -1,7 +1,7 @@
|
|||
use ruff_python_ast::call_path::CallPath;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use ruff_python_ast::helpers::map_callable;
|
||||
use ruff_python_ast::name::QualifiedName;
|
||||
use ruff_python_semantic::{Definition, SemanticModel};
|
||||
use ruff_source_file::UniversalNewlines;
|
||||
|
||||
|
@ -53,11 +53,11 @@ pub(crate) fn should_ignore_definition(
|
|||
|
||||
function.decorator_list.iter().any(|decorator| {
|
||||
semantic
|
||||
.resolve_call_path(map_callable(&decorator.expression))
|
||||
.is_some_and(|call_path| {
|
||||
.resolve_qualified_name(map_callable(&decorator.expression))
|
||||
.is_some_and(|qualified_name| {
|
||||
ignore_decorators
|
||||
.iter()
|
||||
.any(|decorator| CallPath::from_qualified_name(decorator) == call_path)
|
||||
.any(|decorator| QualifiedName::from_dotted_name(decorator) == qualified_name)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use once_cell::sync::Lazy;
|
|||
|
||||
use ruff_diagnostics::{Diagnostic, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::call_path::CallPath;
|
||||
use ruff_python_ast::name::QualifiedName;
|
||||
use ruff_python_semantic::analyze::visibility::{is_property, is_test};
|
||||
use ruff_source_file::UniversalNewlines;
|
||||
use ruff_text_size::Ranged;
|
||||
|
@ -74,8 +74,8 @@ pub(crate) fn non_imperative_mood(
|
|||
|
||||
let property_decorators = property_decorators
|
||||
.iter()
|
||||
.map(|decorator| CallPath::from_qualified_name(decorator))
|
||||
.collect::<Vec<CallPath>>();
|
||||
.map(|decorator| QualifiedName::from_dotted_name(decorator))
|
||||
.collect::<Vec<QualifiedName>>();
|
||||
|
||||
if is_test(&function.name)
|
||||
|| is_property(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue