ssanderson / python-interface

Minimal Pythonic Interface Definitions
https://interface.readthedocs.io/en/latest/
Apache License 2.0
111 stars 16 forks source link

ENH: Add property as a supported type. #3

Closed ehebert closed 7 years ago

ehebert commented 7 years ago

Enables definitions such as:

class FooInterface(Interface):

    @property
    def bar(self):
        pass

class Foo(implements(FooInterface)):

    @property
    def bar(self):
        return 'baz'

If the implementation is missing the property decorator, such as:

class FooInterface(Interface):

    @property
    def bar(self):
        pass

class Foo(implements(FooInterface)):

    def bar(self):
        return 'baz'

Then an error is raised showing that the method has the wrong type:

The following methods of FooInterface were implemented with incorrect types:
  - bar: 'function' is not a subtype of expected type 'property'