Bug Report
I'm getting a bunch of false positives when reusing .mypy_cache in CI and refactoring the code base. They disappear after clearing the CI mypy cache, so they must be related to the cache.
To Reproduce
I'm not sure about the exact steps. This is what I've gathered so far:
- Run mypy on an existing project
- Rename some module
- Re-run mypy
I was able to reproduce the "reverse" of the original issue locally in the repo (closed source) by running mypy in a branch containing a refactor, switching back to the default branch, and re-running mypy. I then got the same type of errors, but complaining that the modules in the refactor branch could not be found.
Only the first run of mypy fails. Subsequent runs "understand" that some code has been renamed, and no longer produces any errors.
Expected Behavior
The code should pass validation on the first try without having to clear the cache.
Actual Behavior
some/path/__init__.py:1: error:
Cannot find implementation or library stub for module named
"project.module.submodule" [import-not-found]
from collections import defaultdict
^
Clearly the built-in collections module import doesn't depend on a project-internal module, so this error message is nonsensical.
Your Environment
- Mypy version used: 1.15.0
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini (and other config files): pyproject.toml.txt
- Python version used: 3.12.11
Bug Report
I'm getting a bunch of false positives when reusing
.mypy_cachein CI and refactoring the code base. They disappear after clearing the CI mypy cache, so they must be related to the cache.To Reproduce
I'm not sure about the exact steps. This is what I've gathered so far:
I was able to reproduce the "reverse" of the original issue locally in the repo (closed source) by running
mypyin a branch containing a refactor, switching back to the default branch, and re-running mypy. I then got the same type of errors, but complaining that the modules in the refactor branch could not be found.Only the first run of
mypyfails. Subsequent runs "understand" that some code has been renamed, and no longer produces any errors.Expected Behavior
The code should pass validation on the first try without having to clear the cache.
Actual Behavior
Clearly the built-in
collectionsmodule import doesn't depend on a project-internal module, so this error message is nonsensical.Your Environment
mypy.ini(and other config files): pyproject.toml.txt