[ty] Mark all_type_assignable_to_iterable_are_iterable as flaky (#19574)

This commit is contained in:
Alex Waygood 2025-07-27 12:04:13 +01:00 committed by GitHub
parent 469c50b0b7
commit df5eba7583
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -68,7 +68,7 @@ macro_rules! type_property_test {
mod stable {
use super::union;
use crate::types::{CallableType, KnownClass, Type};
use crate::types::{CallableType, Type};
// Reflexivity: `T` is equivalent to itself.
type_property_test!(
@ -205,16 +205,6 @@ mod stable {
all_fully_static_type_pairs_are_subtype_of_their_union, db,
forall fully_static_types s, t. s.is_subtype_of(db, union(db, [s, t])) && t.is_subtype_of(db, union(db, [s, t]))
);
// Any type assignable to `Iterable[object]` should be considered iterable.
//
// Note that the inverse is not true, due to the fact that we recognize the old-style
// iteration protocol as well as the new-style iteration protocol: not all objects that
// we consider iterable are assignable to `Iterable[object]`.
type_property_test!(
all_type_assignable_to_iterable_are_iterable, db,
forall types t. t.is_assignable_to(db, KnownClass::Iterable.to_specialized_instance(db, [Type::object(db)])) => t.try_iterate(db).is_ok()
);
}
/// This module contains property tests that currently lead to many false positives.
@ -227,6 +217,8 @@ mod stable {
mod flaky {
use itertools::Itertools;
use crate::types::{KnownClass, Type};
use super::{intersection, union};
// Negating `T` twice is equivalent to `T`.
@ -321,4 +313,16 @@ mod flaky {
bottom_materialization_of_type_is_assigneble_to_type, db,
forall types t. t.bottom_materialization(db).is_assignable_to(db, t)
);
// Any type assignable to `Iterable[object]` should be considered iterable.
//
// Note that the inverse is not true, due to the fact that we recognize the old-style
// iteration protocol as well as the new-style iteration protocol: not all objects that
// we consider iterable are assignable to `Iterable[object]`.
//
// Currently flaky due to <https://github.com/astral-sh/ty/issues/889>
type_property_test!(
all_type_assignable_to_iterable_are_iterable, db,
forall types t. t.is_assignable_to(db, KnownClass::Iterable.to_specialized_instance(db, [Type::object(db)])) => t.try_iterate(db).is_ok()
);
}