Skip to content

Commit 98f36e8

Browse files
committed
improve variadic test to not use overlapping overloads
1 parent 5d22e8d commit 98f36e8

File tree

9 files changed

+24
-15
lines changed

9 files changed

+24
-15
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "mypy 1.14.1"
2-
test_duration = 1.8
2+
test_duration = 1.7

conformance/results/pyre/overloads_evaluation.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Line 147: Unexpected errors ['overloads_evaluation.py:147:29 Incompatible parame
1919
Line 148: Unexpected errors ['overloads_evaluation.py:148:4 Assert type [70]: Expected `Union[int, str]` but got `int`.']
2020
Line 169: Unexpected errors ['overloads_evaluation.py:169:24 Incompatible parameter type [6]: In call `expand_tuple`, for 1st positional argument, expected `Tuple[int, int]` but got `Tuple[int, Union[int, str]]`.']
2121
Line 170: Unexpected errors ['overloads_evaluation.py:170:4 Assert type [70]: Expected `Union[int, str]` but got `int`.']
22-
Line 196: Unexpected errors ['overloads_evaluation.py:196:4 Assert type [70]: Expected `int` but got `typing_extensions.Literal[0]`.']
22+
Line 196: Unexpected errors ['overloads_evaluation.py:196:4 Assert type [70]: Expected `int` but got `str`.']
2323
Line 224: Unexpected errors ['overloads_evaluation.py:224:4 Assert type [70]: Expected `typing.Any` but got `int`.']
2424
"""
2525
output = """
@@ -38,6 +38,6 @@ overloads_evaluation.py:147:29 Incompatible parameter type [6]: In call `expand_
3838
overloads_evaluation.py:148:4 Assert type [70]: Expected `Union[int, str]` but got `int`.
3939
overloads_evaluation.py:169:24 Incompatible parameter type [6]: In call `expand_tuple`, for 1st positional argument, expected `Tuple[int, int]` but got `Tuple[int, Union[int, str]]`.
4040
overloads_evaluation.py:170:4 Assert type [70]: Expected `Union[int, str]` but got `int`.
41-
overloads_evaluation.py:196:4 Assert type [70]: Expected `int` but got `typing_extensions.Literal[0]`.
41+
overloads_evaluation.py:196:4 Assert type [70]: Expected `int` but got `str`.
4242
overloads_evaluation.py:224:4 Assert type [70]: Expected `typing.Any` but got `int`.
4343
"""
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "pyre 0.9.23"
2-
test_duration = 6.7
2+
test_duration = 6.0

conformance/results/pyright/overloads_evaluation.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ notes = """
33
Does not expand boolean arguments to Literal[True] and Literal[False].
44
Does not expand enum arguments to literal variants.
55
Does not expand tuple arguments to possible combinations.
6+
Does not prefer variadic match to indeterminate-length unpacked argument.
67
"""
78
conformance_automated = "Fail"
89
errors_diff = """
@@ -12,6 +13,7 @@ Line 129: Unexpected errors ['overloads_evaluation.py:129:12 - error: No overloa
1213
Line 130: Unexpected errors ['overloads_evaluation.py:130:17 - error: "assert_type" mismatch: expected "Literal[0, 1]" but received "Unknown" (reportAssertTypeFailure)']
1314
Line 169: Unexpected errors ['overloads_evaluation.py:169:12 - error: No overloads for "expand_tuple" match the provided arguments (reportCallIssue)', 'overloads_evaluation.py:169:29 - error: Argument of type "tuple[Literal[1], int | str]" cannot be assigned to parameter "x" of type "tuple[int, str]" in function "expand_tuple"']
1415
Line 170: Unexpected errors ['overloads_evaluation.py:170:17 - error: "assert_type" mismatch: expected "int | str" but received "Unknown" (reportAssertTypeFailure)']
16+
Line 196: Unexpected errors ['overloads_evaluation.py:196:17 - error: "assert_type" mismatch: expected "int" but received "str" (reportAssertTypeFailure)']
1517
"""
1618
output = """
1719
overloads_evaluation.py:32:1 - error: No overloads for "example1" match the provided arguments
@@ -40,4 +42,5 @@ overloads_evaluation.py:169:29 - error: Argument of type "tuple[Literal[1], int
4042
  Type "int | str" is not assignable to type "str"
4143
    "int" is not assignable to "str" (reportArgumentType)
4244
overloads_evaluation.py:170:17 - error: "assert_type" mismatch: expected "int | str" but received "Unknown" (reportAssertTypeFailure)
45+
overloads_evaluation.py:196:17 - error: "assert_type" mismatch: expected "int" but received "str" (reportAssertTypeFailure)
4346
"""
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "pyright 1.1.391"
2-
test_duration = 1.7
2+
test_duration = 1.5

conformance/results/pytype/overloads_evaluation.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
conformant = "Partial"
22
notes = """
3-
Does not pick a winning overload based on arity, prior to considering argument types.
43
Does not perform argument expansion (on any types) when matching overloads.
54
Does not treat multiple matches due to gradual types as ambiguous.
5+
Does not prefer variadic match to indeterminate-length unpacked argument.
66
"""
77
conformance_automated = "Fail"
88
errors_diff = """
@@ -21,6 +21,7 @@ Line 148: Unexpected errors ['overloads_evaluation.py:148:5: \\x1b[1m\\x1b[31mer
2121
Line 166: Unexpected errors ['overloads_evaluation.py:166:12: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in expand_tuple: bad return type [bad-return-type]']
2222
Line 170: Unexpected errors ['overloads_evaluation.py:170:5: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in check_expand_tuple: int [assert-type]']
2323
Line 188: Unexpected errors ['overloads_evaluation.py:188:12: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in variadic: bad return type [bad-return-type]']
24+
Line 196: Unexpected errors ['overloads_evaluation.py:196:5: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in check_variadic: str [assert-type]']
2425
Line 217: Unexpected errors ['overloads_evaluation.py:217:12: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in example4: bad return type [bad-return-type]']
2526
Line 224: Unexpected errors ['overloads_evaluation.py:224:5: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in check_example4: int [assert-type]']
2627
"""
@@ -117,6 +118,11 @@ overloads_evaluation.py:188:12: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in
117118
return 1
118119
\u001b[1m\u001b[31m~\u001b[39m\u001b[0m
119120
121+
overloads_evaluation.py:196:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in check_variadic: str [assert-type]
122+
123+
assert_type(ret1, int)
124+
\u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m
125+
120126
overloads_evaluation.py:217:12: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in example4: bad return type [bad-return-type]
121127
122128
return 1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version = "pytype 2024.10.11"
2-
test_duration = 31.1
2+
test_duration = 30.8

conformance/results/results.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,16 @@ <h3>Python Type System Conformance Test Results</h3>
159159
<div class="table_container"><table><tbody>
160160
<tr><th class="col1">&nbsp;</th>
161161
<th class='tc-header'><div class='tc-name'>mypy 1.14.1</div>
162-
<div class='tc-time'>1.8sec</div>
162+
<div class='tc-time'>1.7sec</div>
163163
</th>
164164
<th class='tc-header'><div class='tc-name'>pyright 1.1.391</div>
165-
<div class='tc-time'>1.7sec</div>
165+
<div class='tc-time'>1.5sec</div>
166166
</th>
167167
<th class='tc-header'><div class='tc-name'>pyre 0.9.23</div>
168-
<div class='tc-time'>6.7sec</div>
168+
<div class='tc-time'>6.0sec</div>
169169
</th>
170170
<th class='tc-header'><div class='tc-name'>pytype 2024.10.11</div>
171-
<div class='tc-time'>31.1sec</div>
171+
<div class='tc-time'>30.8sec</div>
172172
</th>
173173
</tr>
174174
<tr><th class="column" colspan="5">
@@ -692,9 +692,9 @@ <h3>Python Type System Conformance Test Results</h3>
692692
</tr>
693693
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;overloads_evaluation</th>
694694
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Does not expand boolean arguments to Literal[True] and Literal[False].</p><p>Does not expand enum arguments to literal variants.</p><p>Does not expand tuple arguments to possible combinations.</p></span></div></th>
695-
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Does not expand boolean arguments to Literal[True] and Literal[False].</p><p>Does not expand enum arguments to literal variants.</p><p>Does not expand tuple arguments to possible combinations.</p></span></div></th>
695+
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Does not expand boolean arguments to Literal[True] and Literal[False].</p><p>Does not expand enum arguments to literal variants.</p><p>Does not expand tuple arguments to possible combinations.</p><p>Does not prefer variadic match to indeterminate-length unpacked argument.</p></span></div></th>
696696
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Does not expand boolean arguments to Literal[True] and Literal[False].</p><p>Does not expand enum arguments to literal variants.</p><p>Does not expand type[A | B] to type[A] and type[B].</p><p>Does not expand tuple arguments to possible combinations.</p><p>Does not prefer variadic match to indeterminate-length unpacked argument.</p><p>Does not treat multiple matches due to gradual types as ambiguous.</p></span></div></th>
697-
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Does not pick a winning overload based on arity, prior to considering argument types.</p><p>Does not perform argument expansion (on any types) when matching overloads.</p><p>Does not treat multiple matches due to gradual types as ambiguous.</p></span></div></th>
697+
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Does not perform argument expansion (on any types) when matching overloads.</p><p>Does not treat multiple matches due to gradual types as ambiguous.</p><p>Does not prefer variadic match to indeterminate-length unpacked argument.</p></span></div></th>
698698
</tr>
699699
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;overloads_overlap</th>
700700
<th class="column col2 conformant">Pass</th>

conformance/tests/overloads_evaluation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ def check_expand_tuple(v: int | str) -> None:
177177
# > If so, eliminate overloads that do not have a variadic parameter.
178178

179179
@overload
180-
def variadic(x: int, /) -> Literal[0]:
180+
def variadic(x: int, /) -> str:
181181
...
182182

183183
@overload
184-
def variadic(*args: int) -> int:
184+
def variadic(x: int, y: int, /, *args: int) -> int:
185185
...
186186

187187
def variadic(*args: int) -> int | str:

0 commit comments

Comments
 (0)