SIGN IN SIGN UP

Fix skipped imports considered stale (#21639)

Fixes https://github.com/python/mypy/issues/21102

When the option `follow_imports = skip` is used, dependency states that
are initially considered skipped might have their reason changed to not
found in `load_graph`.

If on the first mypy run, a given suppressed module is written to cache
with its suppression reason set to skipped, and it's overridden to not
found in a subsequent mypy run, then `suppressed_deps_opts` between the
cache and the current run won't match and the module will be considered
stale.

To fix the issue, change the unconditional overwrite to `setdefault`.

This also affects mypyc as the dependency being considered stale means
that mypyc will needlessly recompile it instead of reading from cache.
Add a unit test to confirm that the dependency output files are not
overwritten with the fix.
P
Piotr Sawicki committed
24335663f560c3e2b1311464f0edd80e88ea5ff8
Parent: 3179030
Committed by GitHub <noreply@github.com> on 6/24/2026, 3:04:30 PM