This commit is contained in:
Alex Waygood 2025-11-27 17:41:51 +00:00
parent ebce96c20d
commit 7d7a3a883c
2 changed files with 21 additions and 2 deletions

View File

@ -25,3 +25,22 @@ B = bytes
reveal_mro(C) # revealed: (<class 'C'>, <class 'int'>, <class 'G[bytes]'>, typing.Generic, <class 'object'>)
```
## Starred bases
These are currently not supported, but ideally we would support them in some limited situations.
```py
from ty_extensions import reveal_mro
class A: ...
class B: ...
class C: ...
bases = (A, B, C)
class Foo(*bases): ...
# revealed: (<class 'Foo'>, @Todo(Starred expressions in class bases), <class 'object'>)
reveal_mro(Foo)
```

View File

@ -386,6 +386,8 @@ impl<'db> TypeContext<'db> {
.is_some_and(|ty| ty.is_typealias_special_form())
}
// TODO: we could just always use `Iterable[<expected_element_type>]`
// as the type context once <https://github.com/astral-sh/ty/issues/1576> is fixed.
pub(crate) fn for_starred_expression(
db: &'db dyn Db,
expected_element_type: Type<'db>,
@ -401,8 +403,6 @@ impl<'db> TypeContext<'db> {
ast::Expr::Tuple(_) => {
Self::new(Some(Type::homogeneous_tuple(db, expected_element_type)))
}
// `Iterable[<expected_element_type>]` would work well for an arbitrary other node
// if <https://github.com/astral-sh/ty/issues/1576> is implemented.
_ => Self::default(),
}
}