Open ns-rse opened 1 year ago
Is this still and issue or a continuous? We're just tidying up the issue list :)
As numpydoc-validation is part of the pre-commit hooks, and thus needs typehints for functions and classes, can this be considered closed?
I don't think this can be closed yet until we have enabled a mypy
pre-commit
hook so that we are consistently checking that type hints are always correct.
If I run mypy topostats
against main
I get the following that needs fixing...
❱ mypy topostats
...
Found 544 errors in 30 files (checked 35 source files)
On the tests/
directory there are...
❱ mypy tests --exclude tests/measure/conftest.py --exclude tests/tracing/conftest.py
...
Found 824 errors in 51 files (checked 32 source files)
So we're a long way off achieving correct typehints that pass mypy
.
Whilst incredibly useful in the long run its not a particularly fun task to undertake and other tasks (features) take priority.
Typehints (see PEP484) make it easier to read and understand code (by default the "type" of objects in Python is dynamically determined and can change, adding typehints clarifies intent). Newer code that has been developed includes typehints.
The MonkeyType tool can be used to determine and apply types across an existing code base and the pytest-monkeytype package facilitates applying this to existing code bases.
Once in place we can then introduce type checkers such as mypy into the pre-commit pipeline.