Closed roger-collins-self closed 1 month ago
@roger-collins-self Hi, you can change as following
from that_depends import BaseContainer, providers
class DIContainer(BaseContainer):
settings = providers.Singleton(Settings)
settings_casted: Settings = settings.cast
some_factory = providers.Factory(SomeFactory, service_name=settings_casted.service_name)
And than this will work without mypy error:
@inject
def get_value(settings: Settings = Provide[Container.settings]) -> str:
return settings.my_value
I will update this in docs as well
Given the example in the docs:
and injecting the settings elsewhere:
Results in a mypy error:
The code executes correctly, but just doesn't pass type checking.
Is there a right way to do this?