From 717a38f579a1a2eff0719939560040e6874a0279 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 31 May 2026 20:02:06 -0700 Subject: [PATCH] conformance: fix TypeIs case Strictly, the inferred type in the old code should be `tuple[str, ...] & ~tuple[str, str]`: that is, a tuple full of strs of any length that is not 2. Currently no type checker actually infers this type, but I'm working on a change to pycroscope that will make it fail this test. ty also infers the negation type, but passes the test because the conformance suite turns off the specific "assert-type-unspellable-subtype" error code. --- conformance/tests/narrowing_typeis.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conformance/tests/narrowing_typeis.py b/conformance/tests/narrowing_typeis.py index d3bbb6045..9a2e62cde 100644 --- a/conformance/tests/narrowing_typeis.py +++ b/conformance/tests/narrowing_typeis.py @@ -14,11 +14,11 @@ def is_two_element_tuple(val: tuple[T, ...]) -> TypeIs[tuple[T, T]]: return len(val) == 2 -def func1(names: tuple[str, ...]): +def func1(names: tuple[str, str] | tuple[str, str, str]): if is_two_element_tuple(names): assert_type(names, tuple[str, str]) else: - assert_type(names, tuple[str, ...]) + assert_type(names, tuple[str, str, str]) # > The final narrowed type may be narrower than **R**, due to the constraints of the