Skip to content

Fix staleness on changed follow imports options#20773

Merged
ilevkivskyi merged 2 commits intopython:masterfrom
ilevkivskyi:fix-follow-imports-changed
Feb 12, 2026
Merged

Fix staleness on changed follow imports options#20773
ilevkivskyi merged 2 commits intopython:masterfrom
ilevkivskyi:fix-follow-imports-changed

Conversation

@ilevkivskyi
Copy link
Copy Markdown
Member

This fixes the coarse grained part of #7777. I do not change semantics for daemon for two reasons:

  • Performance penalty from this fix will be minor for regular incremental, but may be well visible for the daemon.
  • And (more importantly) and just don't want to open this another can of worms (yet).

Some notes:

  • The general logic is straightforward, invalidate dependent modules, if import options for their dependencies changed.
  • It looks like the problem only affects suppressed dependencies, in all other situations we either already invalidate because something gets added to/removed from dependencies (e.g. when follow_imports = skip <-> normal), or there is no effect on the caller/importer (e.g. when follow_imports = normal <-> silent).
  • This requires another entry for CacheMeta but good new is I have an idea how to get rid of another entry I added in one of recent PRs. Essentially I will need to record early (import) errors anyway to send to parallel workers after we switch to parallel parsing, and if we do this we won't need the imports_ignored entry.

@ilevkivskyi ilevkivskyi requested a review from JukkaL February 9, 2026 14:46
@github-actions

This comment has been minimized.

@JukkaL
Copy link
Copy Markdown
Collaborator

JukkaL commented Feb 11, 2026

Not a full review, but I measured performance on a huge internal codebase, and I couldn't see any regression. So performance impact looks minimal.

@github-actions
Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Copy Markdown
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this old but quite annoying issue! The approach looks good.

@ilevkivskyi ilevkivskyi merged commit fe6fe1d into python:master Feb 12, 2026
23 checks passed
@ilevkivskyi ilevkivskyi deleted the fix-follow-imports-changed branch February 12, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants