mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 05:44:56 +00:00
[ty] get_protocol_members
returns a frozenset, not a tuple (#18284)
This commit is contained in:
parent
53d19f8368
commit
e293411679
2 changed files with 18 additions and 27 deletions
|
@ -667,15 +667,15 @@ impl<'db> Bindings<'db> {
|
|||
Some(KnownFunction::GetProtocolMembers) => {
|
||||
if let [Some(Type::ClassLiteral(class))] = overload.parameter_types() {
|
||||
if let Some(protocol_class) = class.into_protocol_class(db) {
|
||||
// TODO: actually a frozenset at runtime (requires support for legacy generic classes)
|
||||
overload.set_return_type(Type::Tuple(TupleType::new(
|
||||
db,
|
||||
protocol_class
|
||||
.interface(db)
|
||||
.members(db)
|
||||
.map(|member| Type::string_literal(db, member.name()))
|
||||
.collect::<Box<[Type<'db>]>>(),
|
||||
)));
|
||||
let member_names = protocol_class
|
||||
.interface(db)
|
||||
.members(db)
|
||||
.map(|member| Type::string_literal(db, member.name()));
|
||||
let specialization = UnionType::from_elements(db, member_names);
|
||||
overload.set_return_type(
|
||||
KnownClass::FrozenSet
|
||||
.to_specialized_instance(db, [specialization]),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue