ksindi / implements

:snake: Pythonic interfaces using decorators
http://implements.readthedocs.io/
Apache License 2.0
33 stars 4 forks source link

TypeError when implementation has a property decorator while the interface doesn't #10

Closed pshirali closed 4 years ago

pshirali commented 4 years ago

The following test fails with a TypeError

def test_property_inverse():
    class FooInterface(Interface):
        def foo(self):      <--- interface defines a regular method
            pass

    with pytest.raises(NotImplementedError):
        @implements(FooInterface)
        class FooImplementationFail:
            @property
            def foo(self):  <--- implementation defines a property
                pass

In verify_methods

cls_signature = inspect.signature(cls_method) if cls_method else None
                ^

With a @property decorator, a method is no longer callable. inspect.signature expects a callable. Fix: if cls_method and callable(cls_method) else None

pshirali commented 4 years ago

@ksindi fyi: I'll be opening issues to tag relevant commits with respective issue numbers. I'm assigning the issues to myself.

ksindi commented 4 years ago

Thanks @pshirali!