Skip to content

Working with interfaces in separate files not working? #30

@nagreme

Description

@nagreme

I've implemented an interface in one file let's call it A.py:

from interface import Interface

class A(Interface):
  def method1(self):
    pass

And when I try to import and use it in another file, say B.py:

from interface import implements
import A

class B(implements(A)):
  def method1(self):
    print("foo")

b = B()
b.method1()

When I run B.py or whenever I try to import B I get this error:

Traceback (most recent call last):
  File "B.py", line 4, in <module>
    class B(implements(A)):
  File "/home/nagreme/.local/lib/python3.6/site-packages/interface/interface.py", line 490, in implements
    if not issubclass(I, Interface):
TypeError: issubclass() arg 1 must be a class

If I put the implementation of A in the same file it works but that isn't really convenient for bigger projects with several more complex implementing classes: is there any way to fix this or work around it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions