mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:09:22 +00:00
Respect attribute chains when resolving builtin call paths (#9309)
## Summary When resolving `dict.__dict__`, we were discarding the `.__dict__` segment when computing the call path. ## Test Plan `cargo test`
This commit is contained in:
parent
ec88acc291
commit
00f3c7d1d5
5 changed files with 26 additions and 3 deletions
|
@ -707,7 +707,20 @@ impl<'a> SemanticModel<'a> {
|
|||
};
|
||||
Some(resolved)
|
||||
}
|
||||
BindingKind::Builtin => Some(smallvec!["", head.id.as_str()]),
|
||||
BindingKind::Builtin => {
|
||||
if value.is_name_expr() {
|
||||
// Ex) `dict`
|
||||
Some(smallvec!["", head.id.as_str()])
|
||||
} else {
|
||||
// Ex) `dict.__dict__`
|
||||
let value_path = collect_call_path(value)?;
|
||||
Some(
|
||||
std::iter::once("")
|
||||
.chain(value_path.iter().copied())
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
}
|
||||
BindingKind::ClassDefinition(_) | BindingKind::FunctionDefinition(_) => {
|
||||
let value_path = collect_call_path(value)?;
|
||||
let resolved: CallPath = self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue