This is function annotations. It can be use to attach additional information to the arguments or a return values of functions. It is a useful way to say how a function must be used.
Functions annotations are stored in a function’s __annotations__
attribute.
Use Cases (From documentation)
-
Providing typing information
- Type checking
- Let IDEs show what types a function expects and returns
- Function overloading / generic functions
- Foreign-language bridges
- Adaptation
- Predicate logic functions
- Database query mapping
- RPC parameter marshaling
-
Other information
- Documentation for parameters and return values
From python-3.5
it can be used for Type Hints