Fix problem with np.array related to type[T]
This commit is contained in:
@@ -6799,7 +6799,7 @@ impl<'db> Type<'db> {
|
||||
}
|
||||
KnownInstanceType::Literal(ty) => Ok(ty.inner(db)),
|
||||
KnownInstanceType::Annotated(ty) => Ok(ty.inner(db)),
|
||||
KnownInstanceType::TypeGenericAlias(ty) => {
|
||||
KnownInstanceType::TypeGenericAlias(instance) => {
|
||||
// When `type[…]` appears in a value position (e.g. in an implicit type alias),
|
||||
// we infer its argument as a type expression. This ensures that we can emit
|
||||
// diagnostics for invalid type expressions, and more importantly, that we can
|
||||
@@ -6808,7 +6808,13 @@ impl<'db> Type<'db> {
|
||||
// (`int` -> instance of `int` -> subclass of `int`) can be lossy, but it is
|
||||
// okay for all valid arguments to `type[…]`.
|
||||
|
||||
Ok(ty.inner(db).to_meta_type(db))
|
||||
let ty = instance.inner(db);
|
||||
|
||||
if ty.is_type_var() {
|
||||
Ok(todo_type!("type[T] for typevar T"))
|
||||
} else {
|
||||
Ok(ty.to_meta_type(db))
|
||||
}
|
||||
}
|
||||
KnownInstanceType::Callable(instance) => {
|
||||
Ok(Type::Callable(instance.callable_type(db)))
|
||||
|
||||
Reference in New Issue
Block a user