Description
TL;DR: some errors prevent mypy
from further checking the project and this should be clearly stated in the log.
I was trying to add mypy
type-checks to a big Python project. The branch I reproduced this problem on is: https://github.com/marmistrz/golem/blob/mypy-quirks
There's a defective function here which is properly linted with
$ mypy --ignore-missing-imports --strict-optional golem/model.py
golem/model.py:143: error: Item "None" of "Optional[Node]" has no attribute "to_json"
But now any of these:
mypy golem --ignore-missing-imports --strict-optional
mypy -m golem --ignore-missing-imports --strict-optional
mypy -p golem --ignore-missing-imports --strict-optional
doesn't yield that result (the variants golem
and -p golem
yield other errors but not this, -m golem
yields no results)
What's more interesting, if I run
mypy golem/network --ignore-missing-imports --strict-optional
the same error, in golem/model.py
is detected! Even an xargs
invocation failed...
What was the problem? The second error message!
golem/core/async.py:34: error: Name 'default_errback' already defined on line 17
apps/rendering/resources/imgrepr.py:181: error: invalid type comment or annotation
The annotation was indeed incorrect:
def load_as_PILImgRepr(file_) -> PILImgRepr():
The second error made mypy
abort further checking. It should be stated more clearly that this error prevents further scanning (e.g. even with capitals). This is very important when introducing incremental linting (only banning new findings) and it really puzzled me for some time that my mistake was not detected.