It's type hints added in Python 3.5.
So it's
So if run in Python 3.6 no error massage is generated,
have to use 3-party library like mypy to get a error message about wrong types.
Example:
So it's
hints
and not forced yet maybe in 3.7.So if run in Python 3.6 no error massage is generated,
have to use 3-party library like mypy to get a error message about wrong types.
Example:
hello.py
def greeting(name: str) -> str: return f'Hello {name}' print(greeting('Kent'))
hello_int.py
def greeting(name: str) -> str: return f'Hello {name}' print(greeting(100))With mypy
pip install mypy
E:\1 λ mypy hello.py # No error E:\1 λ mypy hello_int.py hello_int.py:4: error: Argument 1 to "greeting" has incompatible type "int"; expected "str"