-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Create default templates (feature request) #287
Comments
Thanks @A-Telfer for this feature request. Agree, this would be a great addition. I am thinking about implementing a method on each sources like |
I just closed #292 as duplicate of this ticket. Knowing the name of a field (in #292 I was mostly interested in the representation as env var, but the same holds for any other representation) is quite useful. No more reading all the models and options to mentally compile / reconstruct the name of the field I'm interested in. (I personal don't think of this feature as "templates", but naming is hard 🤷 ) Thinking out loud: |
Just curious any updates on this @hramezani ? I might take a crack at the |
@A-Telfer it would be great! |
For from pydantic import Field, SecretStr, BaseModel
from pydantic_settings import BaseSettings, SettingsConfigDict
from typing import List
class NestedSetting(BaseSettings):
model_config = SettingsConfigDict(env_prefix="foo_")
url: str
"""the nested setting URL."""
password: SecretStr
# I think a class method would make more sense
template = NestedSetting.template(format="env")
print(template) # FOO_URL: str
# the nested setting URL.
FOO_URL=
# FOO_PASSWORD: secret str
FOO_PASSWORD= |
Since a big part of pydantic-settings is accepting options from different sources (secrets, env, dotenv, json, yaml...) it would be nice if there were a way to also generate template files for them
Use example
There should be a way to separate Secret, SecretStr, and SecretBytes
then
For secrets
The text was updated successfully, but these errors were encountered: