-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
I'm finding it's quite common to have Python Libraries using mixins with signatures that mypy considers to be conflicting because one takes a different set of kwargs than the other. For example - https://github.com/pallets/itsdangerous/blob/master/itsdangerous.py#L881-L886 (which is simplified below).
class A(object):
def load(self, payload):
pass
class B(object):
def load(self, payload, return_header=False):
pass
def dump(self, obj):
pass
class C(A, B):
passIn this case, mypy will complain that A and B have conflicting signatures for load. In practice, Python will always dispatch load calls to A so C's signature for load should be load(self, payload). It would be incorrect to pass return_header to C().load.
What are your thoughts on having mypy reflect what Python will do at runtime here and just take the definition of A's load instead of throwing an error? The only way around this currently is to add **kwargs to As signature which is less safe.