Skip to content

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

Merged
JukkaL merged 3 commits into
masterfrom
daemon-module-getattr
Oct 19, 2023
Merged

Fix daemon false positives related to module-level __getattr__#16292
JukkaL merged 3 commits into
masterfrom
daemon-module-getattr

Conversation

@JukkaL

@JukkaL JukkaL commented Oct 19, 2023

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Contributor

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

@JukkaL
JukkaL requested a review from ilevkivskyi October 19, 2023 22:46

@ilevkivskyi ilevkivskyi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch!

@JukkaL

JukkaL commented Oct 19, 2023

Copy link
Copy Markdown
Collaborator Author

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
@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.

2 participants