nose2 icon indicating copy to clipboard operation
nose2 copied to clipboard

Add typing to improve the code

Open JCHacking opened this issue 1 year ago • 2 comments

Add hint typing to the code and use a tool like mypy to analyze it, this can improve development and also prevent bugs.

JCHacking avatar Apr 14 '24 10:04 JCHacking

Also worth noting: with the increasing prevalence of IDE assistive features driven by typing, this could help contributors in a variety of ways.

I've taken a few projects from the pre-typing era into fully typed codebases. The successful ones start small and treat it as a priority to chip away at missing types piece by piece. Once we get far enough along, mypy can be configured to be relatively strict (no-untyped-defs, etc) with excludes for the handful of broken modules.

Once thing which is somewhat controversial is that I'm not a fan of type checking a test suite -- in many cases, it's unhelpful, and you may want to call APIs with mocks or other "unsafe types" to exercise runtime behaviors.

Overall, strong 👍 from me, as long as we start small and lenient, and tighten things up very gradually.

sirosen avatar Apr 15 '24 13:04 sirosen

I am of the same opinion, obviously this is a change that has to be done slowly and avoid breaking anything. It is not something that can be done in one day.

JCHacking avatar Apr 15 '24 15:04 JCHacking