REF: Introduce typing and type hints #965
Labels
docs
Documentation and tutorials
enhancement
New feature or request
maint
Maintenance
refactor
testing
Milestone
As per George’s recommendation, we should introduce type hints and typing to our code. This enables use of checkers like mypy https://www.mypy-lang.org/ , which can help with debugging and testing. I believe this is especially helpful with scientific computing in particular:
int
because of a bug or dependency change. Your analysis code (and tests) may process this as if it is a valid scientific output, and pass, but type checking would have prevented this at the beginning.This may make the frequent use of
externals/mne.py::_validate_type()
unnecessary.If we want something similar to
_validate_type()
that runs EVERY time the code is used at runtime, then once we add our type-hints to our function signatures, we could try using https://github.com/RussBaz/enforce . That way, we get all the advantages of typing using the language-standard way, but also enforce our runtime checks. I personally think that usingmypy
at commit-time, instead of every run-time, is good enough, however.mypy
recommends starting small, and has some great advice for the order in which to gradually add type checking to our code: https://mypy.readthedocs.io/en/stable/existing_code.html .The text was updated successfully, but these errors were encountered: