Skip to content

Commit ffd520a

Browse files
authored
Do not mandate a specific dead code policy in NoReturn conformance test (#2175)
Remove dead-code lines from specialtypes_never conformance test
1 parent 6112382 commit ffd520a

File tree

6 files changed

+16
-24
lines changed

6 files changed

+16
-24
lines changed

conformance/results/mypy/specialtypes_never.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
conformant = "Pass"
22
output = """
33
specialtypes_never.py:19: error: Implicit return in function which does not return [misc]
4-
specialtypes_never.py:87: error: Incompatible types in assignment (expression has type "list[Never]", variable has type "list[int]") [assignment]
5-
specialtypes_never.py:87: note: "list" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
6-
specialtypes_never.py:87: note: Consider using "Sequence" instead, which is covariant
7-
specialtypes_never.py:106: error: Incompatible return value type (got "ClassC[Never]", expected "ClassC[U]") [return-value]
4+
specialtypes_never.py:85: error: Incompatible types in assignment (expression has type "list[Never]", variable has type "list[int]") [assignment]
5+
specialtypes_never.py:85: note: "list" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
6+
specialtypes_never.py:85: note: Consider using "Sequence" instead, which is covariant
7+
specialtypes_never.py:104: error: Incompatible return value type (got "ClassC[Never]", expected "ClassC[U]") [return-value]
88
"""
99
conformance_automated = "Pass"
1010
errors_diff = """
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
conformant = "Partial"
2-
notes = """
3-
Does not detect invalid return is unreachable
4-
"""
5-
conformance_automated = "Fail"
1+
conformant = "Pass"
2+
conformance_automated = "Pass"
63
errors_diff = """
7-
Line 33: Unexpected errors ["Returned type `Literal['whatever works']` is not assignable to declared return type `int` [bad-return]"]
84
"""
95
output = """
106
ERROR specialtypes_never.py:19:22-30: Function declared to return `NoReturn` but is missing an explicit `return` [bad-return]
11-
ERROR specialtypes_never.py:33:12-28: Returned type `Literal['whatever works']` is not assignable to declared return type `int` [bad-return]
12-
ERROR specialtypes_never.py:87:21-22: `list[Never]` is not assignable to `list[int]` [bad-assignment]
13-
ERROR specialtypes_never.py:106:12-27: Returned type `ClassC[Never]` is not assignable to declared return type `ClassC[U]` [bad-return]
7+
ERROR specialtypes_never.py:85:21-22: `list[Never]` is not assignable to `list[int]` [bad-assignment]
8+
ERROR specialtypes_never.py:104:12-27: Returned type `ClassC[Never]` is not assignable to declared return type `ClassC[U]` [bad-return]
149
"""

conformance/results/pyright/specialtypes_never.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
conformant = "Pass"
22
output = """
33
specialtypes_never.py:19:22 - error: Function with declared return type "NoReturn" cannot return "None" (reportReturnType)
4-
specialtypes_never.py:87:21 - error: Type "list[Never]" is not assignable to declared type "list[int]"
4+
specialtypes_never.py:85:21 - error: Type "list[Never]" is not assignable to declared type "list[int]"
55
  "list[Never]" is not assignable to "list[int]"
66
    Type parameter "_T@list" is invariant, but "Never" is not the same as "int"
77
    Consider switching from "list" to "Sequence" which is covariant (reportAssignmentType)
8-
specialtypes_never.py:106:12 - error: Type "ClassC[Never]" is not assignable to return type "ClassC[U@func10]"
8+
specialtypes_never.py:104:12 - error: Type "ClassC[Never]" is not assignable to return type "ClassC[U@func10]"
99
  "ClassC[Never]" is not assignable to "ClassC[U@func10]"
1010
    Type parameter "T@ClassC" is invariant, but "Never" is not the same as "U@func10" (reportReturnType)
1111
"""

conformance/results/results.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ <h3>Python Type System Conformance Test Results</h3>
227227
<th class="column col2 conformant">Pass</th>
228228
<th class="column col2 conformant">Pass</th>
229229
<th class="column col2 conformant">Pass</th>
230-
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Does not detect invalid return is unreachable</p></span></div></th>
230+
<th class="column col2 conformant">Pass</th>
231231
</tr>
232232
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;specialtypes_none</th>
233233
<th class="column col2 conformant">Pass</th>

conformance/results/zuban/specialtypes_never.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ errors_diff = """
33
"""
44
output = """
55
specialtypes_never.py:19: error: Implicit return in function which does not return [misc]
6-
specialtypes_never.py:32: error: Statement is unreachable [unreachable]
7-
specialtypes_never.py:87: error: Incompatible types in assignment (expression has type "list[Never]", variable has type "list[int]") [assignment]
8-
specialtypes_never.py:87: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
9-
specialtypes_never.py:87: note: Consider using "Sequence" instead, which is covariant
10-
specialtypes_never.py:106: error: Incompatible return value type (got "ClassC[Never]", expected "ClassC[U]") [return-value]
6+
specialtypes_never.py:85: error: Incompatible types in assignment (expression has type "list[Never]", variable has type "list[int]") [assignment]
7+
specialtypes_never.py:85: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
8+
specialtypes_never.py:85: note: Consider using "Sequence" instead, which is covariant
9+
specialtypes_never.py:104: error: Incompatible return value type (got "ClassC[Never]", expected "ClassC[U]") [return-value]
1110
"""

conformance/tests/specialtypes_never.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@ def func1(x: int) -> NoReturn: # E: implicitly returns None
2424
# > The checkers will also recognize that the code after calls to such functions
2525
# > is unreachable and will behave accordingly.
2626

27-
27+
# No error on implicit None return after stop()
2828
def func2(x: int) -> int:
2929
if x > 0:
3030
return x
3131
stop()
32-
... # E?: This statement can be marked unreachable
33-
return "whatever works" # No type error
3432

3533

3634
# The spec previously said that NoReturn is only valid in a function return type,

0 commit comments

Comments
 (0)