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.final

Parameters & Attributes

NameTypeDescription
targetclass or callableObject 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))
Python Reference