Skip to content

Commit c6fd374

Browse files
committed
add an optional E? assertion for documentation purposes
1 parent b6074d8 commit c6fd374

File tree

6 files changed

+15
-0
lines changed

6 files changed

+15
-0
lines changed

conformance/results/mypy/directives_type_checking.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
conformant = "Pass"
22
output = """
3+
directives_type_checking.py:22: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]
34
"""
45
conformance_automated = "Pass"
56
errors_diff = """

conformance/results/pyrefly/directives_type_checking.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ conformance_automated = "Pass"
33
errors_diff = """
44
"""
55
output = """
6+
ERROR directives_type_checking.py:22:14-16: `Literal['']` is not assignable to `int` [bad-assignment]
67
"""

conformance/results/pyright/directives_type_checking.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
conformant = "Pass"
22
output = """
3+
directives_type_checking.py:22:14 - error: Type "Literal['']" is not assignable to declared type "int"
4+
  "Literal['']" is not assignable to "int" (reportAssignmentType)
35
"""
46
conformance_automated = "Pass"
57
errors_diff = """

conformance/results/ty/directives_type_checking.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ conformance_automated = "Pass"
22
errors_diff = """
33
"""
44
output = """
5+
directives_type_checking.py:22:14: error[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`
56
"""

conformance/results/zuban/directives_type_checking.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ conformance_automated = "Pass"
22
errors_diff = """
33
"""
44
output = """
5+
directives_type_checking.py:22: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]
56
"""

conformance/tests/directives_type_checking.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,12 @@ def foo(x: list[int], y: list[str]) -> None:
1616
z = y
1717

1818
assert_type(z, list[int])
19+
20+
21+
if TYPE_CHECKING:
22+
x: int = "" # E: In a `if TYPE_CHECKING` block, type checkers should report all errors as normal
23+
else:
24+
x: int = "" # E? Many type checkers suppress all errors in `else` blocks of `if TYPE_CHECKING`, though this is not currently specified
25+
26+
if not TYPE_CHECKING:
27+
x: int = "" # E? Many type checkers suppress all errors in `if not TYPE_CHECKING` blocks, though this is not currently specified

0 commit comments

Comments
 (0)