On this page
typing.Final
Prev: typing.evaluate_forward_ref | Up: typing | Next: typing.final
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.Final
Tags: #public #python3 #stdlib #typing
Import
import typing
from typing import Final
Signature & Overview
typing.Final(*args, **kwds)
Special typing construct to indicate final names to type checkers.
Usage
from typing import Final
MAX_RETRIES: Final[int] = 3
assert MAX_RETRIES == 3
Gotchas
- Static check only: Python does not prevent reassigning
MAX_RETRIESat runtime—Finalis enforced bymypy/pyright.
REPL Inspect
from typing import Final
help(Final)
Linked from
Related notes
- tuts/python3/stdlib_module/typing/evaluate_forward_ref Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/final_func Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/typing/AbstractSet Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Annotated Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Any Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/assert_never Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/assert_type shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/AsyncContextManager shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/AsyncGenerator shared tags: #stdlib, #typing