Skip to content

jochemloedeman/env-example

Repository files navigation

env-example

Package version Package version

Creates an .env.example file for your Python monorepo, based on all Pydantic settings classes found in your project. Env-example uses the abstract syntax tree of your project to discover settings instead of runtime introspection, to avoid side effects and having to deal with external project dependencies.

Usage

I recommend to use uvx to run env-example:

# Basic usage
uvx env-example

# Exclude specific directories from the search. Relative to the project root
uvx env-example --exclude-dir other/scripts

# Ignore optional settings fields
uvx env-example --ignore-optionals

Example

from pydantic_settings import BaseSettings


class AppSettings(BaseSettings):
    model_config = {
        "env_prefix": "APP__"
    }
    debug: bool
    log_level: str

class DatabaseSettings(BaseSettings):
    model_config = {
        "env_prefix": "DB__"
    }
    host: str
    port: int
    username: str
    password: str

env-example will generate the following .env.example file:

# AppSettings
APP__DEBUG=
APP__LOG_LEVEL=

# DatabaseSettings
DB__HOST=
DB__PORT=
DB__USERNAME=
DB__PASSWORD=

About

Generate an .env.example file for your Python monorepo.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages