Mypy does not recheck files when follow_imports changes for dependencies
Open
Nobody has claimed this yet.
bug
priority-0-high
topic-fine-grained-incremental
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Steps to reproduce
- Create module test.py with import from nonexistent module:
from foo import bar
- Create mypy.ini file:
[mypy]
[mypy-foo]
ignore_missing_imports = True
- Run
mypy
$ mypy test.py
Success: no issues found in 1 source file
- Comment out
[mypy-foo]section in mypy.ini
[mypy]
# [mypy-foo]
# ignore_missing_imports = True
- Run
mypy
$ mypy test.py
Success: no issues found in 1 source file
Expected result
After step 4, mypy should detect config change and (partially?) invalidate cache, leading to a type error.
$ mypy test.py
test.py:1: error: Cannot find module named 'foo'
test.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)
Notes
- Deleting
.mypy_cache/and re-runningmypyfixes the issue. - Adding/removing
ignore_missing_importsin the main[mypy]section does seem to invalidate the cache as expected. So this issue only seems to apply to[mypy-PATTERN]sections.
Versions
$ python --version
Python 3.7.3
$ mypy --version
mypy 0.740
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with test.py, mypy.ini, and the .mypy_cache/ directory using the configuration steps shown. Start by tracing cache invalidation for [mypy-PATTERN] sections and compare it with changes in the main [mypy] section. Done means changing the pattern section causes mypy to report the missing foo module without manually deleting the cache.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100