> Support for type hints was introduced in Python 3.5. Type hints make it easier to read and review code in my opinion. Also an IDE may discover a potential bug sooner. Yet, as PEP 484 says: "It should also be emphasized that Python will remain a dynamically typed language, and the authors have no desire to ever make type hints mandatory, even by convention."
>
> Mypy is used to do the type checking. The package is standard so there is little chance that it will be abandoned. Mypy checks that type hints in source code are correct when they are not, it fails with an error.
>
> Useful resources:
>
> * https://docs.python.org/3.5/library/typing.html
> * https://www.python.org/dev/peps/pep-0484/
Note: Core still depended on python 3.5 when this was merged, so they had to use old style "type comments". With Python 3.6, it becomes possible to use the typehint syntax for variables and attributes. Unfortunately Postponed Evaluation of Annotations is only available starting from python 3.7, so for now e have to use quotes when annotating types (classes) that are only defined later in a module.
This is a backport of [[https://github.com/bitcoin/bitcoin/pull/18210 | core#18210]]
Note: Core still depended on python 3.5 when this was merged, so they
had to use old style "type comments". With Python 3.6, it becomes
possible to use the typehint syntax for variables and attributes.
Unfortunately Postponed Evaluation of Annotations is only available
strating from python 3.7, so for now we have to use quotes when
annotating types (classes) that are only defined later in a module.Depends on D9270