mypy
0e6cfd41 - Unify handling of self attributes in daemon (#21025)

Commit
104 days ago
Unify handling of self attributes in daemon (#21025) There are two situations that require special handling in the daemon: * When we have an attribute _defined_ on `self` in a method. * When a variable defined in class body is _inferred_ using an assignment in 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 `None` type 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.
Author
Parents
Loading