Closed sotte closed 4 months ago
Thanks @sotte for this issue. It is not possible to list env var names right now. I think it would be a good addition and will help a lot. I think it can be a duplicate of https://github.com/pydantic/pydantic-settings/issues/287. I mean we can have a method on each sources and the method will generate required data structure for the source.
So, we can close this one as a duplicate.
What do you think @sotte ?
Thanks @hramezani. #287 is indeed very similar (though I would not have guessed that from just the headline). I'm closing this as duplicate.
Is there an easy way to get/print the name of the env var that is used to set the value of a field?
Problem: You have a bunch of configs (potentially nested) and you quickly want to know what the name of the env var for a given field is.
Current workaround: Right now, I read the code, the nesting of the models, and the
SettingsConfigDict
to infer the name of the field. Then I try names until I find the correct one.Potential solution: Add a new function like
print_env_var_names()
that works something like this: