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
MyPy gives errors because of the super-calls, which is addressed by #4001.
It would be nice for Inherited to ensure in its super-call that x has the right type, which is the topic of #4441 although it would also be nice for Final's constructor to only accept x, y, and z. I can't find any issue for that.
This example is done with __init__, but the problem can occur in any such “augmenting” method pattern. It is not restricted to __init__. This augmenting pattern always needs a top level method in some class. In __init__'s case, it's in object.
One idea is to have a special annotation on **kwargs, for example, typing.Collector? MyPy could then figure out the necessary arguments and their types in all derived classes. An inherited class would only be allowed to explicitly forward variables accepted by parents, but they should be able to forward anything. MyPy would make a best effort to ensure that all required arguments get in somehow.
I recognize that not everyone is a fan of cooperative MI, but I personally think it's quite beautiful. I would love to see MyPy handle it elegantly.
The text was updated successfully, but these errors were encountered:
Consider annotating this example of cooperative multiple inheritance:
MyPy gives errors because of the super-calls, which is addressed by #4001.
It would be nice for
Inherited
to ensure in its super-call thatx
has the right type, which is the topic of #4441 although it would also be nice forFinal
's constructor to only acceptx
,y
, andz
. I can't find any issue for that.This example is done with
__init__
, but the problem can occur in any such “augmenting” method pattern. It is not restricted to__init__
. This augmenting pattern always needs a top level method in some class. In__init__
's case, it's inobject
.One idea is to have a special annotation on
**kwargs
, for example,typing.Collector
? MyPy could then figure out the necessary arguments and their types in all derived classes. An inherited class would only be allowed to explicitly forward variables accepted by parents, but they should be able to forward anything. MyPy would make a best effort to ensure that all required arguments get in somehow.I recognize that not everyone is a fan of cooperative MI, but I personally think it's quite beautiful. I would love to see MyPy handle it elegantly.
The text was updated successfully, but these errors were encountered: