Type annotations

Type annotations indicate the expected types of parameters, return values and variables. Python does not enforce them at runtime: they serve documentation, editors and static checkers such as mypy or pyright. The modern syntax uses list[int] and int | None.

Example

def moyenne(notes: list[float]) -> float | None: ...

Related concepts

The whole glossary