| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
When the mypy cache is corrupt (e.g. partially overwritten), mypy used to crash with an INTERNAL ERROR. Now it reports an actionable error that tells the user to remove the cache directory (or pass a different --cache-dir) and re-run. This covers corruption detected while reading/deserializing the cache data file, while resolving cache metadata, while fixing cross-references after deserialization, and the deferred "TypeInfo not fixed" assertion that would otherwise surface deep inside type checking. Fixes python#22220
for more information, see https://pre-commit.ci
|
Diff from mypy_primer, showing the effect of this PR on open source code: scipy-stubs (https://github.com/scipy/scipy-stubs)
+ tests/misc/test_submodules_empty.pyi:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
When the mypy cache is corrupt (for example, partially overwritten in a shared/temp directory), mypy used to crash with an INTERNAL ERROR. This PR replaces that with an actionable error telling the user to remove the cache directory (or pass a different --cache-dir) and re-run.
Fixes #22220
How it works
The fix adds guards on every cache-read path in mypy/build.py:
All paths now report a blocker error such as:
Reproduction / verification
Before the fix, a corrupt cache produces:
After the fix:
A new regression test (mypy/test/testcache.py) populates the cache, corrupts the cached data file (preserving mtime so the cache is still trusted), and asserts the next build fails with a clean "corrupt cache" error and without an INTERNAL ERROR. The test fails on the unguarded code (raw AssertionError / INTERNAL ERROR) and passes with the fix.
Test plan