Description
Bug Report
I have in my environment a bunch of packages in the nr
namespace packages (e.g. nr.preconditions
, nr.stream
, nr.optional
, etc.). When using Mypy to check my package, every other invokation (starting with the first time), it shows errors that the type hints for the nr
module cannot be found.
The nr.*
packages I listed above and also the databind
packages check out with Mypy individually. It seems that only every other invokation, Mypy understands that it doesn't need to look for type hints for nr
because it is just a namespace package. The nr/__init__.py
file is the same for all of these packages with the following content:
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
What also surprises me is that Mypy seems to be checking the validity of dependencies? (I.e. source code in .venv
) My understanding was that Mypy axiomatically assumes the correctness of type hints in dependencies and only fully checks static typing in the files/directories specified on the CLI.
To Reproduce
I'm having a bit of a hard time to find a small example to reproduce this issue consistently. The project where I experience this is internal, so I can't share the entire project. Until I find a definitive reproduction scenario, happy to take any advice or answer questions.
Expected Behavior
Mypy does not look for type hints for the nr
namespace.
Your Environment
- Mypy version used: 0.910
- Mypy command-line flags: n/a
- Mypy configuration options from
mypy.ini
(and other config files): n/a - Python version used: 3.9.6
- Operating system and version: OSX