mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
[red-knot] Minor 'member_lookup_with_policy' fix (#17407)
## Summary Couldn't really think of a regression test, but it's probably better to fix this if we ever add new member-lookup-policies.
This commit is contained in:
parent
03adae80dc
commit
1f85e0d0a0
1 changed files with 11 additions and 8 deletions
|
@ -2637,24 +2637,27 @@ impl<'db> Type<'db> {
|
|||
_ => {
|
||||
KnownClass::MethodType
|
||||
.to_instance(db)
|
||||
.member(db, &name)
|
||||
.member_lookup_with_policy(db, name.clone(), policy)
|
||||
.or_fall_back_to(db, || {
|
||||
// If an attribute is not available on the bound method object,
|
||||
// it will be looked up on the underlying function object:
|
||||
Type::FunctionLiteral(bound_method.function(db)).member(db, &name)
|
||||
Type::FunctionLiteral(bound_method.function(db))
|
||||
.member_lookup_with_policy(db, name, policy)
|
||||
})
|
||||
}
|
||||
},
|
||||
Type::MethodWrapper(_) => KnownClass::MethodWrapperType
|
||||
.to_instance(db)
|
||||
.member(db, &name),
|
||||
.member_lookup_with_policy(db, name, policy),
|
||||
Type::WrapperDescriptor(_) => KnownClass::WrapperDescriptorType
|
||||
.to_instance(db)
|
||||
.member(db, &name),
|
||||
Type::DataclassDecorator(_) => {
|
||||
KnownClass::FunctionType.to_instance(db).member(db, &name)
|
||||
}
|
||||
Type::Callable(_) => KnownClass::Object.to_instance(db).member(db, &name),
|
||||
.member_lookup_with_policy(db, name, policy),
|
||||
Type::DataclassDecorator(_) => KnownClass::FunctionType
|
||||
.to_instance(db)
|
||||
.member_lookup_with_policy(db, name, policy),
|
||||
Type::Callable(_) => KnownClass::Object
|
||||
.to_instance(db)
|
||||
.member_lookup_with_policy(db, name, policy),
|
||||
|
||||
Type::Instance(InstanceType { class })
|
||||
if matches!(name.as_str(), "major" | "minor")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue