Skip to content

Commit 2c466d4

Browse files
committed
Incorporated feedback from Carl's code review.
1 parent cf93e82 commit 2c466d4

File tree

7 files changed

+27
-20
lines changed

7 files changed

+27
-20
lines changed

conformance/results/mypy/overloads_evaluation.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ 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.
66
Does not evaluate Any in some cases where overload is ambiguous.
7-
Evaluates Any is some cases where overload is not ambiguous.
7+
Evaluates Any in some cases where overload is not ambiguous.
88
"""
99
conformance_automated = "Fail"
1010
errors_diff = """
@@ -16,8 +16,8 @@ Line 204: Unexpected errors ['overloads_evaluation.py:204: error: Argument 1 to
1616
Line 205: Unexpected errors ['overloads_evaluation.py:205: error: Expression is of type "int", not "int | str" [assert-type]']
1717
Line 264: Unexpected errors ['overloads_evaluation.py:264: error: Expression is of type "list[Any]", not "Any" [assert-type]']
1818
Line 280: Unexpected errors ['overloads_evaluation.py:280: error: Expression is of type "list[Any]", not "Any" [assert-type]']
19-
Line 298: Unexpected errors ['overloads_evaluation.py:298: error: Expression is of type "Any", not "float" [assert-type]']
20-
Line 336: Unexpected errors ['overloads_evaluation.py:336: error: Expression is of type "list[Any]", not "Any" [assert-type]']
19+
Line 301: Unexpected errors ['overloads_evaluation.py:301: error: Expression is of type "Any", not "float" [assert-type]']
20+
Line 345: Unexpected errors ['overloads_evaluation.py:345: error: Expression is of type "list[Any]", not "Any" [assert-type]']
2121
"""
2222
output = """
2323
overloads_evaluation.py:38: error: All overload variants of "example1_1" require at least one argument [call-overload]
@@ -48,6 +48,6 @@ overloads_evaluation.py:204: error: Argument 1 to "expand_tuple" has incompatibl
4848
overloads_evaluation.py:205: error: Expression is of type "int", not "int | str" [assert-type]
4949
overloads_evaluation.py:264: error: Expression is of type "list[Any]", not "Any" [assert-type]
5050
overloads_evaluation.py:280: error: Expression is of type "list[Any]", not "Any" [assert-type]
51-
overloads_evaluation.py:298: error: Expression is of type "Any", not "float" [assert-type]
52-
overloads_evaluation.py:336: error: Expression is of type "list[Any]", not "Any" [assert-type]
51+
overloads_evaluation.py:301: error: Expression is of type "Any", not "float" [assert-type]
52+
overloads_evaluation.py:345: error: Expression is of type "list[Any]", not "Any" [assert-type]
5353
"""

conformance/results/pyre/overloads_evaluation.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ Line 205: Unexpected errors ['overloads_evaluation.py:205:4 Assert type [70]: Ex
2222
Line 234: Unexpected errors ['overloads_evaluation.py:234:4 Assert type [70]: Expected `int` but got `str`.']
2323
Line 264: Unexpected errors ['overloads_evaluation.py:264:4 Assert type [70]: Expected `typing.Any` but got `List[int]`.']
2424
Line 280: Unexpected errors ['overloads_evaluation.py:280:4 Assert type [70]: Expected `typing.Any` but got `List[int]`.']
25-
Line 307: Unexpected errors ["overloads_evaluation.py:307:4 Assert type [70]: Expected `str` but got `typing_extensions.Literal['']`."]
26-
Line 336: Unexpected errors ['overloads_evaluation.py:336:4 Assert type [70]: Expected `typing.Any` but got `List[int]`.']
25+
Line 345: Unexpected errors ['overloads_evaluation.py:345:4 Assert type [70]: Expected `typing.Any` but got `List[int]`.']
2726
"""
2827
output = """
2928
overloads_evaluation.py:38:0 Missing argument [20]: Call `example1_1` expects argument `x`.
@@ -44,6 +43,5 @@ overloads_evaluation.py:205:4 Assert type [70]: Expected `Union[int, str]` but g
4443
overloads_evaluation.py:234:4 Assert type [70]: Expected `int` but got `str`.
4544
overloads_evaluation.py:264:4 Assert type [70]: Expected `typing.Any` but got `List[int]`.
4645
overloads_evaluation.py:280:4 Assert type [70]: Expected `typing.Any` but got `List[int]`.
47-
overloads_evaluation.py:307:4 Assert type [70]: Expected `str` but got `typing_extensions.Literal['']`.
48-
overloads_evaluation.py:336:4 Assert type [70]: Expected `typing.Any` but got `List[int]`.
46+
overloads_evaluation.py:345:4 Assert type [70]: Expected `typing.Any` but got `List[int]`.
4947
"""
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 = 7.3
2+
test_duration = 6.4

conformance/results/pytype/overloads_evaluation.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Line 234: Unexpected errors ['overloads_evaluation.py:234:5: \\x1b[1m\\x1b[31mer
2626
Line 264: Unexpected errors ['overloads_evaluation.py:264:5: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in check_example4: list[int] [assert-type]']
2727
Line 280: Unexpected errors ['overloads_evaluation.py:280:5: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in check_example5: list[int] [assert-type]']
2828
Line 291: Unexpected errors ['overloads_evaluation.py:291:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in example6: bad return type [bad-return-type]', 'overloads_evaluation.py:291:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in example6: bad return type [bad-return-type]', 'overloads_evaluation.py:291:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in example6: bad return type [bad-return-type]']
29-
Line 336: Unexpected errors ['overloads_evaluation.py:336:5: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in check_example7: list[int] [assert-type]']
29+
Line 345: Unexpected errors ['overloads_evaluation.py:345:5: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in check_example7: list[int] [assert-type]']
3030
"""
3131
output = """
3232
overloads_evaluation.py:33:12: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in example1_1: bad return type [bad-return-type]
@@ -152,20 +152,20 @@ def example6(a: float, b: T) -> T: ...
152152
\u001b[1m\u001b[31m\u001b[39m\u001b[0m
153153
154154
Called from (traceback):
155-
line 312, in check_example6
155+
line 321, in check_example6
156156
overloads_evaluation.py:291:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in example6: bad return type [bad-return-type]
157157
158158
def example6(a: float, b: T) -> T: ...
159159
\u001b[1m\u001b[31m\u001b[39m\u001b[0m
160160
161161
Called from (traceback):
162-
line 306, in check_example6
162+
line 315, in check_example6
163163
overloads_evaluation.py:291:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in example6: bad return type [bad-return-type]
164164
165165
def example6(a: float, b: T) -> T: ...
166166
\u001b[1m\u001b[31m\u001b[39m\u001b[0m
167167
168-
overloads_evaluation.py:336:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in check_example7: list[int] [assert-type]
168+
overloads_evaluation.py:345:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in check_example7: list[int] [assert-type]
169169
170170
assert_type(ret3, Any)
171171
\u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m
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 = 33.4
2+
test_duration = 32.7

conformance/results/results.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ <h3>Python Type System Conformance Test Results</h3>
165165
<div class='tc-time'>1.3sec</div>
166166
</th>
167167
<th class='tc-header'><div class='tc-name'>pyre 0.9.23</div>
168-
<div class='tc-time'>7.3sec</div>
168+
<div class='tc-time'>6.4sec</div>
169169
</th>
170170
<th class='tc-header'><div class='tc-name'>pytype 2024.10.11</div>
171-
<div class='tc-time'>33.4sec</div>
171+
<div class='tc-time'>32.7sec</div>
172172
</th>
173173
</tr>
174174
<tr><th class="column" colspan="5">
@@ -691,7 +691,7 @@ <h3>Python Type System Conformance Test Results</h3>
691691
<th class="column col2 not-conformant"><div class="hover-text">Fail<span class="tooltip-text" id="bottom"><p>Does not enforce any of the specified rules regarding overload definitions.</p></span></div></th>
692692
</tr>
693693
<tr><th class="column col1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;overloads_evaluation</th>
694-
<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 evaluate Any in some cases where overload is ambiguous.</p><p>Evaluates Any is some cases where overload is not ambiguous.</p></span></div></th>
694+
<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 evaluate Any in some cases where overload is ambiguous.</p><p>Evaluates Any in some cases where overload is not ambiguous.</p></span></div></th>
695695
<th class="column col2 partially-conformant"><div class="hover-text">Partial<span class="tooltip-text" id="bottom"><p>Does not evaluate Any in some cases where overload is ambiguous.</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>
697697
<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>

conformance/tests/overloads_evaluation.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,19 +291,28 @@ def example6(a: float, b: T) -> T: ...
291291
def example6(a: float, b: T) -> T: ...
292292

293293

294-
def check_example6(a: list, b: Any) -> None:
294+
def check_example6(a: list[Any], b: Any, c: str) -> None:
295295
m: list[int] = []
296296

297+
# All possible materializations of list[Any] are
298+
# assignable to Any, so this matches the first overload
299+
# and eliminates all subsequent overloads.
297300
v1 = example6(1, a)
298301
assert_type(v1, float)
299302

303+
# All possible materializations of Any are
304+
# assignable to Any, so this matches the first overload
305+
# and eliminates all subsequent overloads.
300306
v2 = example6(1, b)
301307
assert_type(v2, float)
302308

309+
# All possible materializations of list[int] are
310+
# assignable to Any, so this matches the first overload
311+
# and eliminates all subsequent overloads.
303312
v3 = example6(1, m)
304313
assert_type(v3, float)
305314

306-
v4 = example6(1.0, "")
315+
v4 = example6(1.0, c)
307316
assert_type(v4, str)
308317

309318
v5 = example6(1.0, b)

0 commit comments

Comments
 (0)