Skip to content
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

Fix daemon false positives related to module-level __getattr__ #16292

Merged
merged 3 commits into from
Oct 19, 2023

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Oct 19, 2023

In some cases, mypy daemon could generate false positives about imports targeting packages with a module-level __getattr__ methods. The root cause was that the mypy.build.in_partial_package function would leave a partially initialized module in the modules dictionary of BuildManager, which could probably cause all sorts of confusion. I fixed this by making sure that ASTs related to temporary State objects don't get persisted.

Also updated a test case to properly delete a package -- an empty directory is now actually a valid namespace package, so to delete a package we should delete the directory, not just the files inside it.

@github-actions
Copy link
Contributor

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

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

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

Good catch!

@JukkaL
Copy link
Collaborator Author

JukkaL commented Oct 19, 2023

The test failure seems like a common flake (I remember hearing about 3.8 failures on macOS).

@JukkaL JukkaL merged commit 1c218ea into master Oct 19, 2023
17 of 18 checks passed
@JukkaL JukkaL deleted the daemon-module-getattr branch October 19, 2023 23:13
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.

None yet

2 participants