Skip to content

Commit 535075f

Browse files
committed
split overloads_invalid.py from overloads_basic.py
1 parent 27f1c79 commit 535075f

13 files changed

+239
-201
lines changed
Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
1-
conformant = "Partial"
2-
notes = """
3-
Does not allow an overload with no implementation in an abstract base class.
4-
"""
1+
conformant = "Pass"
52
output = """
6-
overloads_basic.py:41: error: No overload variant of "__getitem__" of "Bytes" matches argument type "str" [call-overload]
7-
overloads_basic.py:41: note: Possible overload variants:
8-
overloads_basic.py:41: note: def __getitem__(self, int, /) -> int
9-
overloads_basic.py:41: note: def __getitem__(self, slice[Any, Any, Any], /) -> bytes
10-
overloads_basic.py:66: error: Single overload definition, multiple required [misc]
11-
overloads_basic.py:78: error: An overloaded function outside a stub file must have an implementation [no-overload-impl]
12-
overloads_basic.py:101: error: An overloaded function outside a stub file must have an implementation [no-overload-impl]
13-
overloads_basic.py:115: error: An overloaded function outside a stub file must have an implementation [no-overload-impl]
14-
overloads_basic.py:130: error: Overload does not consistently use the "@staticmethod" decorator on all function signatures. [misc]
15-
overloads_basic.py:140: error: Overloaded function implementation does not accept all possible arguments of signature 1 [misc]
16-
overloads_basic.py:140: error: Overloaded function implementation does not accept all possible arguments of signature 2 [misc]
17-
overloads_basic.py:143: error: Overload does not consistently use the "@classmethod" decorator on all function signatures. [misc]
3+
overloads_basic.py:39: error: No overload variant of "__getitem__" of "Bytes" matches argument type "str" [call-overload]
4+
overloads_basic.py:39: note: Possible overload variants:
5+
overloads_basic.py:39: note: def __getitem__(self, int, /) -> int
6+
overloads_basic.py:39: note: def __getitem__(self, slice[Any, Any, Any], /) -> bytes
187
"""
19-
conformance_automated = "Fail"
8+
conformance_automated = "Pass"
209
errors_diff = """
21-
Line 101: Unexpected errors ['overloads_basic.py:101: error: An overloaded function outside a stub file must have an implementation [no-overload-impl]']
2210
"""
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
conformant = "Partial"
2+
conformance_automated = "Fail"
3+
notes = """
4+
Does not allow an overload with no implementation in an abstract base class.
5+
"""
6+
errors_diff = """
7+
Line 47: Unexpected errors ['overloads_invalid.py:47: error: An overloaded function outside a stub file must have an implementation [no-overload-impl]']
8+
"""
9+
output = """
10+
overloads_invalid.py:12: error: Single overload definition, multiple required [misc]
11+
overloads_invalid.py:24: error: An overloaded function outside a stub file must have an implementation [no-overload-impl]
12+
overloads_invalid.py:47: error: An overloaded function outside a stub file must have an implementation [no-overload-impl]
13+
overloads_invalid.py:61: error: An overloaded function outside a stub file must have an implementation [no-overload-impl]
14+
overloads_invalid.py:76: error: Overload does not consistently use the "@staticmethod" decorator on all function signatures. [misc]
15+
overloads_invalid.py:86: error: Overloaded function implementation does not accept all possible arguments of signature 1 [misc]
16+
overloads_invalid.py:86: error: Overloaded function implementation does not accept all possible arguments of signature 2 [misc]
17+
overloads_invalid.py:89: error: Overload does not consistently use the "@classmethod" decorator on all function signatures. [misc]
18+
"""
Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
1-
conformant = "Partial"
2-
notes = """
3-
Does not allow an overload with no implementation in a Protocol or an abstract base class.
4-
"""
1+
conformant = "Pass"
52
output = """
6-
overloads_basic.py:41:2 Incompatible parameter type [6]: In call `Bytes.__getitem__`, for 1st positional argument, expected `int` but got `str`.
7-
overloads_basic.py:67:0 Incompatible overload [43]: At least two overload signatures must be present.
8-
overloads_basic.py:79:0 Missing overload implementation [42]: Overloaded function `func2` must have an implementation.
9-
overloads_basic.py:92:4 Missing overload implementation [42]: Overloaded function `MyProto.func3` must have an implementation.
10-
overloads_basic.py:103:4 Missing overload implementation [42]: Overloaded function `MyAbstractBase.func4` must have an implementation.
11-
overloads_basic.py:116:4 Missing overload implementation [42]: Overloaded function `MyAbstractBase.not_abstract` must have an implementation.
12-
overloads_basic.py:132:4 Incompatible overload [43]: The implementation of `C.func5` does not accept all possible arguments of overload defined on line `132`.
13-
overloads_basic.py:137:4 Incompatible overload [43]: The implementation of `C.func5` does not accept all possible arguments of overload defined on line `137`.
14-
overloads_basic.py:140:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
15-
overloads_basic.py:145:4 Incompatible overload [43]: The implementation of `C.func6` does not accept all possible arguments of overload defined on line `145`.
16-
overloads_basic.py:150:4 Incompatible overload [43]: The implementation of `C.func6` does not accept all possible arguments of overload defined on line `150`.
17-
overloads_basic.py:153:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
3+
overloads_basic.py:39:2 Incompatible parameter type [6]: In call `Bytes.__getitem__`, for 1st positional argument, expected `int` but got `str`.
184
"""
19-
conformance_automated = "Fail"
5+
conformance_automated = "Pass"
206
errors_diff = """
21-
Line 92: Unexpected errors ['overloads_basic.py:92:4 Missing overload implementation [42]: Overloaded function `MyProto.func3` must have an implementation.']
22-
Line 103: Unexpected errors ['overloads_basic.py:103:4 Missing overload implementation [42]: Overloaded function `MyAbstractBase.func4` must have an implementation.']
237
"""
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
conformant = "Partial"
2+
conformance_automated = "Fail"
3+
notes = """
4+
Does not allow an overload with no implementation in a Protocol or an abstract base class.
5+
"""
6+
errors_diff = """
7+
Line 38: Unexpected errors ['overloads_invalid.py:38:4 Missing overload implementation [42]: Overloaded function `MyProto.func3` must have an implementation.']
8+
Line 49: Unexpected errors ['overloads_invalid.py:49:4 Missing overload implementation [42]: Overloaded function `MyAbstractBase.func4` must have an implementation.']
9+
"""
10+
output = """
11+
overloads_invalid.py:13:0 Incompatible overload [43]: At least two overload signatures must be present.
12+
overloads_invalid.py:25:0 Missing overload implementation [42]: Overloaded function `func2` must have an implementation.
13+
overloads_invalid.py:38:4 Missing overload implementation [42]: Overloaded function `MyProto.func3` must have an implementation.
14+
overloads_invalid.py:49:4 Missing overload implementation [42]: Overloaded function `MyAbstractBase.func4` must have an implementation.
15+
overloads_invalid.py:62:4 Missing overload implementation [42]: Overloaded function `MyAbstractBase.not_abstract` must have an implementation.
16+
overloads_invalid.py:78:4 Incompatible overload [43]: The implementation of `C.func5` does not accept all possible arguments of overload defined on line `78`.
17+
overloads_invalid.py:83:4 Incompatible overload [43]: The implementation of `C.func5` does not accept all possible arguments of overload defined on line `83`.
18+
overloads_invalid.py:86:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
19+
overloads_invalid.py:91:4 Incompatible overload [43]: The implementation of `C.func6` does not accept all possible arguments of overload defined on line `91`.
20+
overloads_invalid.py:96:4 Incompatible overload [43]: The implementation of `C.func6` does not accept all possible arguments of overload defined on line `96`.
21+
overloads_invalid.py:99:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
22+
"""
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.2
2+
test_duration = 5.9

conformance/results/pyright/overloads_basic.toml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,9 @@ conformant = "Pass"
22
notes = """
33
"""
44
output = """
5-
overloads_basic.py:41:1 - error: No overloads for "__getitem__" match the provided arguments (reportCallIssue)
6-
overloads_basic.py:41:1 - error: Argument of type "Literal['']" cannot be assigned to parameter "__s" of type "slice[Any, Any, Any]" in function "__getitem__"
5+
overloads_basic.py:39:1 - error: No overloads for "__getitem__" match the provided arguments (reportCallIssue)
6+
overloads_basic.py:39:1 - error: Argument of type "Literal['']" cannot be assigned to parameter "__s" of type "slice[Any, Any, Any]" in function "__getitem__"
77
  "Literal['']" is not assignable to "slice[Any, Any, Any]" (reportArgumentType)
8-
overloads_basic.py:67:5 - error: "func1" is marked as overload, but additional overloads are missing (reportInconsistentOverload)
9-
overloads_basic.py:79:5 - error: "func2" is marked as overload, but no implementation is provided (reportNoOverloadImplementation)
10-
overloads_basic.py:116:9 - error: "not_abstract" is marked as overload, but no implementation is provided (reportNoOverloadImplementation)
11-
overloads_basic.py:132:9 - error: Overloads for "func5" use @staticmethod inconsistently (reportInconsistentOverload)
12-
overloads_basic.py:140:9 - error: Overloaded implementation is not consistent with signature of overload 1
13-
  Type "(self: Self@C, x: int | str) -> (int | str)" is not assignable to type "(x: int) -> int"
14-
    Parameter name mismatch: "x" versus "self"
15-
    Parameter 1: type "int" is incompatible with type "Self@C"
16-
      Type "int" is not assignable to type "Self@C"
17-
    Extra parameter "x" (reportInconsistentOverload)
18-
overloads_basic.py:140:9 - error: Overloaded implementation is not consistent with signature of overload 2
19-
  Type "(self: Self@C, x: int | str) -> (int | str)" is not assignable to type "(x: str) -> str"
20-
    Parameter name mismatch: "x" versus "self"
21-
    Parameter 1: type "str" is incompatible with type "Self@C"
22-
      Type "str" is not assignable to type "Self@C"
23-
    Extra parameter "x" (reportInconsistentOverload)
24-
overloads_basic.py:145:9 - error: Overloads for "func6" use @classmethod inconsistently (reportInconsistentOverload)
25-
overloads_basic.py:153:15 - warning: Instance methods should take a "self" parameter (reportSelfClsParameterName)
268
"""
279
conformance_automated = "Pass"
2810
errors_diff = """
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
conformant = "Pass"
2+
conformance_automated = "Pass"
3+
errors_diff = """
4+
"""
5+
output = """
6+
overloads_invalid.py:13:5 - error: "func1" is marked as overload, but additional overloads are missing (reportInconsistentOverload)
7+
overloads_invalid.py:25:5 - error: "func2" is marked as overload, but no implementation is provided (reportNoOverloadImplementation)
8+
overloads_invalid.py:62:9 - error: "not_abstract" is marked as overload, but no implementation is provided (reportNoOverloadImplementation)
9+
overloads_invalid.py:78:9 - error: Overloads for "func5" use @staticmethod inconsistently (reportInconsistentOverload)
10+
overloads_invalid.py:86:9 - error: Overloaded implementation is not consistent with signature of overload 1
11+
  Type "(self: Self@C, x: int | str) -> (int | str)" is not assignable to type "(x: int) -> int"
