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
[RFC] Provide workaround for auto-complete w/ Schema #1082
Comments
Recently, I've been working on adding type hints to a Flask config. I, independently, came up with essentially the same solution and would really like to see this functionality built into Dynaconf. For reference, I got around the need for from typing import cast
from dynaconf import Dynaconf
class MySchema(Dynaconf):
name: str
age: int
settings: MySchema = cast(MySchema, Dynaconf(...)) If the schema was passed to Dynaconf as in the example: |
That's nice, I didn't know about cast, thanks for sharing! |
Problem
I want to be able to use a schema object to provide type hints for my
settings
object:Proposal
Fake the type of the Dynaconf object by pretending it is a Schema object.
To provide both Schema attributes and Dynaconf's usual methods, we could provide a base Schema to be inherited, which will act as a stub, providing only docstrings and type hinting to Dynaconf object methods.
It could work along with this more recent Schema Validation proposal:
Alternatives
# type: ignore
, but I'm not sure what.Additional Context
I did some limited testing around that.
The text was updated successfully, but these errors were encountered: