Repository: astral-sh/ruff
File: crates/ty_python_semantic/src/types/bound_super.rs (Rust)

Code before:
                            Type::NominalInstance(instance) => Some(instance.class(db)),
                            _ => bound.to_class_type(db),
                        };
                        match class {
                            Some(class) => SuperOwnerKind::InstanceTypeVar(bound_typevar, class),
                            None => {
                                return Err(BoundSuperError::AbstractOwnerType {
                                    owner_type,
                                    pivot_class: pivot_class_type,
                                    typevar_context: Some(typevar),
                                });
                            }
                        }
                    }
                    Some(TypeVarBoundOrConstraints::Constraints(constraints)) => {
                        return build_constrained_union(
                            constraints,
                            bound_typevar,
                            typevar,
                            SuperOwnerKind::InstanceTypeVar,
                        );
                    }
                    None => {
                        // No bound means the implicit upper bound is `object`.
                        let class = ClassType::object(db);
                        SuperOwnerKind::InstanceTypeVar(bound_typevar, class)
                    }
                }
            }
            Type::BooleanLiteral(_) | Type::TypeIs(_) | Type::TypeGuard(_) => {
                return delegate_to(KnownClass::Bool.to_instance(db));
            }
            Type::IntLiteral(_) => return delegate_to(KnownClass::Int.to_instance(db)),
            Type::StringLiteral(_) | Type::LiteralString => {
                return delegate_to(KnownClass::Str.to_instance(db));
            }
            Type::BytesLiteral(_) => {
                return delegate_to(KnownClass::Bytes.to_instance(db));
            }
            Type::SpecialForm(special_form) => {
                return delegate_to(special_form.instance_fallback(db));
            }
            Type::KnownInstance(instance) => {
                return delegate_to(instance.instance_fallback(db));
            }
            Type::FunctionLiteral(_) | Type::DataclassDecorator(_) => {
                return delegate_to(KnownClass::FunctionType.to_instance(db));
            }
            Type::WrapperDescriptor(_) => {
                return delegate_to(KnownClass::WrapperDescriptorType.to_instance(db));
            }

Review comment (suggestion):
```suggestion
                        SuperOwnerKind::InstanceTypeVar(bound_typevar, ClassType::object(db))
```

Code after:
                    if let Ok(good_element) = delegate_to(*positive) {
                        one_good_element_found = true;
                        builder = builder.add_positive(good_element);
                    }
                }
                if !one_good_element_found {
                    return Err(BoundSuperError::AbstractOwnerType {
                        owner_type,
                        pivot_class: pivot_class_type,
                        typevar_context: None,
                    });
                }
                for negative in intersection.negative(db) {
                    if let Ok(good_element) = delegate_to(*negative) {
                        builder = builder.add_negative(good_element);
                    }
                }
                return Ok(builder.build());
            }
            Type::TypeAlias(alias) => {
                return delegate_to(alias.value_type(db));
            }
            Type::TypeVar(bound_typevar) => {
                let typevar = bound_typevar.typevar(db);
                match typevar.bound_or_constraints(db) {
                    Some(TypeVarBoundOrConstraints::UpperBound(bound)) => {
                        let class = match bound {
                            Type::NominalInstance(instance) => Some(instance.class(db)),
                            Type::ProtocolInstance(protocol) => protocol
                                .to_nominal_instance()
                                .map(|instance| instance.class(db)),
                            _ => None,
                        };
                        if let Some(class) = class {
                            SuperOwnerKind::InstanceTypeVar(bound_typevar, class)
                        } else {
                            return delegate_with_error_mapped(bound, Some(typevar));
                        }
                    }
                    Some(TypeVarBoundOrConstraints::Constraints(constraints)) => {
                        return build_constrained_union(
                            constraints,
                            bound_typevar,
                            typevar,
                            SuperOwnerKind::InstanceTypeVar,
                        );
                    }
                    None => {
                        // No bound means the implicit upper bound is `object`.
                        SuperOwnerKind::InstanceTypeVar(bound_typevar, ClassType::object(db))
                    }