Definition
An annotation of a function parameter or return value.
Function annotations are usually used for
type hints: for example, this function is expected to take two
int
arguments and is also expected to have an int
return value:
def sum_two_numbers(a: int, b: int) -> int:
return a + b
Function annotation syntax is explained in section Function definitions.
See variable annotation and PEP 484, which describe this functionality. Also see Annotations Best Practices for best practices on working with annotations.