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
Makes two modifications to step 5 of overload call evaluation:
1. When materializing arguments to check whether we can
eliminate overloads, skip arguments that have the same
parameter type in all overloads.
2. When we still have multiple overloads after the materialization
filter, try to find a return type that all materializations of
all other return types are assignable to.
Updates the conformance tests as well. All type checkers already do
(1). Mypy and pyrefly pass the conformance test for (2). I believe
mypy has a heuristic that approximates the new rule; pyrefly
implements it exactly.
Copy file name to clipboardExpand all lines: conformance/results/mypy/overloads_evaluation.toml
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -14,10 +14,10 @@ Line 161: Unexpected errors ['overloads_evaluation.py:161: error: No overload va
14
14
Line 162: Unexpected errors ['overloads_evaluation.py:162: error: Expression is of type "Any", not "Literal[0, 1]" [assert-type]']
15
15
Line 205: Unexpected errors ['overloads_evaluation.py:205: error: Argument 1 to "expand_tuple" has incompatible type "tuple[int, int | str]"; expected "tuple[int, int]" [arg-type]']
16
16
Line 206: Unexpected errors ['overloads_evaluation.py:206: error: Expression is of type "int", not "int | str" [assert-type]']
17
-
Line 265: Unexpected errors ['overloads_evaluation.py:265: error: Expression is of type "list[Any]", not "Any" [assert-type]']
18
-
Line 281: Unexpected errors ['overloads_evaluation.py:281: error: Expression is of type "list[Any]", not "Any" [assert-type]']
19
-
Line 303: Unexpected errors ['overloads_evaluation.py:303: error: Expression is of type "Any", not "float" [assert-type]']
20
-
Line 347: Unexpected errors ['overloads_evaluation.py:347: error: Expression is of type "list[Any]", not "Any" [assert-type]']
17
+
Line 268: Unexpected errors ['overloads_evaluation.py:268: error: Expression is of type "list[Any]", not "Any" [assert-type]']
18
+
Line 284: Unexpected errors ['overloads_evaluation.py:284: error: Expression is of type "list[Any]", not "Any" [assert-type]']
19
+
Line 306: Unexpected errors ['overloads_evaluation.py:306: error: Expression is of type "Any", not "float" [assert-type]']
20
+
Line 350: Unexpected errors ['overloads_evaluation.py:350: error: Expression is of type "list[Any]", not "Any" [assert-type]']
21
21
"""
22
22
output = """
23
23
overloads_evaluation.py:38: error: All overload variants of "example1_1" require at least one argument [call-overload]
Copy file name to clipboardExpand all lines: conformance/results/pyrefly/directives_no_type_check.toml
-2Lines changed: 0 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,6 @@ errors_diff = """
4
4
"""
5
5
output = """
6
6
ERROR directives_no_type_check.py:15:14-16: `Literal['']` is not assignable to `int` [bad-assignment]
7
-
ERROR directives_no_type_check.py:29:7-17: Argument `Literal[b'invalid']` is not assignable to parameter `a` with type `int` in function `func1` [bad-argument-type]
8
-
ERROR directives_no_type_check.py:29:19-31: Argument `Literal[b'arguments']` is not assignable to parameter `b` with type `str` in function `func1` [bad-argument-type]
9
7
ERROR directives_no_type_check.py:32:6-8: Missing argument `a` in function `func1` [missing-argument]
10
8
ERROR directives_no_type_check.py:32:6-8: Missing argument `b` in function `func1` [missing-argument]
ERROR enums_member_values.py:78:5-10: Enum member `GREEN` has type `str`, must match the `_value_` attribute annotation of `int` [bad-assignment]
9
+
ERROR enums_member_values.py:78:5-10: Enum member `GREEN` has type `Literal['green']`, must match the `_value_` attribute annotation of `int` [bad-assignment]
13
10
ERROR enums_member_values.py:85:24-29: `int` is not assignable to attribute `_value_` with type `str` [bad-assignment]
ERROR generics_paramspec_components.py:60:28-34: Keyword-only parameter `s` may not appear after ParamSpec args parameter [bad-function-definition]
23
20
ERROR generics_paramspec_components.py:70:10-30: Expected *-unpacked P.args and **-unpacked P.kwargs [invalid-param-spec]
24
21
ERROR generics_paramspec_components.py:72:10-27: Expected 1 more positional argument [bad-argument-count]
25
-
ERROR generics_paramspec_components.py:83:13-14: Unexpected keyword argument `x` in function `foo` [unexpected-keyword]
26
-
ERROR generics_paramspec_components.py:83:13-16: Expected 1 more positional argument in function `foo` [bad-argument-count]
22
+
ERROR generics_paramspec_components.py:83:13-14: Expected argument `x` to be positional in function `foo` [unexpected-keyword]
27
23
ERROR generics_paramspec_components.py:98:20-23: Argument `Literal['A']` is not assignable to parameter `a` with type `int` in function `twice` [bad-argument-type]
28
24
ERROR generics_paramspec_components.py:98:25-26: Argument `Literal[1]` is not assignable to parameter `b` with type `str` in function `twice` [bad-argument-type]
Copy file name to clipboardExpand all lines: conformance/results/pyrefly/qualifiers_final_annotation.toml
+6-15Lines changed: 6 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,5 @@
1
-
conformant = "Partial"
2
-
notes = """
3
-
Does not reject Final inside ClassVar.
4
-
Issues with NamedTuple interaction.
5
-
"""
6
-
conformance_automated = "Fail"
1
+
conformance_automated = "Pass"
7
2
errors_diff = """
8
-
Line 107: Expected 1 errors
9
-
Line 131: Unexpected errors ['Expected first item to be a string literal [invalid-argument]', 'Expected first item to be a string literal [invalid-argument]']
10
-
Line 133: Unexpected errors ['Unexpected keyword argument `x` in function `N.__new__` [unexpected-keyword]', 'Unexpected keyword argument `y` in function `N.__new__` [unexpected-keyword]']
11
3
"""
12
4
output = """
13
5
ERROR qualifiers_final_annotation.py:16:7-12: Expected a type argument for `Final` [invalid-annotation]
@@ -22,17 +14,16 @@ ERROR qualifiers_final_annotation.py:67:9-17: Cannot set field `ID7` [read-only]
22
14
ERROR qualifiers_final_annotation.py:71:8-11: Cannot assign to variable `RATE` because it is marked final [bad-assignment]
23
15
ERROR qualifiers_final_annotation.py:81:1-18: Cannot set field `DEFAULT_ID` [read-only]
24
16
ERROR qualifiers_final_annotation.py:94:5-17: `BORDER_WIDTH` is declared as final in parent class `ClassC` [bad-override]
17
+
ERROR qualifiers_final_annotation.py:107:5-11: `Final` may not be nested inside `ClassVar` [invalid-annotation]
25
18
ERROR qualifiers_final_annotation.py:108:19-27: `ClassVar` may not be nested inside `Final` [invalid-annotation]
26
19
ERROR qualifiers_final_annotation.py:118:9-19: `Final` is not allowed in this context [invalid-annotation]
27
20
ERROR qualifiers_final_annotation.py:121:14-19: `Final` is only allowed on a class or local variable annotation [invalid-annotation]
28
21
ERROR qualifiers_final_annotation.py:121:14-30: `Final` is not allowed in this context [invalid-annotation]
29
-
ERROR qualifiers_final_annotation.py:131:23-24: Expected first item to be a string literal [invalid-argument]
30
-
ERROR qualifiers_final_annotation.py:131:33-34: Expected first item to be a string literal [invalid-argument]
31
-
ERROR qualifiers_final_annotation.py:133:3-4: Unexpected keyword argument `x` in function `N.__new__` [unexpected-keyword]
32
-
ERROR qualifiers_final_annotation.py:133:8-9: Unexpected keyword argument `y` in function `N.__new__` [unexpected-keyword]
22
+
ERROR qualifiers_final_annotation.py:134:2-7: Missing argument `x` in function `N.__new__` [missing-argument]
23
+
ERROR qualifiers_final_annotation.py:134:2-7: Missing argument `y` in function `N.__new__` [missing-argument]
33
24
ERROR qualifiers_final_annotation.py:134:3-4: Unexpected keyword argument `a` in function `N.__new__` [unexpected-keyword]
34
-
ERROR qualifiers_final_annotation.py:135:3-4: Unexpected keyword argument `x` in function `N.__new__` [unexpected-keyword]
35
-
ERROR qualifiers_final_annotation.py:135:9-10: Unexpected keyword argument `y` in function `N.__new__` [unexpected-keyword]
25
+
ERROR qualifiers_final_annotation.py:135:5-7: Argument `Literal['']` is not assignable to parameter `x` with type `int` in function `N.__new__` [bad-argument-type]
26
+
ERROR qualifiers_final_annotation.py:135:11-13: Argument `Literal['']` is not assignable to parameter `y` with type `int` in function `N.__new__` [bad-argument-type]
36
27
ERROR qualifiers_final_annotation.py:141:11-12: Cannot assign to variable `ID1` because it is marked final [bad-assignment]
37
28
ERROR qualifiers_final_annotation.py:145:5-11: Cannot assign to variable `x` because it is marked final [bad-assignment]
38
29
ERROR qualifiers_final_annotation.py:147:15-16: Cannot assign to variable `x` because it is marked final [bad-assignment]
0 commit comments