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
Add conformance test for @final-decorated @Property
The language of the typing spec indicates that the @Final decorator
may be used with properties:
> The method decorator version may be used with all of instance methods, class methods, static methods, and properties.
I noticed this case while working on Pyre. I observed that Mypy and
Pyright also differ in behavior, so it seemed like a good conformance
test to add.
See discussion here:
https://discuss.python.org/t/proposal-allow-chaining-final-decorator-when-previous-decorators-return-a-non-function/78918
Copy file name to clipboardExpand all lines: conformance/results/pyre/qualifiers_final_decorator.toml
+11-10Lines changed: 11 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -7,18 +7,19 @@ Reports misleading error when overload is marked @final but implementation is no
7
7
output = """
8
8
qualifiers_final_decorator.py:21:0 Invalid inheritance [39]: Cannot inherit from final class `Base1`.
9
9
qualifiers_final_decorator.py:51:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
10
-
qualifiers_final_decorator.py:56:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method1` cannot override final method defined in `Base2`.
11
-
qualifiers_final_decorator.py:60:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method2` cannot override final method defined in `Base2`.
12
-
qualifiers_final_decorator.py:64:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method3` cannot override final method defined in `Base2`.
13
-
qualifiers_final_decorator.py:75:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method4` cannot override final method defined in `Base2`.
14
-
qualifiers_final_decorator.py:86:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
15
-
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.
16
-
qualifiers_final_decorator.py:118:4 Invalid override [40]: `qualifiers_final_decorator.Derived5.method` cannot override final method defined in `Base5_2`.
17
-
qualifiers_final_decorator.py:126:0 Invalid inheritance [39]: `final` cannot be used with non-method functions.
10
+
qualifiers_final_decorator.py:64:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method1` cannot override final method defined in `Base2`.
11
+
qualifiers_final_decorator.py:68:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method2` cannot override final method defined in `Base2`.
12
+
qualifiers_final_decorator.py:72:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method3` cannot override final method defined in `Base2`.
13
+
qualifiers_final_decorator.py:83:4 Invalid override [40]: `qualifiers_final_decorator.Derived2.method4` cannot override final method defined in `Base2`.
14
+
qualifiers_final_decorator.py:98:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).
15
+
qualifiers_final_decorator.py:130:4 Inconsistent override [14]: `qualifiers_final_decorator.Derived5.method` overrides method defined in `Base5_2` inconsistently. Could not find parameter `v` in overriding signature.
16
+
qualifiers_final_decorator.py:130:4 Invalid override [40]: `qualifiers_final_decorator.Derived5.method` cannot override final method defined in `Base5_2`.
17
+
qualifiers_final_decorator.py:138:0 Invalid inheritance [39]: `final` cannot be used with non-method functions.
18
18
"""
19
19
conformance_automated = "Fail"
20
20
errors_diff = """
21
-
Lines 80, 89: Expected error (tag 'Derived3')
22
-
Lines 94, 102: Expected error (tag 'Derived4')
21
+
Lines 86, 87: Expected error (tag 'method5')
22
+
Lines 92, 101: Expected error (tag 'Derived3')
23
+
Lines 106, 114: Expected error (tag 'Derived4')
23
24
Line 51: Unexpected errors ['qualifiers_final_decorator.py:51:4 Incompatible overload [43]: This definition does not have the same decorators as the preceding overload(s).']
Copy file name to clipboardExpand all lines: conformance/results/pyright/annotations_forward_refs.toml
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -6,19 +6,19 @@ annotations_forward_refs.py:24:7 - error: Union syntax cannot be used with strin
6
6
annotations_forward_refs.py:25:13 - error: Union syntax cannot be used with string operand; use quotes around entire expression (reportGeneralTypeIssues)
7
7
annotations_forward_refs.py:41:10 - error: Call expression not allowed in type expression (reportInvalidTypeForm)
8
8
annotations_forward_refs.py:42:10 - error: List expression not allowed in type expression
9
-
Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm)
9
+
Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm)
10
10
annotations_forward_refs.py:42:10 - error: Expected class but received "list[Unknown]" (reportGeneralTypeIssues)
11
11
annotations_forward_refs.py:43:10 - error: Tuple expression not allowed in type expression
12
-
Use tuple[T1, ..., Tn] to indicate a tuple type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm)
12
+
Use tuple[T1, ..., Tn] to indicate a tuple type or T1 | T2 to indicate a union type (reportInvalidTypeForm)
13
13
annotations_forward_refs.py:44:10 - error: List expression not allowed in type expression
14
-
Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm)
14
+
Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm)
15
15
annotations_forward_refs.py:44:10 - error: Expected class but received "list[type[int]]" (reportGeneralTypeIssues)
16
16
annotations_forward_refs.py:45:10 - error: Dictionary expression not allowed in type expression
17
-
Use Dict[T1, T2] to indicate a dictionary type (reportInvalidTypeForm)
17
+
Use dict[T1, T2] to indicate a dictionary type (reportInvalidTypeForm)
18
18
annotations_forward_refs.py:45:10 - error: Expected class but received "dict[Unknown, Unknown]" (reportGeneralTypeIssues)
19
19
annotations_forward_refs.py:46:10 - error: Call expression not allowed in type expression (reportInvalidTypeForm)
20
20
annotations_forward_refs.py:47:10 - error: List expression not allowed in type expression
21
-
Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportInvalidTypeForm)
21
+
Use list[T] to indicate a list type or T1 | T2 to indicate a union type (reportInvalidTypeForm)
22
22
annotations_forward_refs.py:47:10 - error: Expected class but received "list[type[int]]" (reportGeneralTypeIssues)
23
23
annotations_forward_refs.py:47:16 - error: Expected class but received "Literal[0]" (reportGeneralTypeIssues)
24
24
annotations_forward_refs.py:48:10 - error: Ternary expression not allowed in type expression (reportInvalidTypeForm)
0 commit comments