mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-01 17:32:25 +00:00

## 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`
9 lines
291 B
Rust
9 lines
291 B
Rust
use ruff_python_ast::Expr;
|
|
|
|
use ruff_python_semantic::SemanticModel;
|
|
|
|
pub(super) fn is_sys(expr: &Expr, target: &str, semantic: &SemanticModel) -> bool {
|
|
semantic
|
|
.resolve_qualified_name(expr)
|
|
.is_some_and(|qualified_name| qualified_name.segments() == ["sys", target])
|
|
}
|