You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered: