This is an instance of python3 type hinting. The use of -> 'None'
indicates that the function does not have a return statement.
List[str]
is more interesting: The List
part indicates it will return a list type, and its argument [str]
indicates it is a parameterized type. In practice, python lists may contain any type of object, but in strongly-typed language a list is a homogeneous collection.
Using this hint both indicates to a caller of the function that s
must contain only strings, thus avoiding any exceptions for whatever operation will be performed, and it also indicates to an intelligent IDE (e.g. PyCharm, VSCode) that the objects contained in the list have string instance methods for autocompletion indicators.
The python interpreter does not do anything with this information in terms type checking, however the mypy interpreter will typecheck your code.
For more information see PEP 484 and the typing module, which has also been backported to pre-3.5 python3 and 2.7.