feat: implement env_nested_delimiter support for nested configuration#49
Merged
Merged
Conversation
env_nested_delimiter was declared in SettingsConfigDict but never used. This implements the actual nested env var unfolding so that variables like DATABASE__HOST=localhost are resolved into nested struct fields. - Change env_nested_delimiter default from "__" to None (opt-in) - Add env_nested_max_depth config (0 = unlimited) - Add _resolve_field_type to convert BaseSettings types to struct equivalents (handles Union, Annotated, and generic types) - Add _collect_nested_env_values with delimiter-aware env scanning - Add 10 tests covering nesting, prefix, depth limit, dotenv, Optional
vilsonrodrigues
approved these changes
Mar 22, 2026
vilsonrodrigues
approved these changes
Mar 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
env_nested_delimiter was declared in SettingsConfigDict but never used. This implements the actual nested env var unfolding so that variables like DATABASE__HOST=localhost are resolved into nested struct fields.
Changes
Type of Change
Testing
uv run pytest -v)Documentation
Checklist
uv run ruff format)uv run ruff check)uv run pytest -v)Additional Notes