Skip to content

Commit 169fa58

Browse files
committed
add tests for enum and tuple expansion
1 parent f5bee93 commit 169fa58

File tree

8 files changed

+197
-78
lines changed

8 files changed

+197
-78
lines changed

conformance/results/mypy/overloads_evaluation.toml

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,47 @@ conformant = "Partial"
22
notes = """
33
Does not pick a winning overload based on arity, prior to considering argument types.
44
Does not expand boolean arguments to Literal[True] and Literal[False].
5+
Does not expand enum arguments to literal variants.
6+
Does not expand tuple arguments to possible combinations.
57
"""
68
conformance_automated = "Fail"
79
errors_diff = """
8-
Line 35: Unexpected errors ['overloads_evaluation.py:35: error: Expression is of type "Any", not "int" [assert-type]']
9-
Line 41: Unexpected errors ['overloads_evaluation.py:41: error: Expression is of type "Any", not "str" [assert-type]']
10-
Line 102: Unexpected errors ['overloads_evaluation.py:102: error: No overload variant of "expand_bool" matches argument type "bool" [call-overload]']
11-
Line 103: Unexpected errors ['overloads_evaluation.py:103: error: Expression is of type "Any", not "Literal[0, 1]" [assert-type]']
10+
Line 36: Unexpected errors ['overloads_evaluation.py:36: error: Expression is of type "Any", not "int" [assert-type]']
11+
Line 42: Unexpected errors ['overloads_evaluation.py:42: error: Expression is of type "Any", not "str" [assert-type]']
12+
Line 103: Unexpected errors ['overloads_evaluation.py:103: error: No overload variant of "expand_bool" matches argument type "bool" [call-overload]']
13+
Line 104: Unexpected errors ['overloads_evaluation.py:104: error: Expression is of type "Any", not "Literal[0, 1]" [assert-type]']
14+
Line 126: Unexpected errors ['overloads_evaluation.py:126: error: No overload variant of "expand_enum" matches argument type "Color" [call-overload]']
15+
Line 127: Unexpected errors ['overloads_evaluation.py:127: error: Expression is of type "Any", not "Literal[0, 1]" [assert-type]']
16+
Line 147: Unexpected errors ['overloads_evaluation.py:147: error: Argument 1 to "expand_tuple" has incompatible type "tuple[int, int | str]"; expected "tuple[int, int]" [arg-type]']
17+
Line 148: Unexpected errors ['overloads_evaluation.py:148: error: Expression is of type "int", not "int | str" [assert-type]']
1218
"""
1319
output = """
14-
overloads_evaluation.py:26: error: All overload variants of "example1" require at least one argument [call-overload]
15-
overloads_evaluation.py:26: note: Possible overload variants:
16-
overloads_evaluation.py:26: note: def example1(x: int, y: str) -> int
17-
overloads_evaluation.py:26: note: def example1(x: str) -> str
18-
overloads_evaluation.py:34: error: No overload variant of "example1" matches argument types "int", "int" [call-overload]
19-
overloads_evaluation.py:34: note: Possible overload variants:
20-
overloads_evaluation.py:34: note: def example1(x: int, y: str) -> int
21-
overloads_evaluation.py:34: note: def example1(x: str) -> str
22-
overloads_evaluation.py:35: error: Expression is of type "Any", not "int" [assert-type]
23-
overloads_evaluation.py:40: error: No overload variant of "example1" matches argument type "int" [call-overload]
24-
overloads_evaluation.py:40: note: Possible overload variants:
25-
overloads_evaluation.py:40: note: def example1(x: int, y: str) -> int
26-
overloads_evaluation.py:40: note: def example1(x: str) -> str
27-
overloads_evaluation.py:41: error: Expression is of type "Any", not "str" [assert-type]
28-
overloads_evaluation.py:85: error: Argument 1 to "example2" has incompatible type "int | str"; expected "int" [arg-type]
29-
overloads_evaluation.py:85: error: Argument 2 to "example2" has incompatible type "int | str"; expected "str" [arg-type]
30-
overloads_evaluation.py:102: error: No overload variant of "expand_bool" matches argument type "bool" [call-overload]
31-
overloads_evaluation.py:102: note: Possible overload variants:
32-
overloads_evaluation.py:102: note: def expand_bool(x: Literal[False]) -> Literal[0]
33-
overloads_evaluation.py:102: note: def expand_bool(x: Literal[True]) -> Literal[1]
34-
overloads_evaluation.py:103: error: Expression is of type "Any", not "Literal[0, 1]" [assert-type]
20+
overloads_evaluation.py:27: error: All overload variants of "example1" require at least one argument [call-overload]
21+
overloads_evaluation.py:27: note: Possible overload variants:
22+
overloads_evaluation.py:27: note: def example1(x: int, y: str) -> int
23+
overloads_evaluation.py:27: note: def example1(x: str) -> str
24+
overloads_evaluation.py:35: error: No overload variant of "example1" matches argument types "int", "int" [call-overload]
25+
overloads_evaluation.py:35: note: Possible overload variants:
26+
overloads_evaluation.py:35: note: def example1(x: int, y: str) -> int
27+
overloads_evaluation.py:35: note: def example1(x: str) -> str
28+
overloads_evaluation.py:36: error: Expression is of type "Any", not "int" [assert-type]
29+
overloads_evaluation.py:41: error: No overload variant of "example1" matches argument type "int" [call-overload]
30+
overloads_evaluation.py:41: note: Possible overload variants:
31+
overloads_evaluation.py:41: note: def example1(x: int, y: str) -> int
32+
overloads_evaluation.py:41: note: def example1(x: str) -> str
33+
overloads_evaluation.py:42: error: Expression is of type "Any", not "str" [assert-type]
34+
overloads_evaluation.py:86: error: Argument 1 to "example2" has incompatible type "int | str"; expected "int" [arg-type]
35+
overloads_evaluation.py:86: error: Argument 2 to "example2" has incompatible type "int | str"; expected "str" [arg-type]
36+
overloads_evaluation.py:103: error: No overload variant of "expand_bool" matches argument type "bool" [call-overload]
37+
overloads_evaluation.py:103: note: Possible overload variants:
38+
overloads_evaluation.py:103: note: def expand_bool(x: Literal[False]) -> Literal[0]
39+
overloads_evaluation.py:103: note: def expand_bool(x: Literal[True]) -> Literal[1]
40+
overloads_evaluation.py:104: error: Expression is of type "Any", not "Literal[0, 1]" [assert-type]
41+
overloads_evaluation.py:126: error: No overload variant of "expand_enum" matches argument type "Color" [call-overload]
42+
overloads_evaluation.py:126: note: Possible overload variants:
43+
overloads_evaluation.py:126: note: def expand_enum(x: Literal[Color.RED]) -> Literal[0]
44+
overloads_evaluation.py:126: note: def expand_enum(x: Literal[Color.BLUE]) -> Literal[1]
45+
overloads_evaluation.py:127: error: Expression is of type "Any", not "Literal[0, 1]" [assert-type]
46+
overloads_evaluation.py:147: error: Argument 1 to "expand_tuple" has incompatible type "tuple[int, int | str]"; expected "tuple[int, int]" [arg-type]
47+
overloads_evaluation.py:148: error: Expression is of type "int", not "int | str" [assert-type]
3548
"""
Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
conformant = "Partial"
22
notes = """
33
Does not expand boolean arguments to Literal[True] and Literal[False].
4+
Does not expand enum arguments to literal variants.
5+
Does not expand tuple arguments to possible combinations.
46
"""
57
conformance_automated = "Fail"
68
errors_diff = """
7-
Line 85: Expected 1 errors
8-
Line 102: Unexpected errors ['overloads_evaluation.py:102:23 Incompatible parameter type [6]: In call `expand_bool`, for 1st positional argument, expected `typing_extensions.Literal[False]` but got `bool`.']
9-
Line 103: Unexpected errors ['overloads_evaluation.py:103:4 Assert type [70]: Expected `Union[typing_extensions.Literal[0], typing_extensions.Literal[1]]` but got `typing_extensions.Literal[0]`.']
9+
Line 78: Unexpected errors ['overloads_evaluation.py:78:23 Incompatible parameter type [6]: In call `example2`, for 2nd positional argument, expected `str` but got `Union[int, str]`.']
10+
Line 79: Unexpected errors ['overloads_evaluation.py:79:4 Assert type [70]: Expected `Union[int, str]` but got `str`.']
11+
Line 103: Unexpected errors ['overloads_evaluation.py:103:23 Incompatible parameter type [6]: In call `expand_bool`, for 1st positional argument, expected `typing_extensions.Literal[False]` but got `bool`.']
12+
Line 104: Unexpected errors ['overloads_evaluation.py:104:4 Assert type [70]: Expected `Union[typing_extensions.Literal[0], typing_extensions.Literal[1]]` but got `typing_extensions.Literal[0]`.']
13+
Line 126: Unexpected errors ['overloads_evaluation.py:126:23 Incompatible parameter type [6]: In call `expand_enum`, for 1st positional argument, expected `typing_extensions.Literal[Color.RED]` but got `Color`.']
14+
Line 127: Unexpected errors ['overloads_evaluation.py:127:4 Assert type [70]: Expected `Union[typing_extensions.Literal[0], typing_extensions.Literal[1]]` but got `typing_extensions.Literal[0]`.']
15+
Line 147: Unexpected errors ['overloads_evaluation.py:147:24 Incompatible parameter type [6]: In call `expand_tuple`, for 1st positional argument, expected `Tuple[int, int]` but got `Tuple[int, Union[int, str]]`.']
16+
Line 148: Unexpected errors ['overloads_evaluation.py:148:4 Assert type [70]: Expected `Union[int, str]` but got `int`.']
1017
"""
1118
output = """
12-
overloads_evaluation.py:26:0 Missing argument [20]: Call `example1` expects argument `x`.
13-
overloads_evaluation.py:34:19 Incompatible parameter type [6]: In call `example1`, for 2nd positional argument, expected `str` but got `int`.
14-
overloads_evaluation.py:40:16 Incompatible parameter type [6]: In call `example1`, for 1st positional argument, expected `str` but got `int`.
15-
overloads_evaluation.py:102:23 Incompatible parameter type [6]: In call `expand_bool`, for 1st positional argument, expected `typing_extensions.Literal[False]` but got `bool`.
16-
overloads_evaluation.py:103:4 Assert type [70]: Expected `Union[typing_extensions.Literal[0], typing_extensions.Literal[1]]` but got `typing_extensions.Literal[0]`.
19+
overloads_evaluation.py:27:0 Missing argument [20]: Call `example1` expects argument `x`.
20+
overloads_evaluation.py:35:19 Incompatible parameter type [6]: In call `example1`, for 2nd positional argument, expected `str` but got `int`.
21+
overloads_evaluation.py:41:16 Incompatible parameter type [6]: In call `example1`, for 1st positional argument, expected `str` but got `int`.
22+
overloads_evaluation.py:78:23 Incompatible parameter type [6]: In call `example2`, for 2nd positional argument, expected `str` but got `Union[int, str]`.
23+
overloads_evaluation.py:79:4 Assert type [70]: Expected `Union[int, str]` but got `str`.
24+
overloads_evaluation.py:86:13 Incompatible parameter type [6]: In call `example2`, for 1st positional argument, expected `int` but got `Union[int, str]`.
25+
overloads_evaluation.py:86:16 Incompatible parameter type [6]: In call `example2`, for 2nd positional argument, expected `str` but got `Union[int, str]`.
26+
overloads_evaluation.py:103:23 Incompatible parameter type [6]: In call `expand_bool`, for 1st positional argument, expected `typing_extensions.Literal[False]` but got `bool`.
27+
overloads_evaluation.py:104:4 Assert type [70]: Expected `Union[typing_extensions.Literal[0], typing_extensions.Literal[1]]` but got `typing_extensions.Literal[0]`.
28+
overloads_evaluation.py:126:23 Incompatible parameter type [6]: In call `expand_enum`, for 1st positional argument, expected `typing_extensions.Literal[Color.RED]` but got `Color`.
29+
overloads_evaluation.py:127:4 Assert type [70]: Expected `Union[typing_extensions.Literal[0], typing_extensions.Literal[1]]` but got `typing_extensions.Literal[0]`.
30+
overloads_evaluation.py:147:24 Incompatible parameter type [6]: In call `expand_tuple`, for 1st positional argument, expected `Tuple[int, int]` but got `Tuple[int, Union[int, str]]`.
31+
overloads_evaluation.py:148:4 Assert type [70]: Expected `Union[int, str]` but got `int`.
1732
"""
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.1
Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,43 @@
11
conformant = "Partial"
22
notes = """
33
Does not expand boolean arguments to Literal[True] and Literal[False].
4+
Does not expand enum arguments to literal variants.
5+
Does not expand tuple arguments to possible combinations.
46
"""
57
conformance_automated = "Fail"
68
errors_diff = """
7-
Line 102: Unexpected errors ['overloads_evaluation.py:102:12 - error: No overloads for "expand_bool" match the provided arguments (reportCallIssue)', 'overloads_evaluation.py:102:24 - error: Argument of type "bool" cannot be assigned to parameter "x" of type "Literal[True]" in function "expand_bool"']
8-
Line 103: Unexpected errors ['overloads_evaluation.py:103:17 - error: "assert_type" mismatch: expected "Literal[0, 1]" but received "Unknown" (reportAssertTypeFailure)']
9+
Line 103: Unexpected errors ['overloads_evaluation.py:103:12 - error: No overloads for "expand_bool" match the provided arguments (reportCallIssue)', 'overloads_evaluation.py:103:24 - error: Argument of type "bool" cannot be assigned to parameter "x" of type "Literal[True]" in function "expand_bool"']
10+
Line 104: Unexpected errors ['overloads_evaluation.py:104:17 - error: "assert_type" mismatch: expected "Literal[0, 1]" but received "Unknown" (reportAssertTypeFailure)']
11+
Line 126: Unexpected errors ['overloads_evaluation.py:126:12 - error: No overloads for "expand_enum" match the provided arguments (reportCallIssue)', 'overloads_evaluation.py:126:24 - error: Argument of type "Color" cannot be assigned to parameter "x" of type "Literal[Color.BLUE]" in function "expand_enum"']
12+
Line 127: Unexpected errors ['overloads_evaluation.py:127:17 - error: "assert_type" mismatch: expected "Literal[0, 1]" but received "Unknown" (reportAssertTypeFailure)']
13+
Line 147: Unexpected errors ['overloads_evaluation.py:147:12 - error: No overloads for "expand_tuple" match the provided arguments (reportCallIssue)', 'overloads_evaluation.py:147: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"']
14+
Line 148: Unexpected errors ['overloads_evaluation.py:148:17 - error: "assert_type" mismatch: expected "int | str" but received "Unknown" (reportAssertTypeFailure)']
915
"""
1016
output = """
11-
overloads_evaluation.py:26:1 - error: No overloads for "example1" match the provided arguments
17+
overloads_evaluation.py:27:1 - error: No overloads for "example1" match the provided arguments
1218
  Argument types: () (reportCallIssue)
13-
overloads_evaluation.py:34:20 - error: Argument of type "Literal[1]" cannot be assigned to parameter "y" of type "str" in function "example1"
19+
overloads_evaluation.py:35:20 - error: Argument of type "Literal[1]" cannot be assigned to parameter "y" of type "str" in function "example1"
1420
  "Literal[1]" is not assignable to "str" (reportArgumentType)
15-
overloads_evaluation.py:40:17 - error: Argument of type "Literal[1]" cannot be assigned to parameter "x" of type "str" in function "example1"
21+
overloads_evaluation.py:41:17 - error: Argument of type "Literal[1]" cannot be assigned to parameter "x" of type "str" in function "example1"
1622
  "Literal[1]" is not assignable to "str" (reportArgumentType)
17-
overloads_evaluation.py:85:5 - error: No overloads for "example2" match the provided arguments (reportCallIssue)
18-
overloads_evaluation.py:85:14 - error: Argument of type "int | str" cannot be assigned to parameter "x" of type "int" in function "example2"
23+
overloads_evaluation.py:86:5 - error: No overloads for "example2" match the provided arguments (reportCallIssue)
24+
overloads_evaluation.py:86:14 - error: Argument of type "int | str" cannot be assigned to parameter "x" of type "int" in function "example2"
1925
  Type "int | str" is not assignable to type "int"
2026
    "str" is not assignable to "int" (reportArgumentType)
21-
overloads_evaluation.py:85:17 - error: Argument of type "int | str" cannot be assigned to parameter "y" of type "int" in function "example2"
27+
overloads_evaluation.py:86:17 - error: Argument of type "int | str" cannot be assigned to parameter "y" of type "int" in function "example2"
2228
  Type "int | str" is not assignable to type "int"
2329
    "str" is not assignable to "int" (reportArgumentType)
24-
overloads_evaluation.py:102:12 - error: No overloads for "expand_bool" match the provided arguments (reportCallIssue)
25-
overloads_evaluation.py:102:24 - error: Argument of type "bool" cannot be assigned to parameter "x" of type "Literal[True]" in function "expand_bool"
30+
overloads_evaluation.py:103:12 - error: No overloads for "expand_bool" match the provided arguments (reportCallIssue)
31+
overloads_evaluation.py:103:24 - error: Argument of type "bool" cannot be assigned to parameter "x" of type "Literal[True]" in function "expand_bool"
2632
  "bool" is not assignable to type "Literal[True]" (reportArgumentType)
27-
overloads_evaluation.py:103:17 - error: "assert_type" mismatch: expected "Literal[0, 1]" but received "Unknown" (reportAssertTypeFailure)
33+
overloads_evaluation.py:104:17 - error: "assert_type" mismatch: expected "Literal[0, 1]" but received "Unknown" (reportAssertTypeFailure)
34+
overloads_evaluation.py:126:12 - error: No overloads for "expand_enum" match the provided arguments (reportCallIssue)
35+
overloads_evaluation.py:126:24 - error: Argument of type "Color" cannot be assigned to parameter "x" of type "Literal[Color.BLUE]" in function "expand_enum"
36+
  "Color" is not assignable to type "Literal[Color.BLUE]" (reportArgumentType)
37+
overloads_evaluation.py:127:17 - error: "assert_type" mismatch: expected "Literal[0, 1]" but received "Unknown" (reportAssertTypeFailure)
38+
overloads_evaluation.py:147:12 - error: No overloads for "expand_tuple" match the provided arguments (reportCallIssue)
39+
overloads_evaluation.py:147: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"
40+
  Type "int | str" is not assignable to type "str"
41+
    "int" is not assignable to "str" (reportArgumentType)
42+
overloads_evaluation.py:148:17 - error: "assert_type" mismatch: expected "int | str" but received "Unknown" (reportAssertTypeFailure)
2843
"""

0 commit comments

Comments
 (0)