Unify handling of self attributes in daemon#21025
Open
ilevkivskyi wants to merge 3 commits intopython:masterfrom
Open
Unify handling of self attributes in daemon#21025ilevkivskyi wants to merge 3 commits intopython:masterfrom
ilevkivskyi wants to merge 3 commits intopython:masterfrom
Conversation
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There are two situations that require special handling in the daemon:
selfin a method.The first one is an old thing that is handled with so called "saved attributes", while the second is a recent addition handled by including relevant methods in the top-level target. Two different mechanisms with subtle differences for two similar situations make it hard to reason about what is going on in the daemon. And it will be even more complicated when we will add "staggered" interface/implementation type-checking in parallel checking, that will need to handle these situations as well.
Although this PR is strictly speaking not required for parallel checking, I propose to unify all four quadrants in the (defined variable vs inferred variable type) x (parallel checking vs daemon) square under the same mechanism: have a single flag on a function/method that specifies that this function/method may affect interface of the module, and thus should be always processed as a part of the module top-level.
This is a relatively significant change in the daemon, but IMO it is (much) cleaner, and we will probably need to rip off this band-aid sooner or later anyway. I didn't do this in my initial implementation of partial
Nonetype support, because I didn't want to touch the daemon more than strictly necessary (as I did in some of my other recent PRs), but now it seems to me that doing so creates too much tech-debt to address later.