Skip to content

Commit ac3b70e

Browse files
committed
add support for stub test files, add overloads_definitions_stub.pyi
1 parent 484b03c commit ac3b70e

14 files changed

+366
-69
lines changed

conformance/results/mypy/overloads_definitions.toml

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ conformant = "Partial"
22
conformance_automated = "Fail"
33
notes = """
44
Does not allow an overload with no implementation in an abstract base class.
5+
Allows @override to be on all overloads and implementation, instead of just implementation.
56
"""
67
errors_diff = """
8+
Line 245: Expected 1 errors
79
Line 49: Unexpected errors ['overloads_definitions.py:49: error: An overloaded function outside a stub file must have an implementation [no-overload-impl]']
8-
Line 202: Unexpected errors ['overloads_definitions.py:202: error: Signature of "good_override" incompatible with supertype "Base" [override]']
910
"""
1011
output = """
1112
overloads_definitions.py:14: error: Single overload definition, multiple required [misc]
@@ -18,30 +19,6 @@ overloads_definitions.py:88: error: Overloaded function implementation does not
1819
overloads_definitions.py:91: error: Overload does not consistently use the "@classmethod" decorator on all function signatures. [misc]
1920
overloads_definitions.py:133: error: @final should be applied only to overload implementation [misc]
2021
overloads_definitions.py:148: error: @final should be applied only to overload implementation [misc]
21-
overloads_definitions.py:176: error: Cannot override final attribute "final_method" (previously declared in base class "Base") [misc]
22-
overloads_definitions.py:176: error: Signature of "final_method" incompatible with supertype "Base" [override]
23-
overloads_definitions.py:176: note: Superclass:
24-
overloads_definitions.py:176: note: @overload
25-
overloads_definitions.py:176: note: def final_method(self, x: int) -> int
26-
overloads_definitions.py:176: note: @overload
27-
overloads_definitions.py:176: note: def final_method(self, x: str) -> str
28-
overloads_definitions.py:176: note: Subclass:
29-
overloads_definitions.py:176: note: def final_method(self, x: int | str) -> int | str
30-
overloads_definitions.py:183: error: Method "bad_override" is marked as an override, but no base method was found with this name [misc]
31-
overloads_definitions.py:202: error: Signature of "good_override" incompatible with supertype "Base" [override]
32-
overloads_definitions.py:202: note: Superclass:
33-
overloads_definitions.py:202: note: def good_override(self, x: int | str) -> int | str
34-
overloads_definitions.py:202: note: Subclass:
35-
overloads_definitions.py:202: note: @overload
36-
overloads_definitions.py:202: note: def good_override(self, x: int) -> int
37-
overloads_definitions.py:202: note: @overload
38-
overloads_definitions.py:202: note: def good_override(self, x: str) -> str
39-
overloads_definitions.py:217: error: Signature of "to_override" incompatible with supertype "Base" [override]
40-
overloads_definitions.py:217: note: Superclass:
41-
overloads_definitions.py:217: note: def to_override(self, x: int | str) -> int | str
42-
overloads_definitions.py:217: note: Subclass:
43-
overloads_definitions.py:217: note: @overload
44-
overloads_definitions.py:217: note: def to_override(self, x: int) -> int
45-
overloads_definitions.py:217: note: @overload
46-
overloads_definitions.py:217: note: def to_override(self, x: str) -> str
22+
overloads_definitions.py:196: error: Cannot override final attribute "final_method" (previously declared in base class "Base") [misc]
23+
overloads_definitions.py:211: error: Method "bad_override" is marked as an override, but no base method was found with this name [misc]
4724
"""
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
conformant = "Partial"
2+
notes = """
3+
Allows @override to appear in a stub file not on the first overload.
4+
"""
5+
conformance_automated = "Fail"
6+
errors_diff = """
7+
Line 168: Expected 1 errors
8+
"""
9+
output = """
10+
overloads_definitions_stub.pyi:13: error: Single overload definition, multiple required [misc]
11+
overloads_definitions_stub.pyi:37: error: Overload does not consistently use the "@staticmethod" decorator on all function signatures. [misc]
12+
overloads_definitions_stub.pyi:38: error: Self argument missing for a non-static method (or an invalid type for self) [misc]
13+
overloads_definitions_stub.pyi:46: error: Overload does not consistently use the "@classmethod" decorator on all function signatures. [misc]
14+
overloads_definitions_stub.pyi:85: error: In a stub file @final must be applied only to the first overload [misc]
15+
overloads_definitions_stub.pyi:101: error: In a stub file @final must be applied only to the first overload [misc]
16+
overloads_definitions_stub.pyi:128: error: Cannot override final attribute "final_method" (previously declared in base class "Base") [misc]
17+
overloads_definitions_stub.pyi:140: error: Method "bad_override" is marked as an override, but no base method was found with this name [misc]
18+
"""

conformance/results/pyre/overloads_definitions.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ Does not allow an overload with no implementation in a Protocol or an abstract b
55
Expects @final/@override on all overloads and implementation, instead of implementation only.
66
"""
77
errors_diff = """
8-
Line 217: Expected 1 errors
8+
Line 245: Expected 1 errors
99
Lines 148, 150: Expected error (tag 'invalid_final_2')
1010
Line 40: Unexpected errors ['overloads_definitions.py:40:4 Missing overload implementation [42]: Overloaded function `MyProto.func3` must have an implementation.']
1111
Line 51: Unexpected errors ['overloads_definitions.py:51:4 Missing overload implementation [42]: Overloaded function `MyAbstractBase.func4` must have an implementation.']
1212
Line 128: Unexpected errors ['overloads_definitions.py:128:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).']
13-
Line 211: Unexpected errors ['overloads_definitions.py:211:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).']
13+
Line 239: Unexpected errors ['overloads_definitions.py:239:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).']
1414
"""
1515
output = """
1616
overloads_definitions.py:15:0 Incompatible overload [43]: At least two overload signatures must be present.
@@ -25,8 +25,8 @@ overloads_definitions.py:97:4 Incompatible overload [43]: The implementation of
2525
overloads_definitions.py:97:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
2626
overloads_definitions.py:128:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
2727
overloads_definitions.py:139:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
28-
overloads_definitions.py:176:4 Invalid override [40]: `overloads_definitions.Child.final_method` cannot override final method defined in `Base`.
29-
overloads_definitions.py:192:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
30-
overloads_definitions.py:192:4 Invalid override [40]: `overloads_definitions.Child.bad_override` is decorated with @override, but no method of the same name exists in superclasses of `Child`.
31-
overloads_definitions.py:211:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
28+
overloads_definitions.py:204:4 Invalid override [40]: `overloads_definitions.Child.final_method` cannot override final method defined in `Base`.
29+
overloads_definitions.py:220:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
30+
overloads_definitions.py:220:4 Invalid override [40]: `overloads_definitions.Child.bad_override` is decorated with @override, but no method of the same name exists in superclasses of `Child`.
31+
overloads_definitions.py:239:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
3232
"""
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
conformant = "Partial"
2+
notes = """
3+
Expects @final and @override to be present on all overloads, not just first.
4+
"""
5+
conformance_automated = "Fail"
6+
errors_diff = """
7+
Line 168: Expected 1 errors
8+
Lines 80, 82, 85, 87: Expected error (tag 'invalid_final')
9+
Lines 96, 98, 101: Expected error (tag 'invalid_final_2')
10+
Lines 122, 128, 129, 133: Expected error (tag 'override-final')
11+
Line 75: Unexpected errors ['overloads_definitions_stub.pyi:75:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).']
12+
Line 91: Unexpected errors ['overloads_definitions_stub.pyi:91:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).']
13+
Line 146: Unexpected errors ['overloads_definitions_stub.pyi:146:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).']
14+
Line 162: Unexpected errors ['overloads_definitions_stub.pyi:162:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).']
15+
Line 174: Unexpected errors ['overloads_definitions_stub.pyi:174:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).']
16+
"""
17+
output = """
18+
overloads_definitions_stub.pyi:14:0 Incompatible overload [43]: At least two overload signatures must be present.
19+
overloads_definitions_stub.pyi:43:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
20+
overloads_definitions_stub.pyi:52:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
21+
overloads_definitions_stub.pyi:75:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
22+
overloads_definitions_stub.pyi:91:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
23+
overloads_definitions_stub.pyi:142:4 Invalid override [40]: `overloads_definitions_stub.Child.bad_override` is decorated with @override, but no method of the same name exists in superclasses of `Child`.
24+
overloads_definitions_stub.pyi:146:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
25+
overloads_definitions_stub.pyi:162:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
26+
overloads_definitions_stub.pyi:174:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
27+
"""
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 = 5.9
2+
test_duration = 6.7

conformance/results/pyright/overloads_definitions.toml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Allows @final/@override on all overloads and implementation; should be implement
44
"""
55
conformance_automated = "Fail"
66
errors_diff = """
7-
Line 217: Expected 1 errors
7+
Line 245: Expected 1 errors
88
Lines 148, 150: Expected error (tag 'invalid_final_2')
99
"""
1010
output = """
@@ -27,10 +27,6 @@ overloads_definitions.py:88:9 - error: Overloaded implementation is not consiste
2727
overloads_definitions.py:93:9 - error: Overloads for "func6" use @classmethod inconsistently (reportInconsistentOverload)
2828
overloads_definitions.py:97:15 - warning: Instance methods should take a "self" parameter (reportSelfClsParameterName)
2929
overloads_definitions.py:135:9 - error: Overload for "invalid_final" is marked @final but implementation is not (reportInconsistentOverload)
30-
overloads_definitions.py:176:9 - error: Method "final_method" cannot override final method defined in class "Base" (reportIncompatibleMethodOverride)
31-
overloads_definitions.py:176:9 - error: Method "final_method" overrides class "Base" in an incompatible manner
32-
  Return type mismatch: base method returns type "int", override returns type "int | str"
33-
    Type "int | str" is not assignable to type "int"
34-
      "str" is not assignable to "int" (reportIncompatibleMethodOverride)
35-
overloads_definitions.py:192:9 - error: Method "bad_override" is marked as override, but no base method of same name is present (reportGeneralTypeIssues)
30+
overloads_definitions.py:204:9 - error: Method "final_method" cannot override final method defined in class "Base" (reportIncompatibleMethodOverride)
31+
overloads_definitions.py:220:9 - error: Method "bad_override" is marked as override, but no base method of same name is present (reportGeneralTypeIssues)
3632
"""
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
conformant = "Partial"
2+
notes = """
3+
Does not enforce that @final/@override in a stub should be only on first overload.
4+
Does not enforce @override when correctly used with an overloaded method in a stub file.
5+
"""
6+
conformance_automated = "Fail"
7+
errors_diff = """
8+
Line 168: Expected 1 errors
9+
Lines 80, 82, 85, 87: Expected error (tag 'invalid_final')
10+
Lines 96, 98, 101: Expected error (tag 'invalid_final_2')
11+
Lines 140, 142: Expected error (tag 'bad_override')
12+
"""
13+
output = """
14+
overloads_definitions_stub.pyi:14:5 - error: "func1" is marked as overload, but additional overloads are missing (reportInconsistentOverload)
15+
overloads_definitions_stub.pyi:38:9 - error: Overloads for "func5" use @staticmethod inconsistently (reportInconsistentOverload)
16+
overloads_definitions_stub.pyi:38:15 - warning: Instance methods should take a "self" parameter (reportSelfClsParameterName)
17+
overloads_definitions_stub.pyi:48:9 - error: Overloads for "func6" use @classmethod inconsistently (reportInconsistentOverload)
18+
overloads_definitions_stub.pyi:52:15 - warning: Instance methods should take a "self" parameter (reportSelfClsParameterName)
19+
overloads_definitions_stub.pyi:133:9 - error: Method "final_method" cannot override final method defined in class "Base" (reportIncompatibleMethodOverride)
20+
"""

0 commit comments

Comments
 (0)