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

refactor: mypy disallow_any_generics #2694

Open
peterschutt opened this issue Nov 17, 2023 · 0 comments · May be fixed by #2769
Open

refactor: mypy disallow_any_generics #2694

peterschutt opened this issue Nov 17, 2023 · 0 comments · May be fixed by #2769
Labels
Refactor This is an improvement to existing code or configuration Typing This relates to typing

Comments

@peterschutt
Copy link
Contributor

peterschutt commented Nov 17, 2023

This issue was identified in #2689 when we realized that mypy is inferring Litestar.template_engine as Any due to AppConfig.template_config being annotated as TemplateConfig (without generic arg) instead of TemplateConfig[TemplateEngineProtocol].

AppConfig.template_config is annotated here:

template_config: TemplateConfig | None = field(default=None)

And assigned to the app instance here:

self.template_engine = config.template_config.engine_instance if config.template_config else None

I really think we should work toward changing

disallow_any_generics = false
to true so these types of errors cannot occur.

Originally posted by @peterschutt in #2689 (comment)


Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh Litestar dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@peterschutt peterschutt added Refactor This is an improvement to existing code or configuration Typing This relates to typing labels Nov 17, 2023
@peterschutt peterschutt changed the title enhancement: mypy disallow_any_generics refactor: mypy disallow_any_generics Nov 17, 2023
@marcuslimdw marcuslimdw linked a pull request Nov 26, 2023 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor This is an improvement to existing code or configuration Typing This relates to typing
Projects
Status: Triage
Development

Successfully merging a pull request may close this issue.

1 participant