draccus
A slightly opinionated framework for simple dataclass-based configurations based on Pyrallis.
What it is and what it does
Draccus is a configuration framework that binds command-line arguments and YAML/TOML/JSON config files directly to Python dataclasses. It extends Pyrallis with support for config file inclusion (allowing you to split configs across files), choice registries (runtime selection between different config subtypes), and better handling of nested config containers. Your dataclass fields become both type-checked configuration parameters and IDE-autocompleted attributes; the framework parses arguments from the command line, a config file, or both, and initializes your dataclass with the result.
The library depends on pyyaml, toml, mergedeep, and typing-inspect to handle parsing, merging, and type resolution. It's designed for projects that need structured, nested configurations—particularly machine learning workflows where you might choose between different model architectures or optimizer types at runtime. The decorator-based API (@draccus.wrap) keeps the boilerplate minimal.
Use it for:
- Machine learning experiment configs: define model, optimizer, and training parameters as nested dataclasses and switch between them via config files.
- Multi-environment deployment: split base config, environment-specific overrides, and secrets into separate files and include them in a main config.
- CLI tools with complex options: replace argparse boilerplate with a clean dataclass definition and automatic --help generation.
- Configuration inheritance: use choice registries to let users select between different implementations (e.g., database backends) at startup.
- Config validation and IDE support: leverage dataclass type hints for autocomplete and static type checking of your configuration structure.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Draccus parses command-line arguments and configuration files into Python dataclasses, with support for nested configs, config file inclusion, and runtime type selection via choice registries.
Yes. Draccus is actively maintained, has no known vulnerabilities, and solves a real problem—structured config management with IDE support—more cleanly than raw argparse or manual YAML loading. The low install friction and permissive license make it a low-risk addition. The Alpha status reflects its origin as a fork, not instability; it's already in production use. Install it if you need nested configs, config file inclusion, or runtime type selection; skip it if your config needs are simple enough for a basic argparse setup.
Install
draccus on PyPI
pip
pip install draccusuv
uv add draccuspoetry
poetry add draccusInstalling draccus
Before you install
Low install friction with a pure-Python wheel and four lightweight runtime dependencies. Actively maintained with a recent release; marked as Alpha but in use with steady download volume.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects.
Quickstart
from dataclasses import dataclass
import draccus
@dataclass
class TrainConfig:
workers: int = 8
exp_name: str = 'default_exp'
@draccus.wrap()
def main(cfg: TrainConfig):
print(f"Training {cfg.exp_name} with {cfg.workers} workers...")
if __name__ == "__main__":
main()
Verify before relying
- Whether config file inclusion via !include tag works with all YAML edge cases or only standard structures
- Performance characteristics when handling deeply nested configs or large config files
- Compatibility with Python 3.11+ beyond the stated 3.9 and 3.10 support
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — mergedeep, pyyaml, toml, typing-inspect |
| Maintenance | actively maintained — 63 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 838,513/month — #4,928 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: draccus-0.11.6-py3-none-any.whl
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
simple-parsingTransforms argparse scripts into structured,…
permissive · top 5,000 on PyPI
argparse-dataclassBuilds command-line interfaces declaratively by…
permissive · top 5,000 on PyPI
config-parserMerges configuration from YAML/JSON files,…
agpl · top 5,000 on PyPI
sconfsconf is a YAML-based configuration library…
permissive · top 15,000 on PyPI
PyStaticConfigurationLoads, validates, and reads configuration from…
permissive · top 15,000 on PyPI
dataclass-wizardDataclass Wizard converts Python dataclasses to…
permissive · top 5,000 on PyPI
datafilesDatafiles is a file-based ORM that…
permissive · top 15,000 on PyPI
jax-dataclassesProvides a JAX-compatible wrapper around Python…
permissive · top 15,000 on PyPI
yacsYACS is a lightweight configuration management…
permissive · top 5,000 on PyPI
daciteConverts dictionaries into dataclass instances…
permissive · top 1,000 on PyPI