Skip to content

Commit 8d74622

Browse files
committed
Allow Mypy/Zuban to ignore specific error codes
This was the proposal of what Rebecca proposed in https://discuss.python.org/t/allow-type-ignore-mypy-style-error-codes-in-conformance-tests/105433/5
1 parent dece44f commit 8d74622

10 files changed

+18
-38
lines changed

conformance/results/mypy/directives_type_ignore.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ Does not honor "# type: ignore" comment if comment includes additional text.
55
output = """
66
directives_type_ignore.py:11: error: Invalid "type: ignore" comment [syntax]
77
directives_type_ignore.py:11: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]
8-
directives_type_ignore.py:14: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]
9-
directives_type_ignore.py:14: note: Error code "assignment" not covered by "type: ignore" comment
108
"""
119
conformance_automated = "Fail"
1210
errors_diff = """
1311
Line 11: Unexpected errors ['directives_type_ignore.py:11: error: Invalid "type: ignore" comment [syntax]', 'directives_type_ignore.py:11: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]']
14-
Line 14: Unexpected errors ['directives_type_ignore.py:14: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]']
1512
"""

conformance/results/results.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ <h3>Python Type System Conformance Test Results</h3>
162162
</th>
163163
<th class='tc-header'><div class='tc-name'>pyright 1.1.407</div>
164164
</th>
165-
<th class='tc-header'><div class='tc-name'>zuban 0.4.1</div>
165+
<th class='tc-header'><div class='tc-name'>zuban 0.4.2</div>
166166
</th>
167167
<th class='tc-header'><div class='tc-name'>pyrefly 0.46.1</div>
168168
</th>
@@ -353,7 +353,7 @@ <h3>Python Type System Conformance Test Results</h3>
353353
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;generics_type_erasure</th>
354354
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Infers Node[Never] instead of Node[Any] when argument is not provided.</p><p>False negative on instance attribute access on type(node).</p></span></div></th>
355355
<th class="column col2 conformant">Pass</th>
356-
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Infers Node[Never] instead of Node[Any] when argument is not provided.</p></span></div></th>
356+
<th class="column col2 conformant">Pass</th>
357357
<th class="column col2 conformant">Pass</th>
358358
</tr>
359359
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;generics_typevartuple_args</th>
@@ -1031,7 +1031,7 @@ <h3>Python Type System Conformance Test Results</h3>
10311031
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;directives_type_ignore</th>
10321032
<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>
10331033
<th class="column col2 conformant">Pass</th>
1034-
<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>
1034+
<th class="column col2 conformant">Pass</th>
10351035
<th class="column col2 conformant">Pass</th>
10361036
</tr>
10371037
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;directives_type_ignore_file1</th>

conformance/results/zuban/classes_classvar.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ classes_classvar.py:40: error: Name "var" is not defined [name-defined]
88
classes_classvar.py:45: error: ClassVar cannot contain type variables [misc]
99
classes_classvar.py:46: error: ClassVar cannot contain type variables [misc]
1010
classes_classvar.py:47: error: ClassVar cannot contain type variables [misc]
11-
classes_classvar.py:52: error: Incompatible types in assignment (expression has type "dict[Never, Never]", variable has type "list[str]") [assignment]
11+
classes_classvar.py:52: error: Incompatible types in assignment (expression has type "dict[Any, Any]", variable has type "list[str]") [assignment]
1212
classes_classvar.py:54: error: Variable should not be annotated with both ClassVar and Final [misc]
1313
classes_classvar.py:55: error: Invalid Type: ClassVar nested inside other type [misc]
1414
classes_classvar.py:66: error: Type in ClassVar[...] can only be omitted if there is an initializer [misc]

conformance/results/zuban/constructors_call_init.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ errors_diff = """
33
"""
44
output = """
55
constructors_call_init.py:21: error: Argument 1 to "Class1" has incompatible type "float"; expected "int" [arg-type]
6-
constructors_call_init.py:42: error: Argument 1 to "Class3" has incompatible type "Class2[Never]"; expected "Self | None" [arg-type]
6+
constructors_call_init.py:42: error: Argument 1 to "Class3" has incompatible type "Class2[Any]"; expected "Self | None" [arg-type]
77
constructors_call_init.py:56: error: Invalid self type in __init__ [call-arg]
8-
constructors_call_init.py:107: error: The type of self "T1" has type vars in non standard potisions for class "Class8" [misc]
9-
constructors_call_init.py:107: error: The type of self "T2" has type vars in non standard potisions for class "Class8" [misc]
8+
constructors_call_init.py:107: error: The type of self "T1" has type vars in non standard positions for class "Class8" [misc]
9+
constructors_call_init.py:107: error: The type of self "T2" has type vars in non standard positions for class "Class8" [misc]
1010
constructors_call_init.py:130: error: Too many arguments for "Class11" [call-arg]
1111
"""
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
conformant = "Partial"
2-
notes = """
3-
Does not honor "# type: ignore" comment if comment includes additional text.
4-
"""
5-
conformance_automated = "Fail"
1+
conformance_automated = "Pass"
62
errors_diff = """
7-
Line 11: Unexpected errors ['directives_type_ignore.py:11: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]']
8-
Line 14: Unexpected errors ['directives_type_ignore.py:14: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]']
93
"""
104
output = """
11-
directives_type_ignore.py:11: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]
12-
directives_type_ignore.py:14: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]
13-
directives_type_ignore.py:14: note: Error code "assignment" not covered by "type: ignore" comment
145
"""

conformance/results/zuban/generics_type_erasure.toml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
conformant = "Partial"
2-
notes = """
3-
Infers Node[Never] instead of Node[Any] when argument is not provided.
4-
"""
5-
conformance_automated = "Fail"
1+
conformance_automated = "Pass"
62
errors_diff = """
7-
Line 19: Unexpected errors ['generics_type_erasure.py:19: error: Expression is of type "Node[Never]", not "Node[Any]" [misc]']
8-
Line 22: Unexpected errors ['generics_type_erasure.py:22: error: Expression is of type "Never", not "Any" [misc]']
93
"""
104
output = """
11-
generics_type_erasure.py:19: error: Expression is of type "Node[Never]", not "Node[Any]" [misc]
12-
generics_type_erasure.py:22: error: Expression is of type "Never", not "Any" [misc]
135
generics_type_erasure.py:38: error: Argument 1 to "Node" has incompatible type "str"; expected "int | None" [arg-type]
146
generics_type_erasure.py:40: error: Argument 1 to "Node" has incompatible type "int"; expected "str | None" [arg-type]
157
generics_type_erasure.py:42: error: Access to generic instance variables via class is ambiguous [misc]

conformance/results/zuban/generics_typevartuple_specialization.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ output = """
55
generics_typevartuple_specialization.py:109: error: Unpack is only valid in a variadic position [misc]
66
generics_typevartuple_specialization.py:109: error: TypeVarTuple "Ts" is unbound [misc]
77
generics_typevartuple_specialization.py:110: error: Unpack is only valid in a variadic position [misc]
8-
generics_typevartuple_specialization.py:121: error: More than one Unpack in a type is not allowed [misc]
9-
generics_typevartuple_specialization.py:122: error: More than one Unpack in a type is not allowed [misc]
8+
generics_typevartuple_specialization.py:121: error: More than one variadic Unpack in a type is not allowed [misc]
9+
generics_typevartuple_specialization.py:122: error: More than one variadic Unpack in a type is not allowed [misc]
1010
generics_typevartuple_specialization.py:127: error: Bad number of arguments for type alias, expected at least 2, given 2 [misc]
1111
generics_typevartuple_specialization.py:163: error: TypeVarTuple cannot be split [misc]
1212
"""

conformance/results/zuban/tuples_unpacked.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ conformance_automated = "Pass"
22
errors_diff = """
33
"""
44
output = """
5-
tuples_unpacked.py:40: error: More than one Unpack in a type is not allowed [misc]
6-
tuples_unpacked.py:41: error: More than one Unpack in a type is not allowed [misc]
7-
tuples_unpacked.py:51: error: More than one Unpack in a type is not allowed [misc]
8-
tuples_unpacked.py:59: error: More than one Unpack in a type is not allowed [misc]
9-
tuples_unpacked.py:61: error: More than one Unpack in a type is not allowed [misc]
5+
tuples_unpacked.py:40: error: More than one variadic Unpack in a type is not allowed [misc]
6+
tuples_unpacked.py:41: error: More than one variadic Unpack in a type is not allowed [misc]
7+
tuples_unpacked.py:51: error: More than one variadic Unpack in a type is not allowed [misc]
8+
tuples_unpacked.py:59: error: More than one variadic Unpack in a type is not allowed [misc]
9+
tuples_unpacked.py:61: error: More than one variadic Unpack in a type is not allowed [misc]
1010
"""
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "zuban 0.4.1"
1+
version = "zuban 0.4.2"

conformance/tests/directives_type_ignore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
y: int = "" # type: ignore - additional stuff
1212

1313
# The following type violation should be suppressed.
14-
z: int = "" # type: ignore[additional_stuff]
14+
z: int = "" # type: ignore[assignment]
1515

1616
# > In some cases, linting tools or other comments may be needed on the same
1717
# > line as a type comment. In these cases, the type comment should be before

0 commit comments

Comments
 (0)