Closed ewilazarus closed 1 month ago
Duplicates https://github.com/maldoinc/wireup/issues/3
Thanks for the interest in this. Registering a protocol with @abstract
should already work but when registering a service, the code needs to associate the thing being registered with the given protocol.
The main thing to do here would be to update the registry register_{service,factory} methods and to update registration decorators with any new arguments.
A reason why I haven't prioritized this is also that I cannot quite get the typing to work as I want: When decorating a class or factory with @container.register(supports=SupportsFoo)
ideally the type checker should flag if the thing being created does not actually adhere to the protocol.
Currently it seems like only
abc.ABC
classes can be used as interfaces.It would be great to add support for
typing.Protocol
s as well!Happy to try to put a PR together, but might need some guidance.