Skip to content

Yurzs/pydantic-conf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pydantic-conf

Overview

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.

Installation

To install the package, use:

pip install pydantic-conf

Usage

Defining Configuration

Create a configuration class by inheriting from EnvAppConfig:

from pydantic_conf.config import EnvAppConfig


class MyConfig(EnvAppConfig):
    app_name: str
    debug: bool = False

Loading Configuration

Load the configuration using the load method:

config = MyConfig.load()
print(config.app_name)
print(config.debug)

Adding Startup Actions

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()

License

This project is licensed under the MIT License.

About

Pydantic based application configuration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages