Closed hynek closed 1 year ago
… just give .get
an @overload
? It's a little ugly type-wise, but you can easily make
db = svcs.get(Database)
# or
db, web_api = svcs.get(Database, WebAPI)
(I would not blame you for finding the single-element special-case kind of gross, but I think as a user this is what I'd want)
Hmmm, so there's been thought of allowing to pass arguments to factories, but we totally could just say kwargs
only and posargs are always the getter. 🤔
What do you mean by "ugly type-wise"? Will I have to send @tinche to the typing salt mines or is does it just look ugly?
As @glyph mentioned to me, having many services can get unnecessarily verbose and even slow.
We should consider:
It's still a for loop, but saves boilerplate and reduces business code from 3 lines to 1.
Better names appreciated.