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
{{ message }}
Repository navigation
[1.16] Regression in inferring type via unittest.mock.Mock #19184
Regression on type inference found in aiohttp:master.
Seems like the regression may be related to inheriting from Any (which mypy complains about, but is done in typeshed regardless, and has been for many years).
(First error disappears if we actually import Mock.)
test.py:6: error: Class cannot subclass "Any" (has type "Any") [misc]
Found 1 error in 1 file (checked 1 source file)
1.16 Behavior
test.py:6: error: Class cannot subclass "Any" (has type "Any") [misc]
test.py:19: error: Need type annotation for "t" [var-annotated]
Found 2 errors in 1 file (checked 1 source file)
Actually it looks like it was caused by #18587 because we consider that a class with fallback to any may be a metaclass. Maybe we can not do this here, since that special case was added specifically to ignore spurious Anys from type.__call__() IIRC. I will play with this.
Activity
ilevkivskyi commentedon May 31, 2025
Hm, if subclassing
Anyis important here, I think there is a chance this is related to #8829 (on which I am going to work soon).ilevkivskyi commentedon May 31, 2025
Actually it looks like it was caused by #18587 because we consider that a class with fallback to any may be a metaclass. Maybe we can not do this here, since that special case was added specifically to ignore spurious
Anys fromtype.__call__()IIRC. I will play with this.Tighten metaclass __call__ handling in protocols (#19191)
Tighten metaclass __call__ handling in protocols (#19191)