pydantic-conf
is a Python library for managing application configuration using Pydantic. It supports
loading configuration from environment variables and allows for custom startup actions.
To install the package, use:
pip install pydantic-conf
Create a configuration class by inheriting from EnvAppConfig
:
from pydantic_conf.config import EnvAppConfig
class MyConfig(EnvAppConfig):
app_name: str
debug: bool = False
Load the configuration using the load
method:
config = MyConfig.load()
print(config.app_name)
print(config.debug)
Add startup actions by appending to the STARTUP
list:
def startup_action(config):
print(f"Starting up with {config.app_name}")
MyConfig.STARTUP.append(startup_action)
config = MyConfig.load()
This project is licensed under the MIT License.