Closed adamtheturtle closed 1 year ago
To be honest, I'm not worried (or that keen...) to have type annotations on unit tests checked - their execution is a much more valid check of anything...
Type annotations seem valuable on the code that's shipped, should we just exclude the tests folder from consideratiob by mypy instead?
We can always run mypy
only against sybil/
and not against tests/
and then drop this PR and others.
My experience with my own libraries is that it is useful to have a type-hinted consumer of the library which is type checked. It tells me "What is it like to use the library as a type-safe consumer?", and I have found issues like that. For example, if using my library in a type-safe way requires a private import. For my own projects, I find type checking a really good way of finding bugs very quickly, and understanding the causes of bugs. Those bugs are sometimes in the tests, and so I can write tests more quickly.
All of that is a trade-off versus the work and verbosity of type hints. If you choose to close this then I will continue but only on the sybil/
folder.
Yeah, let's not run mypy
against tests/
.
My experience has been the opposite: I have a 100% line coverage baseline for all my open source projects, and I find that catches stuff way before mypy. There's also testing where I want to ensure that run-time passing of the incorrect type is handled correctly, which adds annoyance.
Interesting question: is the stuff indocs/examples
currently checked? I think it probably should be, since those are user-facing examples.
Interesting question: is the stuff indocs/examples currently checked? I think it probably should be, since those are user-facing examples.
I have not been checking those, but it can be done by running mypy docs/
.
This change removes all errors with the code
func-returns-value
when runningmypy --strict sybil tests
, and it is one step towards havingmypy
passing and shipping type hints.Previous errors looked like:
I have tried to find a balance between checking for the side-effects of
evaluate
, and not losing the original intentions of confirming that the method returnsNone
. I think that intention is now met by the type checker, but I added twotype: ignore
s for extra safety.