Skip to content

Commit

Permalink
Added a missing test case for the final decorator and updated results.
Browse files Browse the repository at this point in the history
  • Loading branch information
erictraut committed Dec 31, 2023
1 parent 3b66466 commit 1dc37d7
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 33 deletions.
17 changes: 9 additions & 8 deletions conformance/results/mypy/qualifiers_final_decorator.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ qualifiers_final_decorator.py:59: error: Cannot override final attribute "method
qualifiers_final_decorator.py:63: error: Cannot override final attribute "method3" (previously declared in base class "Base2") [misc]
qualifiers_final_decorator.py:67: error: Cannot override final attribute "method4" (previously declared in base class "Base2") [misc]
qualifiers_final_decorator.py:80: error: Cannot override final attribute "method" (previously declared in base class "Base3") [misc]
qualifiers_final_decorator.py:93: error: Cannot override final attribute "method" (previously declared in base class "Base4") [misc]
qualifiers_final_decorator.py:117: error: Cannot override final attribute "method" (previously declared in base class "Base5_2") [misc]
qualifiers_final_decorator.py:117: error: Signature of "method" incompatible with supertype "Base5_2" [override]
qualifiers_final_decorator.py:117: note: Superclass:
qualifiers_final_decorator.py:117: note: def method(self, v: int) -> None
qualifiers_final_decorator.py:117: note: Subclass:
qualifiers_final_decorator.py:117: note: def method(self) -> None
qualifiers_final_decorator.py:124: error: @final cannot be used with non-method functions [misc]
qualifiers_final_decorator.py:84: error: @final should be applied only to overload implementation [misc]
qualifiers_final_decorator.py:94: error: Cannot override final attribute "method" (previously declared in base class "Base4") [misc]
qualifiers_final_decorator.py:118: error: Cannot override final attribute "method" (previously declared in base class "Base5_2") [misc]
qualifiers_final_decorator.py:118: error: Signature of "method" incompatible with supertype "Base5_2" [override]
qualifiers_final_decorator.py:118: note: Superclass:
qualifiers_final_decorator.py:118: note: def method(self, v: int) -> None
qualifiers_final_decorator.py:118: note: Subclass:
qualifiers_final_decorator.py:118: note: def method(self) -> None
qualifiers_final_decorator.py:125: error: @final cannot be used with non-method functions [misc]
"""
2 changes: 1 addition & 1 deletion conformance/results/mypy/typeddicts_alt_syntax.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
conformant = "Partial"
conformant = "Pass"
notes = """
Does not support keyword-argument form of alternative syntax (deprecated in 3.11).
"""
Expand Down
2 changes: 1 addition & 1 deletion conformance/results/mypy/version.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "mypy 1.8.0"
test_duration = 0.38987088203430176
test_duration = 0.5543861389160156
8 changes: 5 additions & 3 deletions conformance/results/pyre/qualifiers_final_decorator.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ conformant = "Partial"
notes = """
Reports error for overloaded method implementation marked @final if its overloads do not.
Does not report error for overloaded @final method defined in stub file.
Reports misleading error when overload is marked @final but implementation is not.
"""
output = """
qualifiers_final_decorator.py:21:0 Invalid inheritance [39]: Cannot inherit from final class `Base1`.
Expand All @@ -10,7 +11,8 @@ qualifiers_final_decorator.py:56:4 Invalid override [40]: `qualifiers_final_deco
qualifiers_final_decorator.py:60:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method2` cannot override final method defined in `Base2`.
qualifiers_final_decorator.py:64:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method3` cannot override final method defined in `Base2`.
qualifiers_final_decorator.py:75:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method4` cannot override final method defined in `Base2`.
qualifiers_final_decorator.py:117:4 Inconsistent override [14]: `qualifiers_final_decorator.Derived5.method` overrides method defined in `Base5_2` inconsistently. Could not find parameter `v` in overriding signature.
qualifiers_final_decorator.py:117:4 Invalid override [40]: `qualifiers_final_decorator.Derived5.method` cannot override final method defined in `Base5_2`.
qualifiers_final_decorator.py:125:0 Invalid inheritance [39]: `final` cannot be used with non-method functions.
qualifiers_final_decorator.py:86:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
qualifiers_final_decorator.py:118:4 Inconsistent override [14]: `qualifiers_final_decorator.Derived5.method` overrides method defined in `Base5_2` inconsistently. Could not find parameter `v` in overriding signature.
qualifiers_final_decorator.py:118:4 Invalid override [40]: `qualifiers_final_decorator.Derived5.method` cannot override final method defined in `Base5_2`.
qualifiers_final_decorator.py:126:0 Invalid inheritance [39]: `final` cannot be used with non-method functions.
"""
2 changes: 1 addition & 1 deletion conformance/results/pyre/version.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "pyre 0.9.19"
test_duration = 1.5279979705810547
test_duration = 1.92598295211792
6 changes: 4 additions & 2 deletions conformance/results/pyright/qualifiers_final_decorator.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ conformant = "Partial"
notes = """
Does not report override of overloaded method marked @final.
Does not report error for non-method function marked @final.
Does not report error if overload is marked @final but implementation is not.
Does not report error in stub if first overload is not marked @final but subsequent ones are.
"""
output = """
qualifiers_final_decorator.py:8:6 - warning: Import "_qualifiers_final_decorator" could not be resolved from source (reportMissingModuleSource)
qualifiers_final_decorator.py:21:16 - error: Base class "Base1" is marked final and cannot be subclassed
qualifiers_final_decorator.py:56:9 - error: Method "method1" cannot override final method defined in class "Base2"
qualifiers_final_decorator.py:60:9 - error: Method "method2" cannot override final method defined in class "Base2"
qualifiers_final_decorator.py:64:9 - error: Method "method3" cannot override final method defined in class "Base2"
qualifiers_final_decorator.py:117:9 - error: Method "method" overrides class "Base5_2" in an incompatible manner
qualifiers_final_decorator.py:118:9 - error: Method "method" overrides class "Base5_2" in an incompatible manner
  Positional parameter count mismatch; base method has 2, but override has 1 (reportIncompatibleMethodOverride)
qualifiers_final_decorator.py:117:9 - error: Method "method" cannot override final method defined in class "Base5_2"
qualifiers_final_decorator.py:118:9 - error: Method "method" cannot override final method defined in class "Base5_2"
"""
2 changes: 1 addition & 1 deletion conformance/results/pyright/version.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "pyright 1.1.344"
test_duration = 1.0795209407806396
test_duration = 1.0778310298919678
17 changes: 9 additions & 8 deletions conformance/results/pytype/qualifiers_final_decorator.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
conformant = "Partial"
notes = """
Does not report error for overloaded @final method defined in stub file.
Does not report error for overload that is marked @final when implementation is not.
"""
output = """
File "qualifiers_final_decorator.py", line 8, in <module>: Can't find module '_qualifiers_final_decorator'. [import-error]
File "qualifiers_final_decorator.py", line 21, in <module>: Cannot subclass final class: Base1 [final-error]
File "qualifiers_final_decorator.py", line 52, in method4: bad return type [bad-return-type]
Expected: str
Actually returned: int
File "qualifiers_final_decorator.py", line 55, in <module>: Class Derived2 overrides final method method1, defined in base class Base2 [final-error]
File "qualifiers_final_decorator.py", line 55, in <module>: Class Derived2 overrides final method method4, defined in base class Base2 [final-error]
File "qualifiers_final_decorator.py", line 55, in <module>: Class Derived2 overrides final method method3, defined in base class Base2 [final-error]
File "qualifiers_final_decorator.py", line 55, in <module>: Class Derived2 overrides final method method2, defined in base class Base2 [final-error]
File "qualifiers_final_decorator.py", line 55, in <module>: Class Derived2 overrides final method method3, defined in base class Base2 [final-error]
File "qualifiers_final_decorator.py", line 55, in <module>: Class Derived2 overrides final method method4, defined in base class Base2 [final-error]
File "qualifiers_final_decorator.py", line 55, in <module>: Class Derived2 overrides final method method1, defined in base class Base2 [final-error]
File "qualifiers_final_decorator.py", line 76, in method4: bad return type [bad-return-type]
Expected: str
Actually returned: int
File "qualifiers_final_decorator.py", line 89, in method: bad return type [bad-return-type]
File "qualifiers_final_decorator.py", line 90, in method: bad return type [bad-return-type]
Expected: str
Actually returned: int
File "qualifiers_final_decorator.py", line 102, in method: bad return type [bad-return-type]
File "qualifiers_final_decorator.py", line 103, in method: bad return type [bad-return-type]
Expected: str
Actually returned: int
File "qualifiers_final_decorator.py", line 116, in <module>: Class Derived5 overrides final method method, defined in base class Base5_2 [final-error]
File "qualifiers_final_decorator.py", line 117, in Derived5: Overriding method signature mismatch [signature-mismatch]
File "qualifiers_final_decorator.py", line 117, in <module>: Class Derived5 overrides final method method, defined in base class Base5_2 [final-error]
File "qualifiers_final_decorator.py", line 118, in Derived5: Overriding method signature mismatch [signature-mismatch]
Base signature: 'def Base5_2.method(self, v: int) -> None'.
Subclass signature: 'def Derived5.method(self) -> None'.
Not enough positional parameters in overriding method.
File "qualifiers_final_decorator.py", line 125, in <module>: Cannot apply @final decorator to func1 [final-error]
File "qualifiers_final_decorator.py", line 126, in <module>: Cannot apply @final decorator to func1 [final-error]
@final can only be applied to classes and methods.
"""
2 changes: 1 addition & 1 deletion conformance/results/pytype/version.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "pytype 2023.12.18"
test_duration = 65.10498309135437
test_duration = 68.93368911743164
14 changes: 7 additions & 7 deletions conformance/results/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<header>
<h3>Python Type System Conformance Test Results</h3>
</header>
<div class='tc-header'><span class='tc-name'>mypy 1.8.0<span class='tc-time'>(0.39sec)</span>
<div class='tc-header'><span class='tc-name'>mypy 1.8.0<span class='tc-time'>(0.55sec)</span>
</div>
<div class="table_container"><table>
<tr><th class="column spacer" colspan="4"></th></tr>
Expand Down Expand Up @@ -199,7 +199,7 @@ <h3>Python Type System Conformance Test Results</h3>
<tr><th class="column spacer" colspan="4"></th></tr>
<tr><th class="column" colspan="4">
<a class="test_group" href="https://typing.readthedocs.io/en/latest/spec/typeddict.html">Typed dictionaries</a></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">typeddicts_alt_syntax</th><th class="column col2 partially-conformant">Partial</th><th class="column col3">Does not support keyword-argument form of alternative syntax (deprecated in 3.11).<br></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">typeddicts_alt_syntax</th><th class="column col2 conformant">Pass</th><th class="column col3">Does not support keyword-argument form of alternative syntax (deprecated in 3.11).<br></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">typeddicts_class_syntax</th><th class="column col2 conformant">Pass</th><th class="column col3"></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">typeddicts_final</th><th class="column col2 conformant">Pass</th><th class="column col3"></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">typeddicts_inheritance</th><th class="column col2 conformant">Pass</th><th class="column col3"></th></tr>
Expand Down Expand Up @@ -243,7 +243,7 @@ <h3>Python Type System Conformance Test Results</h3>
<a class="test_group" href="https://typing.readthedocs.io/en/latest/spec/qualifiers.html">Type qualifiers</a></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">qualifiers_annotated</th><th class="column col2 partially-conformant">Partial</th><th class="column col3">Does not reject all invalid type expressions within Annotated.<br></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">qualifiers_final_annotation</th><th class="column col2 partially-conformant">Partial</th><th class="column col3">Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition.<br></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">qualifiers_final_decorator</th><th class="column col2 partially-conformant">Partial</th><th class="column col3">Does not report override of overloaded method marked @final.<br>Does not report error for non-method function marked @final.<br></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">qualifiers_final_decorator</th><th class="column col2 partially-conformant">Partial</th><th class="column col3">Does not report override of overloaded method marked @final.<br>Does not report error for non-method function marked @final.<br>Does not report error if overload is marked @final but implementation is not.<br>Does not report error in stub if first overload is not marked @final but subsequent ones are.<br></th></tr>
<tr><th class="column spacer" colspan="4"></th></tr>
<tr><th class="column" colspan="4">
<a class="test_group" href="https://typing.readthedocs.io/en/latest/spec/class-compat.html">Class type compatibility</a></th></tr>
Expand Down Expand Up @@ -319,7 +319,7 @@ <h3>Python Type System Conformance Test Results</h3>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">directives_version_platform</th><th class="column col2 conformant">Pass</th><th class="column col3"></th></tr>
<tr><th class="column spacer" colspan="4"></th></tr>
</table></div>
<div class='tc-header'><span class='tc-name'>pyre 0.9.19<span class='tc-time'>(1.53sec)</span>
<div class='tc-header'><span class='tc-name'>pyre 0.9.19<span class='tc-time'>(1.93sec)</span>
</div>
<div class="table_container"><table>
<tr><th class="column spacer" colspan="4"></th></tr>
Expand All @@ -339,7 +339,7 @@ <h3>Python Type System Conformance Test Results</h3>
<a class="test_group" href="https://typing.readthedocs.io/en/latest/spec/qualifiers.html">Type qualifiers</a></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">qualifiers_annotated</th><th class="column col2 partially-conformant">Partial</th><th class="column col3">Does not reject Annotated with a single parameter.<br></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">qualifiers_final_annotation</th><th class="column col2 partially-conformant">Partial</th><th class="column col3">Does not report Final variable with missing initialization in module scope.<br>Does not report error for invalid nesting of Final and ClassVar.<br>Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition.<br></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">qualifiers_final_decorator</th><th class="column col2 partially-conformant">Partial</th><th class="column col3">Reports error for overloaded method implementation marked @final if its overloads do not.<br>Does not report error for overloaded @final method defined in stub file.<br></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">qualifiers_final_decorator</th><th class="column col2 partially-conformant">Partial</th><th class="column col3">Reports error for overloaded method implementation marked @final if its overloads do not.<br>Does not report error for overloaded @final method defined in stub file.<br>Reports misleading error when overload is marked @final but implementation is not.<br></th></tr>
<tr><th class="column spacer" colspan="4"></th></tr>
<tr><th class="column" colspan="4">
<a class="test_group" href="https://typing.readthedocs.io/en/latest/spec/class-compat.html">Class type compatibility</a></th></tr>
Expand Down Expand Up @@ -415,7 +415,7 @@ <h3>Python Type System Conformance Test Results</h3>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">directives_version_platform</th><th class="column col2 partially-conformant">Partial</th><th class="column col3">Does not support sys.platform checks.<br>Does not support os.name checks.<br></th></tr>
<tr><th class="column spacer" colspan="4"></th></tr>
</table></div>
<div class='tc-header'><span class='tc-name'>pytype 2023.12.18<span class='tc-time'>(65.10sec)</span>
<div class='tc-header'><span class='tc-name'>pytype 2023.12.18<span class='tc-time'>(68.93sec)</span>
</div>
<div class="table_container"><table>
<tr><th class="column spacer" colspan="4"></th></tr>
Expand All @@ -435,7 +435,7 @@ <h3>Python Type System Conformance Test Results</h3>
<a class="test_group" href="https://typing.readthedocs.io/en/latest/spec/qualifiers.html">Type qualifiers</a></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">qualifiers_annotated</th><th class="column col2 partially-conformant">Partial</th><th class="column col3">Does not reject some illegal type expression forms used in Annotated.<br>Does not allow TypeVar to be used in type alias when wrapped with Annotated.<br></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">qualifiers_final_annotation</th><th class="column col2 partially-conformant">Partial</th><th class="column col3">Does not report Final variable with missing initialization.<br>Does not reject Final instance variable declared outside of __init__ method.<br>Does not reject modification of global variable declared Final.<br>Does not reject modification of local variable declared Final.<br></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">qualifiers_final_decorator</th><th class="column col2 partially-conformant">Partial</th><th class="column col3">Does not report error for overloaded @final method defined in stub file.<br></th></tr>
<tr><th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th class="column col1">qualifiers_final_decorator</th><th class="column col2 partially-conformant">Partial</th><th class="column col3">Does not report error for overloaded @final method defined in stub file.<br>Does not report error for overload that is marked @final when implementation is not.<br></th></tr>
<tr><th class="column spacer" colspan="4"></th></tr>
<tr><th class="column" colspan="4">
<a class="test_group" href="https://typing.readthedocs.io/en/latest/spec/class-compat.html">Class type compatibility</a></th></tr>
Expand Down
1 change: 1 addition & 0 deletions conformance/tests/qualifiers_final_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def method(self, x: int) -> int:
...

@overload
@final # Type error: should be applied only to implementation
def method(self, x: str) -> str:
...

Expand Down

0 comments on commit 1dc37d7

Please sign in to comment.