Skip to content

Conversation

@michaels-lyft
Copy link
Contributor

@michaels-lyft michaels-lyft commented Apr 21, 2021

When an interface is inherited, the classes that implement the parent interface are being checked for methods required by the child interface.

Example

from interface import Interface, implements

class Foo(Interface):
  def foo(self, a: str) -> str:
    pass

class Bar(Foo):
  def bar(self, b: str) -> str:
    pass

class Far(implements(Foo)):
  def foo(self, a: str) -> str:
    return a

far = Far()
far.foo("a")

When I run the above code, I get the following error

interface.interface.InvalidImplementation:
class Far failed to implement interface Foo:

The following methods of Foo were not implemented:
  - bar(self, b: str) -> str

The fix is to make a copy of the parent's signature in the merge function.

@michaels-lyft
Copy link
Contributor Author

@ssanderson

@ssanderson
Copy link
Owner

hey @michaels-lyft . Thanks for the PR. These changes look good to me. I appreciate you updating the tests as well.

It looks like the CI build is failing because I have the version of black in pre-commit pinned to stable, and there's been a breaking change on that branch. I'm going to merge this in and then will fix that CI issue and cut a release with the fix.

@ssanderson ssanderson merged commit 4f9a396 into ssanderson:master Apr 21, 2021
@ssanderson
Copy link
Owner

1.6.1 has been released: https://pypi.org/project/python-interface/1.6.1. Thanks!

@michaels-lyft
Copy link
Contributor Author

Thanks for the quick release!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants