[red-knot] Add failing tests for iterating over maybe-iterable unions (#14016)

This commit is contained in:
Alex Waygood 2024-10-31 18:20:21 +00:00 committed by GitHub
parent 9a6b08b557
commit d1189c20df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 61 additions and 3 deletions

View file

@ -1090,7 +1090,7 @@ impl<'db> Type<'db> {
};
}
if let Type::Unknown | Type::Any = self {
if matches!(self, Type::Unknown | Type::Any | Type::Todo) {
// Explicit handling of `Unknown` and `Any` necessary until `type[Unknown]` and
// `type[Any]` are not defined as `Todo` anymore.
return IterationOutcome::Iterable { element_ty: self };
@ -1185,9 +1185,9 @@ impl<'db> Type<'db> {
// TODO can we do better here? `type[LiteralString]`?
Type::StringLiteral(_) | Type::LiteralString => KnownClass::Str.to_class(db),
// TODO: `type[Any]`?
Type::Any => Type::Todo,
Type::Any => Type::Any,
// TODO: `type[Unknown]`?
Type::Unknown => Type::Todo,
Type::Unknown => Type::Unknown,
// TODO intersections
Type::Intersection(_) => Type::Todo,
Type::Todo => Type::Todo,