You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consistently store settable property type (#18774)
Fixes#18764
There are two things important to understand this PR:
* First, mypy has a performance optimization - we store
decorator/overload type during semantic analysis in certain "trivial"
situations (to avoid deferrals). Otherwise, we infer the type of
decorated function or an overload variant during type checking.
* Second, for settable properties we store getter type in two places, as
a `Var.type` of getter (as a decorator), and also in overall
`OverloadedFuncDef.type`. The latter is ugly, but unfortunately it is
hard to get rid of, since some code in multiple plugins rely on this.
It turns out there are _three_ inconsistencies in how these two things
interact (first one causes the actual crash):
* For trivial settable properties (i.e. without extra decorators) when
we store the type in `semanal.py` we only store it the second way (i.e.
as `OverloadedFuncDef.type`).
* For non-trivial settable properties (where getter and/or setter are
themselves decorated), we only set the inferred type the first way (as
`Var.type`).
* When inferring setter type (unlike getter, that is handled correctly)
we actually ignore any extra decorators (this is probably quire niche,
but still inconsistent).
Essentially I simply remove these inconsistencies.
0 commit comments