-
Notifications
You must be signed in to change notification settings - Fork 6
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
Generate config with subclasses #32
Comments
In function generate_toml recursively traverse the various input fields, generating TOML list and tables to contain nested classes and list of other elements, until a base type is found. lincolnloop#32
The lack of complex types is somewhat intentional to keep the library simple and support importing anything as an environment variable. Is the goal just to convert yaml from toml? If so, I'd recommend a purpose built tool such as yj. If you also want to model these in the config, instead of using complex types, I would consider functionality that let you read a config from a specific key prefix in the file. This could work similar to the That would support your use case by allowing you to define multiple |
Sorry my bad, I made a typo. I meant I was trying to use both class AppConfig(GoodConf):
class InnerConfig(BaseModel):
value: str
inner: InnerConfig
class Config:
default_files = ["myproject.yaml", "myproject.toml"]
config = AppConfig()
config.load()
print(config.inner.value) inner:
value: "test"
I also know that for the env variables the only supported format is a (quite ugly) JSON string, as the documentation of pydantic demonstrates. Thanks anyway for you comment. Do you suggest to hook into the |
Hi and thanks for this project! I am slowly migrating my configuration management to this wonderful library.
I would like to generate a
yaml
ortoml
configuration file, but I am having trouble on how to do it using theinitial
callable function on a nested class.Here is a minimal example:
I am trying to obtain an output similar to the following:
However I obtain the following error:
It seems to me that the toml serialization can only handle basic Python types?
The text was updated successfully, but these errors were encountered: