-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
env source: superflous deep env conflicts with non-dict model #275
Labels
Comments
diefans
added a commit
to bettermarks/pydantic-settings
that referenced
this issue
Apr 23, 2024
If a model defines a leaf as e.g. a string and the user or system sets an environment var with an additional `env_nested_delimiter + suffix`, `explode_env_vars` was treating the string as a `dict` (trying to add an item to it). This fix checks if the target is indeed a `dict`. In that regard, the whole `explode_env_vars` seems a bit wasteful, in terms of possible throwing away already computed values, if a deeper environment variable is processed earlier (which is possible, since the iteration order of `os.environ` seems unpredictable). resolves pydantic#275
diefans
added a commit
to bettermarks/pydantic-settings
that referenced
this issue
Apr 23, 2024
If a model defines a leaf as e.g. a string and the user or system sets an environment var with an additional `env_nested_delimiter + suffix`, `explode_env_vars` was treating the string as a `dict` (trying to add an item to it). This fix checks if the target is indeed a `dict`. In that regard, the whole `explode_env_vars` seems a bit wasteful, in terms of possible throwing away already computed values, if a deeper environment variable is processed earlier (which is possible, since the iteration order of `os.environ` seems unpredictable). resolves pydantic#275
diefans
added a commit
to bettermarks/pydantic-settings
that referenced
this issue
Apr 23, 2024
If a model defines a leaf as e.g. a string and the user or system sets an environment var with an additional `env_nested_delimiter + suffix`, `explode_env_vars` was treating the string as a `dict` (trying to add an item to it). This fix checks if the target is indeed a `dict`. In that regard, the whole `explode_env_vars` seems a bit wasteful, in terms of possible throwing away already computed values, if a deeper environment variable is processed earlier (which is possible, since the iteration order of `os.environ` seems unpredictable). resolves pydantic#275
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you define a nested model with a leaf annotated as a string and have deeper nesting environment variables in place, an exception is raised:
Exception:
The text was updated successfully, but these errors were encountered: