wireup icon indicating copy to clipboard operation
wireup copied to clipboard

Add support for protocols

Open maldoinc opened this issue 2 years ago • 0 comments

Allow injection of types based on protocols. Services can declare themselves what protocol they support and the container can then perform autowiring based on that.

class SupportsFoo(Protocol):
    def foo(self) -> str:
        pass


@service(supports=SupportsFoo)
class FooBar:
    def foo(self):
        return "bar"

Requesting SupportsFoo will have FooBar injected.

maldoinc avatar Nov 19 '23 16:11 maldoinc