Skip to content

Commit 2f678fd

Browse files
committed
directives_type_checking.py: do not assert that type checkers must ignore all type errors in if not TYPE_CHECKING blocks
1 parent d08f800 commit 2f678fd

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

conformance/results/results.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ <h3>Python Type System Conformance Test Results</h3>
11761176
<th class="column col2 conformant">Pass</th>
11771177
<th class="column col2 conformant">Pass</th>
11781178
<th class="column col2 conformant">Pass</th>
1179-
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Attempts to detect some errors even in blocks it determines to be unreachable, including in `if not TYPE_CHECKING` blocks.</p></span></div></th>
1179+
<th class="column col2 conformant">Pass</th>
11801180
</tr>
11811181
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;directives_type_ignore</th>
11821182
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Does not honor "# type: ignore" comment if comment includes additional text.</p></span></div></th>
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
conformance_automated = "Fail"
2-
conformant = "Partial"
3-
notes = """
4-
Attempts to detect some errors even in blocks it determines to be unreachable, including in `if not TYPE_CHECKING` blocks.
5-
"""
1+
conformance_automated = "Pass"
62
errors_diff = """
7-
Line 11: Unexpected errors ['directives_type_checking.py:11:14: error[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`']
83
"""
94
output = """
10-
directives_type_checking.py:11:14: error[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`
115
"""

conformance/tests/directives_type_checking.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
from typing import TYPE_CHECKING, assert_type
88

99

10-
if not TYPE_CHECKING:
11-
a: int = "" # This should not generate an error
10+
def foo(x: list[int], y: list[str]) -> None:
11+
z: list[int] | list[str]
1212

13-
if TYPE_CHECKING:
14-
b: list[int] = [1, 2, 3]
15-
else:
16-
b: list[str] = ["a", "b", "c"]
13+
if TYPE_CHECKING:
14+
z = x
15+
else:
16+
z = y
1717

18-
assert_type(b, list[int])
18+
assert_type(z, list[int])

0 commit comments

Comments
 (0)