Closed Teashrock closed 3 years ago
Annotations are not specifically type hints; their values are arbitrary and not checked in any way by the runtime or compiler as their meaning is up to the user.
Ref Python:
Python 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> x: int = "A string!"
>>> __annotations__
{'x': <class 'int'>}
>>> def some_random_func(a_float_variable: str) -> None:
... return int(a_float_variable)
...
>>> some_random_func(3.1415)
3
>>> some_random_func.__annotations__
{'a_float_variable': <class 'str'>, 'return': None}
Python PEP on function annotations: https://www.python.org/dev/peps/pep-3107/
Thank you very much.
It shouldn't be like this, I suppose.