mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-04 23:50:31 +00:00
![]() ## Summary This PR reduces the virality of some of the `Todo` types in `infer_tuple_type_expression`. Rather than inferring `Todo`, we instead infer `tuple[Todo, ...]`. This reflects the fact that whatever the contents of the slice in a `tuple[]` type expression, we would always infer some kind of tuple type as the result of the type expression. Any tuple type should be assignable to `tuple[Todo, ...]`, so this shouldn't introduce any new false positives; this can be seen in the ecosystem report. As a result of the change, we are now able to enforce in the signature of `Type::infer_tuple_type_expression` that it returns an `Option<TupleType<'db>>`, which is more strongly typed and expresses clearly the invariant that a tuple type expression should always be inferred as a `tuple` type. To enable this, it was necessary to refactor several `TupleType` constructors in `tuple.rs` so that they return `Option<TupleType>` rather than `Type`; this means that callers of these constructor functions are now free to either propagate the `Option<TupleType<'db>>` or convert it to a `Type<'db>`. ## Test Plan Mdtests updated. |
||
---|---|---|
.. | ||
annotated.md | ||
any.md | ||
callable.md | ||
deferred.md | ||
int_float_complex.md | ||
invalid.md | ||
literal.md | ||
literal_string.md | ||
never.md | ||
new_types.md | ||
optional.md | ||
self.md | ||
starred.md | ||
stdlib_typing_aliases.md | ||
string.md | ||
union.md | ||
unsupported_special_forms.md | ||
unsupported_special_types.md | ||
unsupported_type_qualifiers.md |