Skip to content
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

Add env_prefix to BaseSettings args #74

Closed
Viicos opened this issue Jun 12, 2023 · 2 comments · Fixed by #76
Closed

Add env_prefix to BaseSettings args #74

Viicos opened this issue Jun 12, 2023 · 2 comments · Fixed by #76

Comments

@Viicos
Copy link
Contributor

Viicos commented Jun 12, 2023

Currently BaseSettings can take the following config values from its __init__ method:

def __init__(
__pydantic_self__,
_env_file: DotenvType | None = env_file_sentinel,
_env_file_encoding: str | None = None,
_env_nested_delimiter: str | None = None,
_secrets_dir: str | Path | None = None,
**values: Any,
) -> None:

Then these values are used if provided, else the ones from the SettingsConfigDict, e.g.:

dotenv_settings = DotEnvSettingsSource(
self.__class__,
env_file=(_env_file if _env_file != env_file_sentinel else self.model_config.get('env_file')),
env_file_encoding=(
_env_file_encoding if _env_file_encoding is not None else self.model_config.get('env_file_encoding')
),

Is there a reason why env_prefix isn't part of this scheme? If this is possible, I can make a PR implementing this.

@hramezani
Copy link
Member

hramezani commented Jun 13, 2023

It's not only env_prefix. case_sensitive is not also included in __init__.

I think we can include both of them. PR welcome.

Please remember to update the docs and add proper tests

@Viicos
Copy link
Contributor Author

Viicos commented Jun 13, 2023

Nice, will do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants