From b1962709a530748b3c375d29314acae61b9ca7a4 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Mon, 10 Mar 2025 13:59:42 -0600 Subject: [PATCH] Implemented conformance tests for typing spec involving imported Final variables. --- .../results/mypy/annotations_generators.toml | 6 ++--- .../mypy/qualifiers_final_annotation.toml | 2 ++ conformance/results/mypy/version.toml | 2 +- .../results/pyre/annotations_generators.toml | 10 ++++---- .../pyre/qualifiers_final_annotation.toml | 3 +++ conformance/results/pyre/version.toml | 2 +- .../pyright/annotations_generators.toml | 18 ++++++++++----- .../results/pyright/callables_subtyping.toml | 4 +++- .../pyright/qualifiers_final_annotation.toml | 2 ++ conformance/results/pyright/version.toml | 2 +- .../pytype/annotations_generators.toml | 14 +++++------ .../pytype/qualifiers_final_annotation.toml | 17 +++++++++++++- conformance/results/pytype/version.toml | 2 +- conformance/results/results.html | 12 +++++----- .../tests/_qualifiers_final_annotation_1.py | 7 ++++++ .../tests/_qualifiers_final_annotation_2.py | 7 ++++++ .../tests/qualifiers_final_annotation.py | 23 +++++++++++++++---- 17 files changed, 96 insertions(+), 37 deletions(-) create mode 100644 conformance/tests/_qualifiers_final_annotation_1.py create mode 100644 conformance/tests/_qualifiers_final_annotation_2.py diff --git a/conformance/results/mypy/annotations_generators.toml b/conformance/results/mypy/annotations_generators.toml index d906218f1..475411412 100644 --- a/conformance/results/mypy/annotations_generators.toml +++ b/conformance/results/mypy/annotations_generators.toml @@ -11,12 +11,12 @@ annotations_generators.py:71: error: No return value expected [return-value] annotations_generators.py:75: error: Incompatible types in "yield" (actual type "B", expected type "A") [misc] annotations_generators.py:86: error: The return type of a generator function should be "Generator" or one of its supertypes [misc] annotations_generators.py:91: error: The return type of an async generator function should be "AsyncGenerator" or one of its supertypes [misc] -annotations_generators.py:116: error: Incompatible types in "yield from" (actual type "A", expected type "B") [misc] -annotations_generators.py:117: error: Incompatible types in "yield from" (actual type "int", expected type "B") [misc] +annotations_generators.py:118: error: Incompatible types in "yield from" (actual type "A", expected type "B") [misc] +annotations_generators.py:119: error: Incompatible types in "yield from" (actual type "int", expected type "B") [misc] """ conformance_automated = "Fail" errors_diff = """ Line 87: Expected 1 errors Line 92: Expected 1 errors -Line 133: Expected 1 errors +Line 135: Expected 1 errors """ diff --git a/conformance/results/mypy/qualifiers_final_annotation.toml b/conformance/results/mypy/qualifiers_final_annotation.toml index d0898be41..2d0cea337 100644 --- a/conformance/results/mypy/qualifiers_final_annotation.toml +++ b/conformance/results/mypy/qualifiers_final_annotation.toml @@ -35,6 +35,8 @@ qualifiers_final_annotation.py:145: error: Cannot assign to final name "x" [mis qualifiers_final_annotation.py:147: error: Cannot assign to final name "x" [misc] qualifiers_final_annotation.py:152: error: Incompatible types in assignment (expression has type "TextIOWrapper[_WrappedBuffer]", variable has type "int") [assignment] qualifiers_final_annotation.py:155: error: Cannot assign to final name "x" [misc] +qualifiers_final_annotation.py:166: error: Cannot assign to final name "TEN" [misc] +qualifiers_final_annotation.py:170: error: Cannot assign to final name "PI" [misc] """ conformance_automated = "Fail" errors_diff = """ diff --git a/conformance/results/mypy/version.toml b/conformance/results/mypy/version.toml index b3982776b..e5c363db9 100644 --- a/conformance/results/mypy/version.toml +++ b/conformance/results/mypy/version.toml @@ -1,2 +1,2 @@ version = "mypy 1.15.0" -test_duration = 1.8 +test_duration = 1.7 diff --git a/conformance/results/pyre/annotations_generators.toml b/conformance/results/pyre/annotations_generators.toml index 4fdff0424..865d139d2 100644 --- a/conformance/results/pyre/annotations_generators.toml +++ b/conformance/results/pyre/annotations_generators.toml @@ -12,15 +12,15 @@ annotations_generators.py:87:4 Incompatible return type [7]: Expected `int` but annotations_generators.py:88:4 Incompatible return type [7]: Expected `int` but got `Generator[typing.Any, typing.Any, int]`. annotations_generators.py:91:0 Incompatible async generator return type [57]: Expected return annotation to be AsyncGenerator or a superclass but got `int`. annotations_generators.py:92:4 Incompatible return type [7]: Expected `int` but got `AsyncGenerator[None, typing.Any]`. -annotations_generators.py:116:4 Incompatible return type [7]: Expected `Iterator[B]` but got `Generator[A, None, typing.Any]`. -annotations_generators.py:117:4 Incompatible return type [7]: Expected `Iterator[B]` but got `Generator[int, None, typing.Any]`. -annotations_generators.py:133:4 Incompatible return type [7]: Expected `Generator[None, str, None]` but got `Generator[None, int, typing.Any]`. -annotations_generators.py:183:0 Incompatible variable type [9]: v1 is declared to have type `typing.Callable[[], Coroutine[typing.Any, typing.Any, AsyncIterator[int]]]` but is used as type `typing.Callable(generator29)[[], AsyncIterator[int]]`. +annotations_generators.py:118:4 Incompatible return type [7]: Expected `Iterator[B]` but got `Generator[A, None, typing.Any]`. +annotations_generators.py:119:4 Incompatible return type [7]: Expected `Iterator[B]` but got `Generator[int, None, typing.Any]`. +annotations_generators.py:135:4 Incompatible return type [7]: Expected `Generator[None, str, None]` but got `Generator[None, int, typing.Any]`. +annotations_generators.py:185:0 Incompatible variable type [9]: v1 is declared to have type `typing.Callable[[], Coroutine[typing.Any, typing.Any, AsyncIterator[int]]]` but is used as type `typing.Callable(generator29)[[], AsyncIterator[int]]`. """ conformance_automated = "Fail" errors_diff = """ Line 51: Expected 1 errors Line 86: Expected 1 errors Line 88: Unexpected errors ['annotations_generators.py:88:4 Incompatible return type [7]: Expected `int` but got `Generator[typing.Any, typing.Any, int]`.'] -Line 183: Unexpected errors ['annotations_generators.py:183:0 Incompatible variable type [9]: v1 is declared to have type `typing.Callable[[], Coroutine[typing.Any, typing.Any, AsyncIterator[int]]]` but is used as type `typing.Callable(generator29)[[], AsyncIterator[int]]`.'] +Line 185: Unexpected errors ['annotations_generators.py:185:0 Incompatible variable type [9]: v1 is declared to have type `typing.Callable[[], Coroutine[typing.Any, typing.Any, AsyncIterator[int]]]` but is used as type `typing.Callable(generator29)[[], AsyncIterator[int]]`.'] """ diff --git a/conformance/results/pyre/qualifiers_final_annotation.toml b/conformance/results/pyre/qualifiers_final_annotation.toml index 1e7cb4c6d..f9b7dff8d 100644 --- a/conformance/results/pyre/qualifiers_final_annotation.toml +++ b/conformance/results/pyre/qualifiers_final_annotation.toml @@ -3,6 +3,7 @@ notes = """ Does not report Final variable with missing initialization in module scope. Does not report error for invalid nesting of Final and ClassVar. Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition. +Does not reject modification of imported variable declared Final. """ output = """ qualifiers_final_annotation.py:18:6 Invalid type parameters [24]: Generic type `Final` expects 1 type parameter, received 2. @@ -33,5 +34,7 @@ errors_diff = """ Line 16: Expected 1 errors Line 107: Expected 1 errors Line 108: Expected 1 errors +Line 166: Expected 1 errors +Line 170: Expected 1 errors Line 133: Unexpected errors ['qualifiers_final_annotation.py:133:0 Unexpected keyword [28]: Unexpected keyword argument `x` to call `N.__init__`.'] """ diff --git a/conformance/results/pyre/version.toml b/conformance/results/pyre/version.toml index 028806c2e..5cd0b295f 100644 --- a/conformance/results/pyre/version.toml +++ b/conformance/results/pyre/version.toml @@ -1,2 +1,2 @@ version = "pyre 0.9.23" -test_duration = 6.5 +test_duration = 6.8 diff --git a/conformance/results/pyright/annotations_generators.toml b/conformance/results/pyright/annotations_generators.toml index aca80497f..84e2463d0 100644 --- a/conformance/results/pyright/annotations_generators.toml +++ b/conformance/results/pyright/annotations_generators.toml @@ -5,11 +5,17 @@ annotations_generators.py:51:21 - error: Function with declared return type "C" annotations_generators.py:54:16 - error: Type "Literal[False]" is not assignable to return type "C"   "Literal[False]" is not assignable to "C" (reportReturnType) annotations_generators.py:57:15 - error: Return type of generator function must be compatible with "Generator[Literal[3], Any, Any]" -  "Literal[3]" is not assignable to "A" (reportReturnType) +  "Generator[Literal[3], Unknown, Unknown]" is not assignable to "Generator[A, B, C]" +    Type parameter "_YieldT_co@Generator" is covariant, but "Literal[3]" is not a subtype of "A" +      "Literal[3]" is not assignable to "A" (reportReturnType) annotations_generators.py:66:15 - error: Return type of generator function must be compatible with "Generator[Literal[3], Any, Any]" -  "Literal[3]" is not assignable to "A" (reportReturnType) +  "Generator[Literal[3], Unknown, Unknown]" is not assignable to "Generator[A, int, Any]" +    Type parameter "_YieldT_co@Generator" is covariant, but "Literal[3]" is not a subtype of "A" +      "Literal[3]" is not assignable to "A" (reportReturnType) annotations_generators.py:75:11 - error: Return type of generator function must be compatible with "Generator[B, Any, Any]" -  "B" is not assignable to "A" (reportReturnType) +  "Generator[B, Unknown, Unknown]" is not assignable to "Iterator[A]" +    Type parameter "_T_co@Iterator" is covariant, but "B" is not a subtype of "A" +      "B" is not assignable to "A" (reportReturnType) annotations_generators.py:86:21 - error: Return type of generator function must be compatible with "Generator[Any, Any, Any]"   "Generator[Any, Any, Any]" is not assignable to "int" (reportInvalidTypeForm) annotations_generators.py:87:11 - error: Return type of generator function must be compatible with "Generator[None, Any, Any]" @@ -18,15 +24,15 @@ annotations_generators.py:91:27 - error: Return type of async generator function   "AsyncGenerator[Any, Any, Any]" is not assignable to "int" (reportInvalidTypeForm) annotations_generators.py:92:11 - error: Return type of async generator function must be compatible with "AsyncGenerator[None, Any]"   "AsyncGenerator[None, Unknown, Unknown]" is not assignable to "int" (reportReturnType) -annotations_generators.py:116:16 - error: Return type of generator function must be compatible with "Generator[A, Any, Any]" +annotations_generators.py:118:16 - error: Return type of generator function must be compatible with "Generator[A, Any, Any]"   "Generator[A, Unknown, Unknown]" is not assignable to "Iterator[B]"     Type parameter "_T_co@Iterator" is covariant, but "A" is not a subtype of "B"       "A" is not assignable to "B" (reportReturnType) -annotations_generators.py:117:16 - error: Return type of generator function must be compatible with "Generator[int, Any, Any]" +annotations_generators.py:119:16 - error: Return type of generator function must be compatible with "Generator[int, Any, Any]"   "Generator[int, Unknown, Unknown]" is not assignable to "Iterator[B]"     Type parameter "_T_co@Iterator" is covariant, but "int" is not a subtype of "B"       "int" is not assignable to "B" (reportReturnType) -annotations_generators.py:133:16 - error: Return type of generator function must be compatible with "Generator[None, Any, Any]" +annotations_generators.py:135:16 - error: Return type of generator function must be compatible with "Generator[None, Any, Any]"   "Generator[None, int, Unknown]" is not assignable to "Generator[None, str, None]"     Type parameter "_SendT_contra@Generator" is contravariant, but "int" is not a supertype of "str"       "str" is not assignable to "int" (reportReturnType) diff --git a/conformance/results/pyright/callables_subtyping.toml b/conformance/results/pyright/callables_subtyping.toml index 134de40c9..53f09982d 100644 --- a/conformance/results/pyright/callables_subtyping.toml +++ b/conformance/results/pyright/callables_subtyping.toml @@ -67,10 +67,12 @@ callables_subtyping.py:119:23 - error: Type "StrArgs4" is not assignable to decl   "StrArgs4" is incompatible with protocol "IntStrArgs4"     "__call__" is an incompatible type       Type "(a: int, /, *args: str) -> None" is not assignable to type "(*args: int | str) -> None" +        Parameter 1: type "int | str" is incompatible with type "int" +          Type "int | str" is not assignable to type "int"         Parameter 2: type "int | str" is incompatible with type "str"           Type "int | str" is not assignable to type "str"         Parameter 1: type "*tuple[int | str, ...]" is incompatible with type "*tuple[str, ...]" -          "*tuple[int | str, ...]" is not assignable to "*tuple[str, ...]" (reportAssignmentType) + ... (reportAssignmentType) callables_subtyping.py:120:23 - error: Type "IntArgs4" is not assignable to declared type "IntStrArgs4"   "IntArgs4" is incompatible with protocol "IntStrArgs4"     "__call__" is an incompatible type diff --git a/conformance/results/pyright/qualifiers_final_annotation.toml b/conformance/results/pyright/qualifiers_final_annotation.toml index 7918a7498..38f55274a 100644 --- a/conformance/results/pyright/qualifiers_final_annotation.toml +++ b/conformance/results/pyright/qualifiers_final_annotation.toml @@ -37,6 +37,8 @@ qualifiers_final_annotation.py:147:10 - error: "x" is declared as Final and cann qualifiers_final_annotation.py:149:9 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) qualifiers_final_annotation.py:152:30 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) qualifiers_final_annotation.py:155:9 - error: "x" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) +qualifiers_final_annotation.py:166:1 - error: "TEN" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) +qualifiers_final_annotation.py:170:1 - error: "PI" is declared as Final and cannot be reassigned (reportGeneralTypeIssues) """ conformance_automated = "Pass" errors_diff = """ diff --git a/conformance/results/pyright/version.toml b/conformance/results/pyright/version.toml index bf9b4ead6..2854cd0a9 100644 --- a/conformance/results/pyright/version.toml +++ b/conformance/results/pyright/version.toml @@ -1,2 +1,2 @@ -version = "pyright 1.1.394" +version = "pyright 1.1.396" test_duration = 1.3 diff --git a/conformance/results/pytype/annotations_generators.toml b/conformance/results/pytype/annotations_generators.toml index af2954999..50bb6423c 100644 --- a/conformance/results/pytype/annotations_generators.toml +++ b/conformance/results/pytype/annotations_generators.toml @@ -46,26 +46,26 @@ async def generator9() -> int: # E: incompatible return type yield None # E \u001b[1m\u001b[31m~~~~~~~~~~~~~~\u001b[39m\u001b[0m -annotations_generators.py:99:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in : Bad return type 'IntIterator' for generator function generator15 [bad-yield-annotation] +annotations_generators.py:100:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in : Bad return type 'IntIterator' for generator function generator15 [bad-yield-annotation] def generator15() -> IntIterator: # OK \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m yield 0 \u001b[1m\u001b[31m~~~~~~~~~~~\u001b[39m\u001b[0m -annotations_generators.py:107:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in : Bad return type 'AsyncIntIterator' for async generator function generator16 [bad-yield-annotation] +annotations_generators.py:109:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in : Bad return type 'AsyncIntIterator' for async generator function generator16 [bad-yield-annotation] async def generator16() -> AsyncIntIterator: # OK \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m yield 0 \u001b[1m\u001b[31m~~~~~~~~~~~\u001b[39m\u001b[0m -annotations_generators.py:116:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in generator18: bad return type [bad-return-type] +annotations_generators.py:118:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in generator18: bad return type [bad-return-type] yield from generator17() # E: incompatible generator type \u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m -annotations_generators.py:117:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in generator18: bad return type [bad-return-type] +annotations_generators.py:119:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in generator18: bad return type [bad-return-type] yield from [1] # E: incompatible generator type \u001b[1m\u001b[31m~~~~~~~~~~~~~~\u001b[39m\u001b[0m @@ -76,7 +76,7 @@ errors_diff = """ Line 51: Expected 1 errors Line 87: Expected 1 errors Line 92: Expected 1 errors -Line 133: Expected 1 errors -Line 99: Unexpected errors ["annotations_generators.py:99:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in : Bad return type 'IntIterator' for generator function generator15 [bad-yield-annotation]"] -Line 107: Unexpected errors ["annotations_generators.py:107:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in : Bad return type 'AsyncIntIterator' for async generator function generator16 [bad-yield-annotation]"] +Line 135: Expected 1 errors +Line 100: Unexpected errors ["annotations_generators.py:100:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in : Bad return type 'IntIterator' for generator function generator15 [bad-yield-annotation]"] +Line 109: Unexpected errors ["annotations_generators.py:109:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in : Bad return type 'AsyncIntIterator' for async generator function generator16 [bad-yield-annotation]"] """ diff --git a/conformance/results/pytype/qualifiers_final_annotation.toml b/conformance/results/pytype/qualifiers_final_annotation.toml index 59ff384d8..7a9dd829a 100644 --- a/conformance/results/pytype/qualifiers_final_annotation.toml +++ b/conformance/results/pytype/qualifiers_final_annotation.toml @@ -4,6 +4,7 @@ Does not report Final variable with missing initialization. Does not reject Final instance variable declared outside of __init__ method. Does not reject modification of global variable declared Final. Does not reject modification of local variable declared Final. +Does not reject modification of imported variable declared Final. """ output = """ qualifiers_final_annotation.py:18:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in : Invalid type annotation 'Final[str, int]' [invalid-annotation] @@ -106,9 +107,19 @@ N(x="", y="") # E qualifiers_final_annotation.py:145:5: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in func2: Assigning to variable x, which was annotated with Final [final-error] - x += 1 # E: cannot modify Final value + x += 1 # E: cannot modify Final value \u001b[1m\u001b[31m~\u001b[39m\u001b[0m +qualifiers_final_annotation.py:164:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in : Can't find module '_qualifiers_final_annotation_1'. [import-error] + +from _qualifiers_final_annotation_1 import TEN +\u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m + +qualifiers_final_annotation.py:168:1: \u001b[1m\u001b[31merror\u001b[39m\u001b[0m: in : Can't find module '_qualifiers_final_annotation_2'. [import-error] + +from _qualifiers_final_annotation_2 import * +\u001b[1m\u001b[31m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u001b[39m\u001b[0m + """ conformance_automated = "Fail" errors_diff = """ @@ -123,5 +134,9 @@ Line 147: Expected 1 errors Line 149: Expected 1 errors Line 152: Expected 1 errors Line 155: Expected 1 errors +Line 166: Expected 1 errors +Line 170: Expected 1 errors Line 93: Unexpected errors ['qualifiers_final_annotation.py:93:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in : Class ClassCChild overrides final class attribute BORDER_WIDTH, defined in base class ClassC [final-error]'] +Line 164: Unexpected errors ["qualifiers_final_annotation.py:164:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in : Can't find module '_qualifiers_final_annotation_1'. [import-error]"] +Line 168: Unexpected errors ["qualifiers_final_annotation.py:168:1: \\x1b[1m\\x1b[31merror\\x1b[39m\\x1b[0m: in : Can't find module '_qualifiers_final_annotation_2'. [import-error]"] """ diff --git a/conformance/results/pytype/version.toml b/conformance/results/pytype/version.toml index 10c237d65..3cd350580 100644 --- a/conformance/results/pytype/version.toml +++ b/conformance/results/pytype/version.toml @@ -1,2 +1,2 @@ version = "pytype 2024.10.11" -test_duration = 34.9 +test_duration = 34.7 diff --git a/conformance/results/results.html b/conformance/results/results.html index ba1f3d8e2..c47b5d4c0 100644 --- a/conformance/results/results.html +++ b/conformance/results/results.html @@ -159,16 +159,16 @@

Python Type System Conformance Test Results

- - - + + diff --git a/conformance/tests/_qualifiers_final_annotation_1.py b/conformance/tests/_qualifiers_final_annotation_1.py new file mode 100644 index 000000000..b2521b19c --- /dev/null +++ b/conformance/tests/_qualifiers_final_annotation_1.py @@ -0,0 +1,7 @@ +""" +Used as part of the test for the typing.Final special form. +""" + +from typing import Final + +TEN: Final[int] = 10 diff --git a/conformance/tests/_qualifiers_final_annotation_2.py b/conformance/tests/_qualifiers_final_annotation_2.py new file mode 100644 index 000000000..603d8bcb6 --- /dev/null +++ b/conformance/tests/_qualifiers_final_annotation_2.py @@ -0,0 +1,7 @@ +""" +Used as part of the test for the typing.Final special form. +""" + +from typing import Final + +PI: Final = 3.14 diff --git a/conformance/tests/qualifiers_final_annotation.py b/conformance/tests/qualifiers_final_annotation.py index c20a82528..822ea564a 100644 --- a/conformance/tests/qualifiers_final_annotation.py +++ b/conformance/tests/qualifiers_final_annotation.py @@ -138,18 +138,33 @@ def func1(x: Final[list[int]]) -> None: # E def func2() -> None: global ID1 - ID1 = 2 # E: cannot modify Final value + ID1 = 2 # E: cannot modify Final value x: Final = 3 - x += 1 # E: cannot modify Final value + x += 1 # E: cannot modify Final value a = (x := 4) # E: cannot modify Final value - for x in [1, 2, 3]: # E: cannot modify Final value + for x in [1, 2, 3]: # E: cannot modify Final value pass - with open("FileName") as x: # E: cannot modify Final value + with open("FileName") as x: # E: cannot modify Final value pass (a, x) = (1, 2) # E: cannot modify Final value + + +# > If a module declares a ``Final`` variable and another module imports that +# > variable in an import statement by name or wildcard, the imported symbol +# > inherits the ``Final`` type qualifier. Any attempt to assign a different value +# > to this symbol should be flagged as an error by a type checker. + + +from _qualifiers_final_annotation_1 import TEN + +TEN = 9 # E: Cannot redefine Final value + +from _qualifiers_final_annotation_2 import * + +PI = 3.14159 # E: Cannot redefine Final value
 
mypy 1.15.0
-
1.8sec
+
1.7sec
pyright 1.1.394
+
pyright 1.1.396
1.3sec
pyre 0.9.23
-
6.5sec
+
6.8sec
pytype 2024.10.11
-
34.9sec
+
34.7sec
@@ -432,8 +432,8 @@

Python Type System Conformance Test Results

     qualifiers_final_annotation
Partial

Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition.

Does not allow conditional assignment of Final instance variable in __init__ method.

Does not allow redefinition of private class variable that is marked Final in parent class.

Does not report modification of local Final variable via "for" statement.

Pass
Partial

Does not report Final variable with missing initialization in module scope.

Does not report error for invalid nesting of Final and ClassVar.

Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition.

Partial

Does not report Final variable with missing initialization.

Does not reject Final instance variable declared outside of __init__ method.

Does not reject modification of global variable declared Final.

Does not reject modification of local variable declared Final.

Partial

Does not report Final variable with missing initialization in module scope.

Does not report error for invalid nesting of Final and ClassVar.

Does not treat use of Final name as if it was replaced by the literal in NamedTuple definition.

Does not reject modification of imported variable declared Final.

Partial

Does not report Final variable with missing initialization.

Does not reject Final instance variable declared outside of __init__ method.

Does not reject modification of global variable declared Final.

Does not reject modification of local variable declared Final.

Does not reject modification of imported variable declared Final.

     qualifiers_final_decorator Pass