You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added a few more overload evaluation tests. (#1957)
* Added a few more overload evaluation tests.
These uncovered a few more cases where mypy and pyright do not conform to the standard.
* Incorporated feedback from Carl's code review.
Copy file name to clipboardExpand all lines: conformance/results/mypy/overloads_evaluation.toml
+42-32Lines changed: 42 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -3,41 +3,51 @@ notes = """
3
3
Does not expand boolean arguments to Literal[True] and Literal[False].
4
4
Does not expand enum arguments to literal variants.
5
5
Does not expand tuple arguments to possible combinations.
6
+
Does not evaluate Any in some cases where overload is ambiguous.
7
+
Evaluates Any in some cases where overload is not ambiguous.
6
8
"""
7
9
conformance_automated = "Fail"
8
10
errors_diff = """
9
-
Line 106: Unexpected errors ['overloads_evaluation.py:106: error: No overload variant of "expand_bool" matches argument type "bool" [call-overload]']
10
-
Line 107: Unexpected errors ['overloads_evaluation.py:107: error: Expression is of type "Any", not "Literal[0, 1]" [assert-type]']
11
-
Line 129: Unexpected errors ['overloads_evaluation.py:129: error: No overload variant of "expand_enum" matches argument type "Color" [call-overload]']
12
-
Line 130: Unexpected errors ['overloads_evaluation.py:130: error: Expression is of type "Any", not "Literal[0, 1]" [assert-type]']
13
-
Line 169: Unexpected errors ['overloads_evaluation.py:169: error: Argument 1 to "expand_tuple" has incompatible type "tuple[int, int | str]"; expected "tuple[int, int]" [arg-type]']
14
-
Line 170: Unexpected errors ['overloads_evaluation.py:170: error: Expression is of type "int", not "int | str" [assert-type]']
11
+
Line 134: Unexpected errors ['overloads_evaluation.py:134: error: No overload variant of "expand_bool" matches argument type "bool" [call-overload]']
12
+
Line 135: Unexpected errors ['overloads_evaluation.py:135: error: Expression is of type "Any", not "Literal[0, 1]" [assert-type]']
13
+
Line 160: Unexpected errors ['overloads_evaluation.py:160: error: No overload variant of "expand_enum" matches argument type "Color" [call-overload]']
14
+
Line 161: Unexpected errors ['overloads_evaluation.py:161: error: Expression is of type "Any", not "Literal[0, 1]" [assert-type]']
15
+
Line 204: Unexpected errors ['overloads_evaluation.py:204: error: Argument 1 to "expand_tuple" has incompatible type "tuple[int, int | str]"; expected "tuple[int, int]" [arg-type]']
16
+
Line 205: Unexpected errors ['overloads_evaluation.py:205: error: Expression is of type "int", not "int | str" [assert-type]']
17
+
Line 264: Unexpected errors ['overloads_evaluation.py:264: error: Expression is of type "list[Any]", not "Any" [assert-type]']
18
+
Line 280: Unexpected errors ['overloads_evaluation.py:280: 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]']
15
21
"""
16
22
output = """
17
-
overloads_evaluation.py:32: error: All overload variants of "example1" require at least one argument [call-overload]
18
-
overloads_evaluation.py:32: note: Possible overload variants:
19
-
overloads_evaluation.py:32: note: def example1(x: int, y: str) -> int
Copy file name to clipboardExpand all lines: conformance/results/pyre/overloads_evaluation.toml
+33-29Lines changed: 33 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -9,35 +9,39 @@ Does not treat multiple matches due to gradual types as ambiguous.
9
9
"""
10
10
conformance_automated = "Fail"
11
11
errors_diff = """
12
-
Line 81: Unexpected errors ['overloads_evaluation.py:81:23 Incompatible parameter type [6]: In call `example2`, for 2nd positional argument, expected `str` but got `Union[int, str]`.']
13
-
Line 82: Unexpected errors ['overloads_evaluation.py:82:4 Assert type [70]: Expected `Union[int, str]` but got `str`.']
14
-
Line 106: Unexpected errors ['overloads_evaluation.py:106:23 Incompatible parameter type [6]: In call `expand_bool`, for 1st positional argument, expected `typing_extensions.Literal[False]` but got `bool`.']
15
-
Line 107: Unexpected errors ['overloads_evaluation.py:107:4 Assert type [70]: Expected `Union[typing_extensions.Literal[0], typing_extensions.Literal[1]]` but got `typing_extensions.Literal[0]`.']
16
-
Line 129: Unexpected errors ['overloads_evaluation.py:129:23 Incompatible parameter type [6]: In call `expand_enum`, for 1st positional argument, expected `typing_extensions.Literal[Color.RED]` but got `Color`.']
17
-
Line 130: Unexpected errors ['overloads_evaluation.py:130:4 Assert type [70]: Expected `Union[typing_extensions.Literal[0], typing_extensions.Literal[1]]` but got `typing_extensions.Literal[0]`.']
18
-
Line 147: Unexpected errors ['overloads_evaluation.py:147:29 Incompatible parameter type [6]: In call `expand_type_union`, for 1st positional argument, expected `Type[int]` but got `Type[Union[int, str]]`.']
19
-
Line 148: Unexpected errors ['overloads_evaluation.py:148:4 Assert type [70]: Expected `Union[int, str]` but got `int`.']
20
-
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]]`.']
21
-
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 `str`.']
23
-
Line 224: Unexpected errors ['overloads_evaluation.py:224:4 Assert type [70]: Expected `typing.Any` but got `int`.']
12
+
Line 105: Unexpected errors ['overloads_evaluation.py:105:23 Incompatible parameter type [6]: In call `example2`, for 2nd positional argument, expected `str` but got `Union[int, str]`.']
13
+
Line 106: Unexpected errors ['overloads_evaluation.py:106:4 Assert type [70]: Expected `Union[int, str]` but got `str`.']
14
+
Line 134: Unexpected errors ['overloads_evaluation.py:134:23 Incompatible parameter type [6]: In call `expand_bool`, for 1st positional argument, expected `typing_extensions.Literal[False]` but got `bool`.']
15
+
Line 135: Unexpected errors ['overloads_evaluation.py:135:4 Assert type [70]: Expected `Union[typing_extensions.Literal[0], typing_extensions.Literal[1]]` but got `typing_extensions.Literal[0]`.']
16
+
Line 160: Unexpected errors ['overloads_evaluation.py:160:23 Incompatible parameter type [6]: In call `expand_enum`, for 1st positional argument, expected `typing_extensions.Literal[Color.RED]` but got `Color`.']
17
+
Line 161: Unexpected errors ['overloads_evaluation.py:161:4 Assert type [70]: Expected `Union[typing_extensions.Literal[0], typing_extensions.Literal[1]]` but got `typing_extensions.Literal[0]`.']
18
+
Line 180: Unexpected errors ['overloads_evaluation.py:180:29 Incompatible parameter type [6]: In call `expand_type_union`, for 1st positional argument, expected `Type[int]` but got `Type[Union[int, str]]`.']
19
+
Line 181: Unexpected errors ['overloads_evaluation.py:181:4 Assert type [70]: Expected `Union[int, str]` but got `int`.']
20
+
Line 204: Unexpected errors ['overloads_evaluation.py:204:24 Incompatible parameter type [6]: In call `expand_tuple`, for 1st positional argument, expected `Tuple[int, int]` but got `Tuple[int, Union[int, str]]`.']
21
+
Line 205: Unexpected errors ['overloads_evaluation.py:205:4 Assert type [70]: Expected `Union[int, str]` but got `int`.']
22
+
Line 234: Unexpected errors ['overloads_evaluation.py:234:4 Assert type [70]: Expected `int` but got `str`.']
23
+
Line 264: Unexpected errors ['overloads_evaluation.py:264:4 Assert type [70]: Expected `typing.Any` but got `List[int]`.']
24
+
Line 280: Unexpected errors ['overloads_evaluation.py:280: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]`.']
overloads_evaluation.py:40:12 Incompatible parameter type [6]: In call `example1`, for 2nd positional argument, expected `str` but got `int`.
28
-
overloads_evaluation.py:45:9 Incompatible parameter type [6]: In call `example1`, for 1st positional argument, expected `str` but got `int`.
29
-
overloads_evaluation.py:81:23 Incompatible parameter type [6]: In call `example2`, for 2nd positional argument, expected `str` but got `Union[int, str]`.
30
-
overloads_evaluation.py:82:4 Assert type [70]: Expected `Union[int, str]` but got `str`.
31
-
overloads_evaluation.py:89:13 Incompatible parameter type [6]: In call `example2`, for 1st positional argument, expected `int` but got `Union[int, str]`.
32
-
overloads_evaluation.py:89:16 Incompatible parameter type [6]: In call `example2`, for 2nd positional argument, expected `str` but got `Union[int, str]`.
33
-
overloads_evaluation.py:106:23 Incompatible parameter type [6]: In call `expand_bool`, for 1st positional argument, expected `typing_extensions.Literal[False]` but got `bool`.
34
-
overloads_evaluation.py:107:4 Assert type [70]: Expected `Union[typing_extensions.Literal[0], typing_extensions.Literal[1]]` but got `typing_extensions.Literal[0]`.
35
-
overloads_evaluation.py:129:23 Incompatible parameter type [6]: In call `expand_enum`, for 1st positional argument, expected `typing_extensions.Literal[Color.RED]` but got `Color`.
36
-
overloads_evaluation.py:130:4 Assert type [70]: Expected `Union[typing_extensions.Literal[0], typing_extensions.Literal[1]]` but got `typing_extensions.Literal[0]`.
37
-
overloads_evaluation.py:147:29 Incompatible parameter type [6]: In call `expand_type_union`, for 1st positional argument, expected `Type[int]` but got `Type[Union[int, str]]`.
38
-
overloads_evaluation.py:148:4 Assert type [70]: Expected `Union[int, str]` but got `int`.
39
-
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]]`.
40
-
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 `str`.
42
-
overloads_evaluation.py:224:4 Assert type [70]: Expected `typing.Any` but got `int`.
overloads_evaluation.py:46:14 Incompatible parameter type [6]: In call `example1_1`, for 2nd positional argument, expected `str` but got `int`.
30
+
overloads_evaluation.py:51:11 Incompatible parameter type [6]: In call `example1_1`, for 1st positional argument, expected `str` but got `int`.
31
+
overloads_evaluation.py:105:23 Incompatible parameter type [6]: In call `example2`, for 2nd positional argument, expected `str` but got `Union[int, str]`.
32
+
overloads_evaluation.py:106:4 Assert type [70]: Expected `Union[int, str]` but got `str`.
33
+
overloads_evaluation.py:115:13 Incompatible parameter type [6]: In call `example2`, for 1st positional argument, expected `int` but got `Union[int, str]`.
34
+
overloads_evaluation.py:115:16 Incompatible parameter type [6]: In call `example2`, for 2nd positional argument, expected `str` but got `Union[int, str]`.
35
+
overloads_evaluation.py:134:23 Incompatible parameter type [6]: In call `expand_bool`, for 1st positional argument, expected `typing_extensions.Literal[False]` but got `bool`.
36
+
overloads_evaluation.py:135:4 Assert type [70]: Expected `Union[typing_extensions.Literal[0], typing_extensions.Literal[1]]` but got `typing_extensions.Literal[0]`.
37
+
overloads_evaluation.py:160:23 Incompatible parameter type [6]: In call `expand_enum`, for 1st positional argument, expected `typing_extensions.Literal[Color.RED]` but got `Color`.
38
+
overloads_evaluation.py:161:4 Assert type [70]: Expected `Union[typing_extensions.Literal[0], typing_extensions.Literal[1]]` but got `typing_extensions.Literal[0]`.
39
+
overloads_evaluation.py:180:29 Incompatible parameter type [6]: In call `expand_type_union`, for 1st positional argument, expected `Type[int]` but got `Type[Union[int, str]]`.
40
+
overloads_evaluation.py:181:4 Assert type [70]: Expected `Union[int, str]` but got `int`.
41
+
overloads_evaluation.py:204:24 Incompatible parameter type [6]: In call `expand_tuple`, for 1st positional argument, expected `Tuple[int, int]` but got `Tuple[int, Union[int, str]]`.
42
+
overloads_evaluation.py:205:4 Assert type [70]: Expected `Union[int, str]` but got `int`.
43
+
overloads_evaluation.py:234:4 Assert type [70]: Expected `int` but got `str`.
44
+
overloads_evaluation.py:264:4 Assert type [70]: Expected `typing.Any` but got `List[int]`.
45
+
overloads_evaluation.py:280: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]`.
Does not evaluate Any in some cases where overload is ambiguous.
4
+
"""
5
+
conformance_automated = "Fail"
3
6
errors_diff = """
7
+
Line 280: Unexpected errors ['overloads_evaluation.py:280:17 - error: "assert_type" mismatch: expected "Any" but received "list[int]" (reportAssertTypeFailure)']
4
8
"""
5
9
output = """
6
-
overloads_evaluation.py:32:1 - error: No overloads for "example1" match the provided arguments
10
+
overloads_evaluation.py:38:1 - error: No overloads for "example1_1" match the provided arguments
7
11
Argument types: () (reportCallIssue)
8
-
overloads_evaluation.py:40:13 - error: Argument of type "Literal[1]" cannot be assigned to parameter "y" of type "str" in function "example1"
12
+
overloads_evaluation.py:46:15 - error: Argument of type "Literal[1]" cannot be assigned to parameter "y" of type "str" in function "example1_1"
9
13
"Literal[1]" is not assignable to "str" (reportArgumentType)
10
-
overloads_evaluation.py:45:10 - error: Argument of type "Literal[1]" cannot be assigned to parameter "x" of type "str" in function "example1"
14
+
overloads_evaluation.py:51:12 - error: Argument of type "Literal[1]" cannot be assigned to parameter "x" of type "str" in function "example1_1"
11
15
"Literal[1]" is not assignable to "str" (reportArgumentType)
12
-
overloads_evaluation.py:89:5 - error: No overloads for "example2" match the provided arguments (reportCallIssue)
13
-
overloads_evaluation.py:89:14 - error: Argument of type "int | str" cannot be assigned to parameter "x" of type "int" in function "example2"
16
+
overloads_evaluation.py:115:5 - error: No overloads for "example2" match the provided arguments (reportCallIssue)
17
+
overloads_evaluation.py:115:14 - error: Argument of type "int | str" cannot be assigned to parameter "x" of type "int" in function "example2"
14
18
Type "int | str" is not assignable to type "int"
15
19
"str" is not assignable to "int" (reportArgumentType)
16
-
overloads_evaluation.py:89:17 - error: Argument of type "int | str" cannot be assigned to parameter "y" of type "int" in function "example2"
20
+
overloads_evaluation.py:115:17 - error: Argument of type "int | str" cannot be assigned to parameter "y" of type "int" in function "example2"
17
21
Type "int | str" is not assignable to type "int"
18
22
"str" is not assignable to "int" (reportArgumentType)
23
+
overloads_evaluation.py:280:17 - error: "assert_type" mismatch: expected "Any" but received "list[int]" (reportAssertTypeFailure)
0 commit comments