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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant