mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-19 10:00:42 +00:00
[ty] Only consider a type T
a subtype of a protocol P
if all of P
's members are fully bound on T
(#18466)
## Summary Fixes https://github.com/astral-sh/ty/issues/578 ## Test Plan mdtests
This commit is contained in:
parent
3a8191529c
commit
5a8cdab771
2 changed files with 29 additions and 8 deletions
|
@ -4,7 +4,7 @@ use std::marker::PhantomData;
|
|||
|
||||
use super::protocol_class::ProtocolInterface;
|
||||
use super::{ClassType, KnownClass, SubclassOfType, Type};
|
||||
use crate::symbol::{Symbol, SymbolAndQualifiers};
|
||||
use crate::symbol::{Boundness, Symbol, SymbolAndQualifiers};
|
||||
use crate::types::{ClassLiteral, TypeMapping, TypeVarInstance};
|
||||
use crate::{Db, FxOrderSet};
|
||||
|
||||
|
@ -45,12 +45,12 @@ impl<'db> Type<'db> {
|
|||
protocol: ProtocolInstanceType<'db>,
|
||||
) -> bool {
|
||||
// TODO: this should consider the types of the protocol members
|
||||
// as well as whether each member *exists* on `self`.
|
||||
protocol
|
||||
.inner
|
||||
.interface(db)
|
||||
.members(db)
|
||||
.all(|member| !self.member(db, member.name()).symbol.is_unbound())
|
||||
protocol.inner.interface(db).members(db).all(|member| {
|
||||
matches!(
|
||||
self.member(db, member.name()).symbol,
|
||||
Symbol::Type(_, Boundness::Bound)
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue