[pep-0591] clarify that type checkers may not allow `Final` in loops (#1033)
This commit is contained in:
parent
7fc318e844
commit
3e293e68e9
|
@ -175,8 +175,9 @@ names in type-checked code::
|
|||
RATE = 300 # Error: can't assign to final attribute
|
||||
Base.DEFAULT_ID = 1 # Error: can't override a final attribute
|
||||
|
||||
for x in [1, 2, 3]:
|
||||
FOO: Final = x # Error: Cannot use Final inside a loop
|
||||
Note that a type checker need not allow ``Final`` declarations inside loops
|
||||
since the runtime will see multiple assignments to the same variable in
|
||||
subsequent iterations.
|
||||
|
||||
Additionally, a type checker should prevent final attributes from
|
||||
being overridden in a subclass::
|
||||
|
|
Loading…
Reference in New Issue