meadsteve / lagom

📦 Autowiring dependency injection container for python 3
https://lagom-di.readthedocs.io/en/latest/
MIT License
294 stars 16 forks source link

Lagom doesn't seemt to recognize default values during injection #257

Open ShravanSunder opened 4 months ago

ShravanSunder commented 4 months ago
class PromptTemplateRepo(BaseRepo):
  def __init__(self, *, sa_service: SaService | None = None, should_auto_commit: bool = False):
    super().__init__(sa_service=sa_service, should_auto_commit=should_auto_commit)
repo = agent_store_container()[PromptTemplateRepo]

UnresolvableType: Unable to construct dependency of type PromptTemplateRepo The constructor probably has some unresolvable dependencies: PromptTemplateRepo => bool => bool

I would have expected it to take into account default values during injection. @meadsteve any thoughts on if i should restructure my class or is this a bug with lagom?

Enforcer commented 2 weeks ago

I think it's an example of undefined behaviour.

Handing defaults might be a nice add-on.