Add type hinting
See original GitHub issueLargely copy/pasted from https://github.com/ethereum/py-evm/issues/1398
Background
Type hints allow us to perform static type checking, among other things. They raise the security bar by catching bugs at development time that, without type support, may turn into runtime bugs.
This stackoverflow answer does a great job at describing their main benefits.
What is wrong?
This library currently does not have any type hints.
This needs to be fixed by:
- Adding all missing type hints.
- Enforcing (stricter) type checking in CI
How
There does exist tooling (monkeytype) to the generation of type hints for existing code bases. From my personal experience monkeytype can be helpful but does still require manual fine tuning. Also, manually adding these type hints does serve as a great boost to the general understanding of the code base as it forces one to think about the code.
-
Run
mypy --follow-imports=silent --warn-unused-ignores --ignore-missing-imports --no-strict-optional --check-untyped-defs --disallow-incomplete-defs --disallow-untyped-defs --disallow-any-generics -p eth -
Eliminate every reported error by adding the right type hint
Because this library supports older versions of python, the type hints will not be able to use the modern python3.6 syntax.
Definition of done
This issue is done when the following criteria are met:
mypyis run in CI
Add a new command to the flake8 environment in the tox.ini file that runs:
mypy --follow-imports=silent --warn-unused-ignores --ignore-missing-imports --no-strict-optional --check-untyped-defs --disallow-incomplete-defs --disallow-untyped-defs --disallow-any-generics -p py_ecc`
- Usage of
type: ignore(silencing the type checker) is minimized and there’s a reasonable explanation for its usage
Stretch goals
When this issue is done, stretch goals can be applied (and individually get funded) to tighten type support to qualify:
mypy --strict --follow-imports=silent --ignore-missing-imports --no-strict-optional -p py_ecc
Issue Analytics
- State:
- Created 5 years ago
- Comments:47 (29 by maintainers)

Top Related StackOverflow Question
@gitcoinbot is it possible to re-activate this bounty to be paid towards @Bhargavasomu
This issue ended up being blocked/delayed by some other deeper work that Somu did on the library and it’s just now been completed.
@pipermerriam I think this bounty be closed with #63.