mirror of https://github.com/astral-sh/ruff
cleanup
This commit is contained in:
parent
ebce96c20d
commit
7d7a3a883c
|
|
@ -25,3 +25,22 @@ B = bytes
|
||||||
|
|
||||||
reveal_mro(C) # revealed: (<class 'C'>, <class 'int'>, <class 'G[bytes]'>, typing.Generic, <class 'object'>)
|
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)
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -386,6 +386,8 @@ impl<'db> TypeContext<'db> {
|
||||||
.is_some_and(|ty| ty.is_typealias_special_form())
|
.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(
|
pub(crate) fn for_starred_expression(
|
||||||
db: &'db dyn Db,
|
db: &'db dyn Db,
|
||||||
expected_element_type: Type<'db>,
|
expected_element_type: Type<'db>,
|
||||||
|
|
@ -401,8 +403,6 @@ impl<'db> TypeContext<'db> {
|
||||||
ast::Expr::Tuple(_) => {
|
ast::Expr::Tuple(_) => {
|
||||||
Self::new(Some(Type::homogeneous_tuple(db, expected_element_type)))
|
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(),
|
_ => Self::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue