Typing and Generics
typing.final
Marks a class as not subclassable or a method as not overridable for static tools. Python does not enforce these restrictions at runtime; since 3.11 the decorator attempts to set __final__.
Formal Syntax & Structure
python syntaxpython
@typing.finalParameters & Attributes
| Name | Type | Description |
|---|---|---|
| target | class or callable | Object to decorate. |
Return Value
class or function
Typing construct or runtime result as described; static typing rules are not runtime validation.
Working Example
Example Snippetpython
from typing import final
@finalclass Token: passprint(getattr(Token,'__final__',False))