Skip to content

Do not cache module lookup results that may become invalid in future #19044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

sterliakov
Copy link
Collaborator

@sterliakov sterliakov commented May 6, 2025

Fixes #19037. See my analysis in #19037 for motivation. As a side note, with this patch the second run behaves as expected (without it mypy tries to reanalyze a lot of modules during the 2nd run, now it only rechecks the inputs with errors).

This comment has been minimized.

Copy link
Contributor

github-actions bot commented May 6, 2025

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

@sterliakov
Copy link
Collaborator Author

Okay, this is not the same cause as in #10360 and #16149 - they are surprisingly unrelated.

@sterliakov
Copy link
Collaborator Author

I don't see how to deal with the whole problem yet, but this looks like a sensible first step. The issue ultimately is that we treat namespace ancestors of typed packages as if they were typed. We only start doing that once we are actually aware of some nested typed subpackages, and this causes issues I linked above. At least removing the cache dependency is good IMO, but I'll need to look deeper to find a complete solution.

@sterliakov sterliakov marked this pull request as ready for review May 6, 2025 22:02
Copy link
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.

This looks good to me, thanks! Incremental mode bugs are usually pretty bad, and if users turn off incremental mode as a result, they will often get quite poor performance.

@JukkaL JukkaL merged commit 79ff4ff into python:master May 7, 2025
18 checks passed
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.

Empty vs filled cache inconsistency for google-cloud-logging & google-cloud-pubsub together with type: ignore comments
2 participants