pydantic-argparse
pydantic-argparse copied to clipboard
Enhancement: Investigate `.env` file support
Summary
- As raised by @ericchansen in #34,
pydantic-argparse
should be able to piggy-back offpydantic
and support loading environment variables from.env
files. - This can probably be accomplished by defining arguments as shown below:
class Args(pydantic.BaseSettings): my_arg: int = pydantic.Field(description="this is an int") class Config: env_file = ".env" env_file_encoding = "utf-8"
- See: https://docs.pydantic.dev/latest/usage/settings/#dotenv-env-support
- If this does work, it might be nice to provide a
dotenv
extra forpydantic-argparse
(similar topydantic
) so people can install it with:$ pip install pydantic-argparse[dotenv]