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
This code requires a type annotation, which is a regression from mypy 0.910:
x = getattr(object(), 'a', []) # Need type annotation for "x"
The signature of getattr was changed relatively recently, and it causes the issue. The new signature is better than old one, but this case got worse.
I'm not sure what would be the best way to deal with this, but there are at least these plausible options:
Implement a plugin hook that deals with getattr.
Somehow improve type inference in this case.
Modify the signature of getattr to make the problem go away by providing e.g. Iterable[Any] as the context in an overload variant. This would be pretty ad hoc though.
This is not blocking the 0.920 release, since the workaround is straightforward and this doesn't seem to come up very often.