roo-oliv/injectable

Optional injection doesn't work when there are the namespce is empty

Closed this issue · 0 comments

Injectable 3.4.1 raises a KeyError for the namespace specified by an optional injection if there are no injectables registered in it. The expected behavior would be for it to inject None instead of raising an error. The following piece of code reproduces the issue:

@autowired
def a(x: Autowired(Optional["anything"])):
    ...

Running it with injectable 3.4.1 and Python 3.6.8 will raise KeyError: 'DEFAULT_NAMESPACE'.