Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type safety for provided? #731

Closed
philipbjorge opened this issue Aug 3, 2023 · 3 comments
Closed

type safety for provided? #731

philipbjorge opened this issue Aug 3, 2023 · 3 comments

Comments

@philipbjorge
Copy link

philipbjorge commented Aug 3, 2023

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?

@toinbis
Copy link

toinbis commented Aug 31, 2023

@philipbjorge - installed your fix from git, works like magic! @rmk135 is there any chance we could get it merge?

@philipbjorge
Copy link
Author

@toinbis -- Another type update :)
#744

@ZipFile
Copy link
Contributor

ZipFile commented Jan 12, 2025

Done in #733 and #744.

@ZipFile ZipFile closed this as completed Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants