Improve Step 5 of overload call evaluation. by rchen152 · Pull Request #2250 · python/typing · GitHub
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions conformance/results/mypy/overloads_evaluation.toml
14 changes: 13 additions & 1 deletion conformance/results/pycroscope/overloads_evaluation.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
conformance_automated = "Pass"
conformance_automated = "Fail"
errors_diff = """
Line 371: Unexpected errors ['./overloads_evaluation.py:371:16: Any[multiple_overload_matches] is not equivalent to bool']
Line 400: Unexpected errors ['./overloads_evaluation.py:400:16: Any[multiple_overload_matches] is not equivalent to bool']
Line 420: Unexpected errors ['./overloads_evaluation.py:420:16: Any[multiple_overload_matches] is not equivalent to bool']
Line 439: Unexpected errors ['./overloads_evaluation.py:439:16: Any[multiple_overload_matches] is not equivalent to bool']
Line 441: Unexpected errors ['./overloads_evaluation.py:441:16: Any[multiple_overload_matches] is not equivalent to bool']
Line 468: Unexpected errors ['./overloads_evaluation.py:468:16: Any[multiple_overload_matches] is not equivalent to ./overloads_evaluation.py.A[Any[explicit]]']
"""
output = """
./overloads_evaluation.py:38:0: Cannot call overloaded function [incompatible_call]
./overloads_evaluation.py:46:0: Cannot call overloaded function [incompatible_argument]
./overloads_evaluation.py:51:0: Cannot call overloaded function [incompatible_argument]
./overloads_evaluation.py:116:4: Cannot call overloaded function [incompatible_argument]
./overloads_evaluation.py:371:16: Any[multiple_overload_matches] is not equivalent to bool
./overloads_evaluation.py:400:16: Any[multiple_overload_matches] is not equivalent to bool
./overloads_evaluation.py:420:16: Any[multiple_overload_matches] is not equivalent to bool
./overloads_evaluation.py:439:16: Any[multiple_overload_matches] is not equivalent to bool
./overloads_evaluation.py:441:16: Any[multiple_overload_matches] is not equivalent to bool
./overloads_evaluation.py:468:16: Any[multiple_overload_matches] is not equivalent to ./overloads_evaluation.py.A[Any[explicit]]
"""
4 changes: 3 additions & 1 deletion conformance/results/pyrefly/overloads_evaluation.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
conformant = "Pass"
conformance_automated = "Pass"
conformance_automated = "Fail"
errors_diff = """
Line 395: Unexpected errors ['assert_type(int, Any) failed [assert-type]']
"""
output = """
ERROR overloads_evaluation.py:38:11-13: No matching overload found for function `example1_1` called with arguments: () [no-matching-overload]
ERROR overloads_evaluation.py:46:15-16: Argument `Literal[1]` is not assignable to parameter `y` with type `str` in function `example1_1` [bad-argument-type]
ERROR overloads_evaluation.py:51:12-13: Argument `Literal[1]` is not assignable to parameter `x` with type `str` in function `example1_1` [bad-argument-type]
ERROR overloads_evaluation.py:116:13-22: No matching overload found for function `example2` called with arguments: (int | str, int | str, Literal[1]) [no-matching-overload]
ERROR overloads_evaluation.py:395:16-27: assert_type(int, Any) failed [assert-type]
"""
13 changes: 11 additions & 2 deletions conformance/results/pyright/overloads_evaluation.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
conformant = "Partial"
notes = """
<<<<<<< HEAD
Does not evaluate Any in some cases where overload is ambiguous.
Picks first overload instead of most general return type in some cases where overload is ambiguous.
=======
Does not evaluate `Any` in some cases where overload is ambiguous.
>>>>>>> main
"""
conformance_automated = "Fail"
errors_diff = """
Line 281: Unexpected errors ['overloads_evaluation.py:281:17 - error: "assert_type" mismatch: expected "Any" but received "list[int]" (reportAssertTypeFailure)']
Line 284: Unexpected errors ['overloads_evaluation.py:284:17 - error: "assert_type" mismatch: expected "Any" but received "list[int]" (reportAssertTypeFailure)']
Line 395: Unexpected errors ['overloads_evaluation.py:395:17 - error: "assert_type" mismatch: expected "Any" but received "int" (reportAssertTypeFailure)']
Line 468: Unexpected errors ['overloads_evaluation.py:468:17 - error: "assert_type" mismatch: expected "A[Any]" but received "A[None]" (reportAssertTypeFailure)']
"""
output = """
overloads_evaluation.py:38:1 - error: No overloads for "example1_1" match the provided arguments
Expand All @@ -20,5 +27,7 @@ overloads_evaluation.py:116:14 - error: Argument of type "int | str" cannot be a
overloads_evaluation.py:116:17 - error: Argument of type "int | str" cannot be assigned to parameter "y" of type "int" in function "example2"
  Type "int | str" is not assignable to type "int"
    "str" is not assignable to "int" (reportArgumentType)
overloads_evaluation.py:281:17 - error: "assert_type" mismatch: expected "Any" but received "list[int]" (reportAssertTypeFailure)
overloads_evaluation.py:284:17 - error: "assert_type" mismatch: expected "Any" but received "list[int]" (reportAssertTypeFailure)
overloads_evaluation.py:395:17 - error: "assert_type" mismatch: expected "Any" but received "int" (reportAssertTypeFailure)
overloads_evaluation.py:468:17 - error: "assert_type" mismatch: expected "A[Any]" but received "A[None]" (reportAssertTypeFailure)
"""
68 changes: 59 additions & 9 deletions conformance/results/results.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion conformance/results/ty/overloads_evaluation.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
conformance_automated = "Pass"
conformant = "Partial"
notes = """
Returns Any instead of most general return type for ambiguous calls.
"""
conformance_automated = "Fail"
errors_diff = """
Line 468: Unexpected errors ['overloads_evaluation.py:468:5: error[type-assertion-failure] Type `Unknown` does not match asserted type `A[Any]`']
"""
output = """
overloads_evaluation.py:38:1: error[no-matching-overload] No overload of function `example1_1` matches arguments
overloads_evaluation.py:46:15: error[invalid-argument-type] Argument to function `example1_1` is incorrect: Expected `str`, found `Literal[1]`
overloads_evaluation.py:51:12: error[invalid-argument-type] Argument to function `example1_1` is incorrect: Expected `str`, found `Literal[1]`
overloads_evaluation.py:116:5: error[no-matching-overload] No overload of function `example2` matches arguments
overloads_evaluation.py:468:5: error[type-assertion-failure] Type `Unknown` does not match asserted type `A[Any]`
"""
11 changes: 10 additions & 1 deletion conformance/results/zuban/overloads_evaluation.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
conformance_automated = "Pass"
conformant = "Partial"
notes = """
Does not handle unpacked arguments when checking for parameter type equivalence.
Returns Any instead of most general return type for ambiguous calls.
"""
conformance_automated = "Fail"
errors_diff = """
Line 439: Unexpected errors ['overloads_evaluation.py:439: error: Expression is of type "Any", not "bool" [misc]']
Line 468: Unexpected errors ['overloads_evaluation.py:468: error: Expression is of type "Any", not "A[Any]" [misc]']
"""
output = """
overloads_evaluation.py:38: error: All overload variants of "example1_1" require at least one argument [call-overload]
Expand All @@ -16,4 +23,6 @@ overloads_evaluation.py:51: note: def example1_1(x: int, y: str) -> int
overloads_evaluation.py:51: note: def example1_1(x: str) -> str
overloads_evaluation.py:116: error: Argument 1 to "example2" has incompatible type "int | str"; expected "int" [arg-type]
overloads_evaluation.py:116: error: Argument 2 to "example2" has incompatible type "int | str"; expected "str" [arg-type]
overloads_evaluation.py:439: error: Expression is of type "Any", not "bool" [misc]
overloads_evaluation.py:468: error: Expression is of type "Any", not "A[Any]" [misc]
"""
129 changes: 125 additions & 4 deletions conformance/tests/overloads_evaluation.py
Loading
Loading