python-dependency-injector
python-dependency-injector copied to clipboard
type safety for provided?
trafficstars
When referencing a singleton via foo.provided.bar, we lose type safety because provided always resolves to the ProvidedInstance rather than the specific type of the dependency.
settings = providers.Singleton(Settings)
identity_container = providers.Container(
IdentityContainer,
base_url=settings.provided.IDENTITY_SERVICE_BASE_URL,
)
Expected
settings.provided resolves to Settings
Actual
settings.provided resolves to ProvidedInstance
This seems like an easy change to make -- Is there any reason this wouldn't work if I opened a PR?
@philipbjorge - installed your fix from git, works like magic! @rmk135 is there any chance we could get it merge?
@toinbis -- Another type update :) https://github.com/ets-labs/python-dependency-injector/pull/744