Skip to content

Commit ac67f79

Browse files
Conformance: Make "# E[tag]" exactly once, add support for at least once (#1982)
1 parent c55a4d0 commit ac67f79

21 files changed

+273
-238
lines changed

conformance/README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,26 @@ Test cases use the following conventions:
4646
* Lines that are expected to produce a type checker error should have a comment starting with # E",
4747
either by itself or followed by an explanation after a colon (e.g., "# E: int is not a subtype
4848
of str"). Such explanatory comments are purely for human understanding, but type checkers are not
49-
expected to use their exact wording.
49+
expected to use their exact wording. There are several syntactic variations; see "Test Case Syntax"
50+
below.
5051
* Lines that may produce an error (e.g., because the spec allows multiple behaviors) should be
5152
marked with "# E?" instead of "# E".
5253
* If a test case tests conformance with a specific passage in the spec, that passage should be
5354
quoted in a comment prefixed with "# > ".
5455

56+
## Test Case Syntax
57+
58+
Test cases support the following special comments for declaring where errors should be raised:
59+
60+
* `# E`: an error must be raised on this line
61+
* `# E?`: an error may be raised on this line
62+
* `# E[tag]`, where `tag` is an arbitrary string: must appear multiple times in a file with the same tag.
63+
Exactly one line with this tag must raise an error.
64+
* `# E[tag+]`: like `# E[tag]`, but errors may be raised on multiple lines.
65+
66+
Each comment may be followed by a colon plus an explanation of the error; the explanation is ignored
67+
by the scoring system.
68+
5569
## Running the Conformance Test Tool
5670

5771
To run the conformance test suite:
@@ -60,7 +74,7 @@ To run the conformance test suite:
6074
* Switch to the `conformance` subdirectory and install all dependencies (`pip install -r requirements.txt`).
6175
* Switch to the `src` subdirectory and run `python main.py`.
6276

63-
Note that some type checkers may not run on some platforms. If a type checker fails to install, tests will be skipped for that type checker.
77+
Note that some type checkers may not run on some platforms. If a type checker fails to install, tests will be skipped for that type checker.
6478
Currently, the only unsupported type checker is Pyre on Windows.
6579

6680
## Reporting Conformance Results

conformance/results/mypy/overloads_definitions.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Does not allow an overload with no implementation in an abstract base class.
55
Allows @override to be on all overloads and implementation, instead of just implementation.
66
"""
77
errors_diff = """
8-
Lines 220, 222, 226: Expected error (tag 'override_impl')
8+
Lines 220, 221, 222, 225, 226: Expected error (tag 'override_impl')
99
Line 47: Unexpected errors ['overloads_definitions.py:47: error: An overloaded function outside a stub file must have an implementation [no-overload-impl]']
1010
"""
1111
output = """
@@ -14,8 +14,6 @@ overloads_definitions.py:27: error: An overloaded function outside a stub file m
1414
overloads_definitions.py:47: error: An overloaded function outside a stub file must have an implementation [no-overload-impl]
1515
overloads_definitions.py:58: error: An overloaded function outside a stub file must have an implementation [no-overload-impl]
1616
overloads_definitions.py:71: error: Overload does not consistently use the "@staticmethod" decorator on all function signatures. [misc]
17-
overloads_definitions.py:81: error: Overloaded function implementation does not accept all possible arguments of signature 1 [misc]
18-
overloads_definitions.py:81: error: Overloaded function implementation does not accept all possible arguments of signature 2 [misc]
1917
overloads_definitions.py:84: error: Overload does not consistently use the "@classmethod" decorator on all function signatures. [misc]
2018
overloads_definitions.py:121: error: @final should be applied only to overload implementation [misc]
2119
overloads_definitions.py:135: error: @final should be applied only to overload implementation [misc]

conformance/results/mypy/overloads_definitions_stub.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Lines 143, 147, 149: Expected error (tag 'override_impl')
99
output = """
1010
overloads_definitions_stub.pyi:13: error: Single overload definition, multiple required [misc]
1111
overloads_definitions_stub.pyi:32: error: Overload does not consistently use the "@staticmethod" decorator on all function signatures. [misc]
12-
overloads_definitions_stub.pyi:33: error: Self argument missing for a non-static method (or an invalid type for self) [misc]
1312
overloads_definitions_stub.pyi:39: error: Overload does not consistently use the "@classmethod" decorator on all function signatures. [misc]
1413
overloads_definitions_stub.pyi:71: error: In a stub file @final must be applied only to the first overload [misc]
1514
overloads_definitions_stub.pyi:84: error: In a stub file @final must be applied only to the first overload [misc]

conformance/results/mypy/tuples_type_compat.toml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,29 @@ tuples_type_compat.py:32: error: Incompatible types in assignment (expression ha
99
tuples_type_compat.py:33: error: Incompatible types in assignment (expression has type "tuple[int, ...]", variable has type "tuple[int]") [assignment]
1010
tuples_type_compat.py:43: error: Incompatible types in assignment (expression has type "tuple[int, ...]", variable has type "tuple[int]") [assignment]
1111
tuples_type_compat.py:62: error: Incompatible types in assignment (expression has type "tuple[int, ...]", variable has type "tuple[int, int]") [assignment]
12-
tuples_type_compat.py:95: error: Expression is of type "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]", not "tuple[int]" [assert-type]
13-
tuples_type_compat.py:99: error: Expression is of type "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]", not "tuple[str, str] | tuple[int, int]" [assert-type]
14-
tuples_type_compat.py:103: error: Expression is of type "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]", not "tuple[int, str, int]" [assert-type]
15-
tuples_type_compat.py:136: error: Expression is of type "Sequence[object]", not "Sequence[complex | list[int]]" [assert-type]
16-
tuples_type_compat.py:139: error: Expression is of type "Sequence[object]", not "Sequence[int | str]" [assert-type]
17-
tuples_type_compat.py:144: error: Incompatible types in assignment (expression has type "tuple[int, str, str]", variable has type "tuple[int, str]") [assignment]
18-
tuples_type_compat.py:149: error: Incompatible types in assignment (expression has type "tuple[int, int, str]", variable has type "tuple[int, *tuple[str, ...]]") [assignment]
19-
tuples_type_compat.py:150: error: Incompatible types in assignment (expression has type "tuple[int, str, int]", variable has type "tuple[int, *tuple[str, ...]]") [assignment]
20-
tuples_type_compat.py:156: error: Incompatible types in assignment (expression has type "tuple[int, str, str]", variable has type "tuple[int, *tuple[str, ...], int]") [assignment]
21-
tuples_type_compat.py:157: error: Incompatible types in assignment (expression has type "tuple[int, str, str, float]", variable has type "tuple[int, *tuple[str, ...], int]") [assignment]
22-
tuples_type_compat.py:162: error: Incompatible types in assignment (expression has type "tuple[int, str, int]", variable has type "tuple[*tuple[str, ...], int]") [assignment]
23-
tuples_type_compat.py:163: error: Incompatible types in assignment (expression has type "tuple[str, str, float]", variable has type "tuple[*tuple[str, ...], int]") [assignment]
24-
tuples_type_compat.py:168: error: Incompatible types in assignment (expression has type "tuple[str, str]", variable has type "tuple[str, str, int]") [assignment]
25-
tuples_type_compat.py:171: error: Incompatible types in assignment (expression has type "tuple[str, str]", variable has type "tuple[str, str, str, *tuple[str, ...]]") [assignment]
26-
tuples_type_compat.py:175: error: Incompatible types in assignment (expression has type "tuple[str, str]", variable has type "tuple[*tuple[str, ...], str, str, str]") [assignment]
12+
tuples_type_compat.py:76: error: Expression is of type "tuple[int]", not "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]" [assert-type]
13+
tuples_type_compat.py:81: error: Expression is of type "tuple[str, str] | tuple[int, int]", not "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]" [assert-type]
14+
tuples_type_compat.py:86: error: Expression is of type "tuple[int, str, int]", not "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]" [assert-type]
15+
tuples_type_compat.py:101: error: Expression is of type "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]", not "tuple[int]" [assert-type]
16+
tuples_type_compat.py:106: error: Expression is of type "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]", not "tuple[str, str] | tuple[int, int]" [assert-type]
17+
tuples_type_compat.py:111: error: Expression is of type "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]", not "tuple[int, str, int]" [assert-type]
18+
tuples_type_compat.py:127: error: Expression is of type "tuple[int | str, str]", not "tuple[int | str, int | str]" [assert-type]
19+
tuples_type_compat.py:130: error: Expression is of type "tuple[int | str, int]", not "tuple[int | str, int | str]" [assert-type]
20+
tuples_type_compat.py:149: error: Expression is of type "Sequence[object]", not "Sequence[complex | list[int]]" [assert-type]
21+
tuples_type_compat.py:152: error: Expression is of type "Sequence[object]", not "Sequence[int | str]" [assert-type]
22+
tuples_type_compat.py:157: error: Incompatible types in assignment (expression has type "tuple[int, str, str]", variable has type "tuple[int, str]") [assignment]
23+
tuples_type_compat.py:162: error: Incompatible types in assignment (expression has type "tuple[int, int, str]", variable has type "tuple[int, *tuple[str, ...]]") [assignment]
24+
tuples_type_compat.py:163: error: Incompatible types in assignment (expression has type "tuple[int, str, int]", variable has type "tuple[int, *tuple[str, ...]]") [assignment]
25+
tuples_type_compat.py:169: error: Incompatible types in assignment (expression has type "tuple[int, str, str]", variable has type "tuple[int, *tuple[str, ...], int]") [assignment]
26+
tuples_type_compat.py:170: error: Incompatible types in assignment (expression has type "tuple[int, str, str, float]", variable has type "tuple[int, *tuple[str, ...], int]") [assignment]
27+
tuples_type_compat.py:175: error: Incompatible types in assignment (expression has type "tuple[int, str, int]", variable has type "tuple[*tuple[str, ...], int]") [assignment]
28+
tuples_type_compat.py:176: error: Incompatible types in assignment (expression has type "tuple[str, str, float]", variable has type "tuple[*tuple[str, ...], int]") [assignment]
29+
tuples_type_compat.py:181: error: Incompatible types in assignment (expression has type "tuple[str, str]", variable has type "tuple[str, str, int]") [assignment]
30+
tuples_type_compat.py:184: error: Incompatible types in assignment (expression has type "tuple[str, str]", variable has type "tuple[str, str, str, *tuple[str, ...]]") [assignment]
31+
tuples_type_compat.py:188: error: Incompatible types in assignment (expression has type "tuple[str, str]", variable has type "tuple[*tuple[str, ...], str, str, str]") [assignment]
2732
"""
2833
conformance_automated = "Fail"
2934
errors_diff = """
30-
Line 95: Unexpected errors ['tuples_type_compat.py:95: error: Expression is of type "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]", not "tuple[int]" [assert-type]']
31-
Line 99: Unexpected errors ['tuples_type_compat.py:99: error: Expression is of type "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]", not "tuple[str, str] | tuple[int, int]" [assert-type]']
32-
Line 103: Unexpected errors ['tuples_type_compat.py:103: error: Expression is of type "tuple[int] | tuple[str, str] | tuple[int, *tuple[str, ...], int]", not "tuple[int, str, int]" [assert-type]']
33-
Line 136: Unexpected errors ['tuples_type_compat.py:136: error: Expression is of type "Sequence[object]", not "Sequence[complex | list[int]]" [assert-type]']
34-
Line 139: Unexpected errors ['tuples_type_compat.py:139: error: Expression is of type "Sequence[object]", not "Sequence[int | str]" [assert-type]']
35+
Line 149: Unexpected errors ['tuples_type_compat.py:149: error: Expression is of type "Sequence[object]", not "Sequence[complex | list[int]]" [assert-type]']
36+
Line 152: Unexpected errors ['tuples_type_compat.py:152: error: Expression is of type "Sequence[object]", not "Sequence[int | str]" [assert-type]']
3537
"""

conformance/results/mypy/version.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "mypy 1.15.0"
2-
test_duration = 2.3
2+
test_duration = 1.8

conformance/results/pyre/overloads_definitions.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ Does not allow an overload with no implementation in a Protocol or an abstract b
55
Expects @final/@override on all overloads and implementation, instead of implementation only.
66
"""
77
errors_diff = """
8-
Lines 135, 137, 142: Expected error (tag 'invalid_final_2')
9-
Lines 220, 222, 226: Expected error (tag 'override_impl')
8+
Lines 71, 73, 78, 81: Expected exactly one error (tag 'func5')
9+
Lines 135, 136, 137, 141, 142: Expected error (tag 'invalid_final_2')
10+
Lines 220, 221, 222, 225, 226: Expected error (tag 'override_impl')
1011
Line 40: Unexpected errors ['overloads_definitions.py:40:4 Missing overload implementation [42]: Overloaded function `MyProto.func3` must have an implementation.']
1112
Line 49: Unexpected errors ['overloads_definitions.py:49:4 Missing overload implementation [42]: Overloaded function `MyAbstractBase.func4` must have an implementation.']
13+
Line 73: Unexpected errors ['overloads_definitions.py:73:4 Incompatible overload [43]: The implementation of `C.func5` does not accept all possible arguments of overload defined on line `73`.']
14+
Line 78: Unexpected errors ['overloads_definitions.py:78:4 Incompatible overload [43]: The implementation of `C.func5` does not accept all possible arguments of overload defined on line `78`.']
15+
Line 81: Unexpected errors ['overloads_definitions.py:81:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).']
1216
Line 117: Unexpected errors ['overloads_definitions.py:117:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).']
1317
Line 215: Unexpected errors ['overloads_definitions.py:215:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).']
1418
"""

0 commit comments

Comments
 (0)