ApPySetty ⚙️
A simple, type-safe Python library for managing application configuration from environment variables and YAML.
ApPySetty uses Python dataclasses as the single definition of your application configuration. It can load values from configuration files and environment variables and generate documentation from the same definition.
Quick Start
Install:
uv add appysetty
Define your configuration:
from dataclasses import dataclass
from appysetty import AppConfigSource, read_configuration
@dataclass
class Config:
host: str = "localhost"
port: int = 8080
debug: bool = False
config = read_configuration(
Config,
AppConfigSource.ENV,
)
Override values with environment variables:
export HOST="0.0.0.0"
export PORT="9000"
export DEBUG="true"
Or load them from YAML:
host: localhost
port: 8080
debug: false
config = read_configuration(
Config,
AppConfigSource.YAML,
)
And also document your configuration with an example yaml and a markdown document:
write_configuration_documentation(Config, output_dir=Path("./docs"))
Configuration Sources
ApPySetty currently supports:
ENV: environment variables using UPPER_SNAKE_CASE onlyYAML: YAML configuration files
Multiple sources can be combined. Later sources overwrite values from earlier sources:
config = read_configuration(
Config,
[
AppConfigSource.YAML,
AppConfigSource.ENV,
],
)
By default, YAML files are searched for in:
config.yaml
config.yml
config/config.yaml
config/config.yml
An explicit YAML path can also be provided.
Usage Details
Define Config
First you need to define a dataclass which contains all the configuration options you want to support.
@dataclass
class Config:
host: str = "localhost"
port: int = 8080
debug: bool = False
timeout: float = 5.0
You can also extend your dataclass with additional information for better documentation and for masking secrets:
@dataclass
class ConfigWithMetadata:
host: Annotated[
str,
AppConfigEntry(description="The application host"),
] = "localhost"
password: Annotated[
str,
AppConfigEntry(description="The database password", is_secret=True),
] = "secret"
Both variants can be mixed. If no description is provided, the name of the field will be the description.
Read Config
To read the config, use:
cfg = read_configuration(ConfigWithMetadata, AppConfigSource.ENV)
After that cfg should have all configurations with auto-complete ready for you.
You can also pass an instance and use multiple sources, where each source will overwrite the previous one:
cfg = read_configuration(
ConfigWithMetadata(), [AppConfigSource.ENV, AppConfigSource.YAML]
)
The available sources are:
| Key | Source | Description |
|---|---|---|
AppConfigSource.ENV |
Environment | This will read config from environment, using UPPER_SNAKE_CASE variant of the field name |
AppConfigSource.YAML |
YAML file | This will read the config from a yaml file, only matching field name exactly |
Options
Options can be used to customize the config:
cfg = read_configuration(
ConfigWithMetadata,
[AppConfigSource.ENV, AppConfigSource.YAML],
AppConfigOptions(
env_prefix="MY_APP_PREFIX",
yaml_path="config.dev.yaml",
overwrite={"port": "8000"},
),
)
| Option | Description |
|---|---|
env_prefix |
A Prefix that will be prepended to all field names using UPPER_SNAKE_CASE to read environment . |
yaml_path |
Setting a specific yaml file to use. It unset, the tool will look for (config)/config.y(a)ml. |
overwrite |
This accepts a mapping. values set with overwrite will always overwrite anything else |
Write Documentation
The second feature of this tool is automated creation of a few documentation items for configuration options:
config.example.yamlcontaining an example yaml file with default values and descriptive comments (if descriptions were defined)DefaultConfiguration.mdcontaining a table of all options with ENV variant, a docker environment block for docker compose and a docker run example command with all -e set.
To create the documentation, use:
# Create both documents
write_configuration_documentation(
ConfigWithMetadata, env_prefix="MY_APP_PREFIX", output_dir=Path()
)
# Only create yaml example
write_config_yaml_example(ConfigWithMetadata, output_dir=Path())
# Only create markdown document
write_config_markdown(ConfigWithMetadata, env_prefix="MY_APP_PREFIX", output_dir=Path())
Development
Clone the repository and install the development dependencies:
git clone https://github.com/SmartFactory-KL/appysetty.git
cd appysetty
uv sync
Run the tests:
uv run pytest
Run tests with coverage:
uv run pytest --cov=appysetty --cov-report=term-missing
Run the examples:
uv run python -m examples.write_documentation
uv run python -m examples.read_documentation
Ruffing:
uv run ruff check
uv run ruff format .
License
ApPySetty is licensed under the MIT License.
Release files for appysetty 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| appysetty-0.2.0.tar.gz | 7.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| appysetty-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.3 kB
Release files / appysetty-0.2.0.tar.gz
| Download URL | appysetty-0.2.0.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f3fea6238d289c23f0ea231acaa3c7a0e6fed9ec2fa10c1afa120a5e34dcdc3a
|
|
BLAKE2b-256 checksum How to use checksums |
84452d20c74fc4b908c47f5cd5410cbf692d68d48ba1161a3688bddaf52f3b5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / appysetty-0.2.0-py3-none-any.whl
| Download URL | appysetty-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f1c3fe2e8299debc2df8da5da60bd10f8b499e00f8163f53bc07155412afa4cf
|
|
BLAKE2b-256 checksum How to use checksums |
b5c95de44a4f468188fa7b4cc6937693a3de9a2cb72d11cfb953bf99f81a6a09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency log