mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 05:20:49 -05:00
[ty] Meta-type of type variables should be type[..] (#18439)
## Summary Came across this while debugging some ecosystem changes in https://github.com/astral-sh/ruff/pull/18347. I think the meta-type of a typevar-annotated variable should be equal to `type`, not `<class 'object'>`. ## Test Plan New Markdown tests.
This commit is contained in:
@@ -5243,7 +5243,7 @@ impl<'db> Type<'db> {
|
||||
Type::Tuple(_) => KnownClass::Tuple.to_class_literal(db),
|
||||
|
||||
Type::TypeVar(typevar) => match typevar.bound_or_constraints(db) {
|
||||
None => KnownClass::Object.to_class_literal(db),
|
||||
None => KnownClass::Type.to_instance(db),
|
||||
Some(TypeVarBoundOrConstraints::UpperBound(bound)) => bound.to_meta_type(db),
|
||||
Some(TypeVarBoundOrConstraints::Constraints(constraints)) => {
|
||||
// TODO: If we add a proper `OneOf` connector, we should use that here instead
|
||||
|
||||
Reference in New Issue
Block a user