Skip to content

Subclasses in typed arguments #42

Description

@isaaclok

Hi, first of all thanks for this amazing library!
I have a problem though, when using interfaces with typed arguments. As I understand it, if a function accept argument of class A, if B inherits from A, it should also be accepted.

But when I try this code

from interface import Interface, implements
class A:
    pass

class B(A):
    pass

class I(Interface):
    def my_func(self, a: A):
        pass

class C(implements(I)):
    def my_func(self, a: B):
        pass

it throws this error

interface.interface.InvalidImplementation: 
class C failed to implement interface I:
The following methods of I were implemented with invalid signatures:
  - my_func(self, a: __main__.B) != my_func(self, a: __main__.A)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions