Skip to content

Commit ecfd695

Browse files
conformance: fix TypeIs case (#2298)
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.
1 parent 735dba9 commit ecfd695

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

conformance/tests/narrowing_typeis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
def is_two_element_tuple(val: tuple[T, ...]) -> TypeIs[tuple[T, T]]:
1515
return len(val) == 2
1616

17-
def func1(names: tuple[str, ...]):
17+
def func1(names: tuple[str, str] | tuple[str, str, str]):
1818
if is_two_element_tuple(names):
1919
assert_type(names, tuple[str, str])
2020
else:
21-
assert_type(names, tuple[str, ...])
21+
assert_type(names, tuple[str, str, str])
2222

2323

2424
# > The final narrowed type may be narrower than **R**, due to the constraints of the

0 commit comments

Comments
 (0)