12+
    Parameter name mismatch: "x" versus "self"
13+
    Parameter 1: type "int" is incompatible with type "Self@C"
14+
      Type "int" is not assignable to type "Self@C"
15+
    Extra parameter "x" (reportInconsistentOverload)
16+
overloads_invalid.py:86:9 - error: Overloaded implementation is not consistent with signature of overload 2
17+
  Type "(self: Self@C, x: int | str) -> (int | str)" is not assignable to type "(x: str) -> str"
18+
    Parameter name mismatch: "x" versus "self"
19+
    Parameter 1: type "str" is incompatible with type "Self@C"
20+
      Type "str" is not assignable to type "Self@C"
21+
    Extra parameter "x" (reportInconsistentOverload)
22+
overloads_invalid.py:91:9 - error: Overloads for "func6" use @classmethod inconsistently (reportInconsistentOverload)
23+
overloads_invalid.py:99:15 - warning: Instance methods should take a "self" parameter (reportSelfClsParameterName)
24+
"""
Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,25 @@
11
conformant = "Partial"
22
notes = """
3-
Does not reject a function with a single @overload signature.
4-
Does not reject a function with @overload signature but no implementation.
5-
Does not allow an overload with no implementation in a Protocol or an abstract base class.
6-
Does not exempt overloads from checking of return type in body, when also decorated with `@staticmethod`.
7-
Does not error on overloads inconsistently decorated with `@staticmethod` or `@classmethod`.
83
"""
94
output = """
10-
overloads_basic.py:35:20: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in __getitem__: bad return type [bad-return-type]
5+
overloads_basic.py:33:20: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in __getitem__: bad return type [bad-return-type]
116
127
return b""
138
\u001b[1m\u001b[31m~~~\u001b[39m\u001b[0m
149
15-
overloads_basic.py:41:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: unsupported operand type(s) for item retrieval: Bytes and str [unsupported-operands]
10+
overloads_basic.py:39:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in <module>: unsupported operand type(s) for item retrieval: Bytes and str [unsupported-operands]
1611
1712
b[""] # E: no matching overload
1813
\u001b[1m\u001b[31m~~~~~\u001b[39m\u001b[0m
1914
20-
overloads_basic.py:62:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in map: bad return type [bad-return-type]
15+
overloads_basic.py:60:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in map: bad return type [bad-return-type]
2116
2217
pass
2318
\u001b[1m\u001b[31m~~~~\u001b[39m\u001b[0m
2419
25-
overloads_basic.py:98:9: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in func3: @typing.overload-decorated 'MyProto.func3' object is not callable [not-callable]
26-
27-
...
28-
\u001b[1m\u001b[31m~~~\u001b[39m\u001b[0m
29-
30-
overloads_basic.py:110:9: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in func4: @typing.overload-decorated 'MyAbstractBase.func4' object is not callable [not-callable]
31-
32-
...
33-
\u001b[1m\u001b[31m~~~\u001b[39m\u001b[0m
34-
35-
overloads_basic.py:122:9: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in not_abstract: @typing.overload-decorated 'MyAbstractBase.not_abstract' object is not callable [not-callable]
36-
37-
...
38-
\u001b[1m\u001b[31m~~~\u001b[39m\u001b[0m
39-
40-
overloads_basic.py:133:9: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in func5: bad return type [bad-return-type]
41-
42-
...
43-
\u001b[1m\u001b[31m~~~\u001b[39m\u001b[0m
44-
45-
overloads_basic.py:138:9: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in func5: bad return type [bad-return-type]
46-
47-
...
48-
\u001b[1m\u001b[31m~~~\u001b[39m\u001b[0m
49-
5020
"""
5121
conformance_automated = "Fail"
5222
errors_diff = """
53-
Lines 66, 67: Expected error (tag 'func1')
54-
Lines 78, 79: Expected error (tag 'func2')
55-
Lines 115, 116: Expected error (tag 'not_abstract')
56-
Lines 130, 132, 137, 140: Expected error (tag 'func5')
57-
Lines 143, 145, 150, 153: Expected error (tag 'func6')
58-
Line 35: Unexpected errors ['overloads_basic.py:35:20: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in __getitem__: bad return type [bad-return-type]']
59-
Line 62: Unexpected errors ['overloads_basic.py:62:5: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in map: bad return type [bad-return-type]']
60-
Line 98: Unexpected errors ["overloads_basic.py:98:9: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in func3: @typing.overload-decorated 'MyProto.func3' object is not callable [not-callable]"]
61-
Line 110: Unexpected errors ["overloads_basic.py:110:9: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in func4: @typing.overload-decorated 'MyAbstractBase.func4' object is not callable [not-callable]"]
62-
Line 122: Unexpected errors ["overloads_basic.py:122:9: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in not_abstract: @typing.overload-decorated 'MyAbstractBase.not_abstract' object is not callable [not-callable]"]
63-
Line 133: Unexpected errors ['overloads_basic.py:133:9: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in func5: bad return type [bad-return-type]']
64-
Line 138: Unexpected errors ['overloads_basic.py:138:9: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in func5: bad return type [bad-return-type]']
23+
Line 33: Unexpected errors ['overloads_basic.py:33:20: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in __getitem__: bad return type [bad-return-type]']
24+
Line 60: Unexpected errors ['overloads_basic.py:60:5: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in map: bad return type [bad-return-type]']
6525
"""
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
conformant = "Fail"
2+
notes = """
3+
Does not reject a function with a single @overload signature.
4+
Does not reject a function with @overload signature but no implementation.
5+
Does not allow an overload with no implementation in a Protocol or an abstract base class.
6+
Does not error on overloads inconsistently decorated with `@staticmethod` or `@classmethod`.
7+
"""
8+
conformance_automated = "Fail"
9+
errors_diff = """
10+
Lines 12, 13: Expected error (tag 'func1')
11+
Lines 24, 25: Expected error (tag 'func2')
12+
Lines 61, 62: Expected error (tag 'not_abstract')
13+
Lines 76, 78, 83, 86: Expected error (tag 'func5')
14+
Lines 89, 91, 96, 99: Expected error (tag 'func6')
15+
Line 44: Unexpected errors ["overloads_invalid.py:44:9: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in func3: @typing.overload-decorated 'MyProto.func3' object is not callable [not-callable]"]
16+
Line 56: Unexpected errors ["overloads_invalid.py:56:9: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in func4: @typing.overload-decorated 'MyAbstractBase.func4' object is not callable [not-callable]"]
17+
Line 68: Unexpected errors ["overloads_invalid.py:68:9: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in not_abstract: @typing.overload-decorated 'MyAbstractBase.not_abstract' object is not callable [not-callable]"]
18+
Line 79: Unexpected errors ['overloads_invalid.py:79:9: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in func5: bad return type [bad-return-type]']
19+
Line 84: Unexpected errors ['overloads_invalid.py:84:9: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in func5: bad return type [bad-return-type]']
20+
"""
21+
output = """
22+
overloads_invalid.py:44:9: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in func3: @typing.overload-decorated 'MyProto.func3' object is not callable [not-callable]
23+
24+
...
25+
\u001b[1m\u001b[31m~~~\u001b[39m\u001b[0m
26+
27+
overloads_invalid.py:56:9: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in func4: @typing.overload-decorated 'MyAbstractBase.func4' object is not callable [not-callable]
28+
29+
...
30+
\u001b[1m\u001b[31m~~~\u001b[39m\u001b[0m
31+
32+
overloads_invalid.py:68:9: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in not_abstract: @typing.overload-decorated 'MyAbstractBase.not_abstract' object is not callable [not-callable]
33+
34+
...
35+
\u001b[1m\u001b[31m~~~\u001b[39m\u001b[0m
36+
37+
overloads_invalid.py:79:9: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in func5: bad return type [bad-return-type]
38+
39+
...
40+
\u001b[1m\u001b[31m~~~\u001b[39m\u001b[0m
41+
42+
overloads_invalid.py:84:9: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in func5: bad return type [bad-return-type]
43+
44+
...
45+
\u001b[1m\u001b[31m~~~\u001b[39m\u001b[0m
46+
47+
"""
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 = 30.5
2+
test_duration = 29.9

0 commit comments

Comments
 (0)