Skip to content

interface.implements decorator #20

Open
@nicoddemus

Description

@nicoddemus

Hi @ssanderson, congratulations on the package!

We have an in-house of implementation of interfaces which is very similar to yours in philosophy and usage.

One key difference in our implementation is that we use a decorator to signal implementation instead of subclassing. For example:

class MyClass(implements(MyInterface)):

    def method1(self, x):
        return x * 2

    def method2(self, x, y):
        return x + y

In our framework is written as:

@implements(MyInterface)
class MyClass:

    def method1(self, x):
        return x * 2

    def method2(self, x, y):
        return x + y

On advantage is that we don't need to insert any classes in the user's hierarchy, similar to how attr.s works, which is less intrusive.

This is not really an issue but more of a question on what you think about the approach of using a decorator?

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