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
For decorators that work on methods as descriptors, I do type-hint+overload __get__ as returning the descriptor or filling in self. This previously worked up to MyPy 1.11 and PyRight was/is happy with it. However, since version 1.12 MyPy no longer matches the overload and completely loses type information; the Possible overload variant suggested is the least suitable.
hauntsaninja
changed the title
[Regression] MyPy >=1.12 no longer recognises descriptors/get that bind self
[1.12 regression] mypy no longer recognises descriptors/get that bind self
Oct 24, 2024
ParamSpec types can match arbitrary parameter types, so treat
them as having 'object' as the upper bound.
This also fixes issues with filtering of overload items based on self type.
Fixes#18036.
Bug Report
For decorators that work on methods as descriptors, I do type-hint+overload
__get__
as returning the descriptor or filling inself
. This previously worked up to MyPy 1.11 and PyRight was/is happy with it. However, since version 1.12 MyPy no longer matches the overload and completely loses type information; thePossible overload variant
suggested is the least suitable.I initially was notified about this for my own library providing
async
versions of the standard library, specifically thelru_cache
. An MRE not using my library is below (in case I missed something that makes the MRE fixable but not my library, this would be good to know, too).To Reproduce
Playground link. The ordering of the
overload
cases does not matter.Expected Behavior
MyPy should correctly infer the type of the bound method. MyPy should report the most suitable overload.
Actual Behavior
MyPy matches none of the overloads and thus completely loses type information. The reported most suitable overload is actually the least suitable.
Your Environment
mypy.ini
(and other config files): defaultsThe text was updated successfully, but these errors were encountered: