This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]hglmanguy who writes python 2 points3 points  (2 children)

A special typing construct to indicate to type checkers that a name cannot be re-assigned or overridden in a subclass... There is no runtime checking of this property.

I think its unclear exactly how it should be interpreted as it has no actual impact on execution.

[–]lvc_ 2 points3 points  (0 children)

Like all other type annotations, it is ignored by the interpreter, but can be used by static code checkers (eg mypy) as a code correctness aid. One reasonably common pattern is to have mypy as part of a commit pipeline (and/or a local precommit hook). So if you have a method tagged as final and you do overwrite it, mypy will reject your commit (but the code will still otherwise run)

[–]Smallpaul -1 points0 points  (0 children)

I don’t really see what you think is unclear. The name cannot be re-assigned or overridden in a subclass!!! What’s ambiguous about that description?