Skip to content

Commit c55a4d0

Browse files
authored
Make optional type narrowing actually optional in tuples_type_compat.py (#1981)
1 parent 2d9ea90 commit c55a4d0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

conformance/tests/tuples_type_compat.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ def func4(
7171
def func5(val: tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]):
7272
if len(val) == 1:
7373
# Type can be narrowed to tuple[int].
74-
assert_type(val, tuple[int]) # tuple[int]
74+
assert_type(val, tuple[int]) # E?: tuple[int]
7575

7676
if len(val) == 2:
7777
# Type can be narrowed to tuple[str, str] | tuple[int, int].
78-
assert_type(val, tuple[str, str] | tuple[int, int])
78+
assert_type(val, tuple[str, str] | tuple[int, int]) # E?
7979

8080
if len(val) == 3:
8181
# Type can be narrowed to tuple[int, str, int].
82-
assert_type(val, tuple[int, str, int])
82+
assert_type(val, tuple[int, str, int]) # E?
8383

8484

8585
# > This property may also be used to safely narrow tuple types within a match
@@ -92,15 +92,15 @@ def func6(val: tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int])
9292
match val:
9393
case (x,):
9494
# Type can be narrowed to tuple[int].
95-
assert_type(val, tuple[int]) # tuple[int]
95+
assert_type(val, tuple[int]) # E?: tuple[int]
9696

9797
case (x, y):
9898
# Type can be narrowed to tuple[str, str] | tuple[int, int].
99-
assert_type(val, tuple[str, str] | tuple[int, int])
99+
assert_type(val, tuple[str, str] | tuple[int, int]) # E?
100100

101101
case (x, y, z):
102102
# Type can be narrowed to tuple[int, str, int].
103-
assert_type(val, tuple[int, str, int])
103+
assert_type(val, tuple[int, str, int]) # E?
104104

105105

106106
# > Type checkers may safely use this equivalency rule (tuple expansion)
@@ -112,9 +112,9 @@ def func6(val: tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int])
112112
def func7(subj: tuple[int | str, int | str]):
113113
match subj:
114114
case x, str():
115-
assert_type(subj, tuple[int | str, str])
115+
assert_type(subj, tuple[int | str, str]) # E?
116116
case y:
117-
assert_type(subj, tuple[int | str, int])
117+
assert_type(subj, tuple[int | str, int]) # E?
118118

119119

120120
# > The tuple class derives from Sequence[T_co] where ``T_co`` is a covariant

0 commit comments

Comments
 (0)