Coqpit is a lightweight configuration management library built around Python dataclasses. It simplifies defining, loading, and parsing configurations from various sources (JSON, YAML, CLI arguments) by leveraging dataclass features. Developed by Coqui-AI, it has a rapid release cycle with frequent minor updates.
pip install coqpitVerified import paths — ran on the pinned version, not inferred.
Define your configuration by inheriting from `Coqpit` and using Python dataclasses. Fields can have default values. For mutable defaults (lists, dicts), always use `field(default_factory=...)`. Instantiate the config directly or use `parse_args()` to integrate with `argparse`, or `load_json`/`load_yaml` for file-based configuration.
Change `my_list: list = []` to `my_list: list = field(default_factory=list)`.
Always pass a string representing the file path (e.g., `'config.json'`) instead of an open file handle (e.g., `open('config.json', 'r')`).Always provide explicit and correct type hints for all fields in your `Coqpit` subclass to ensure proper serialization and deserialization.
Be aware that `None` values in your config file might be replaced by dataclass defaults. For fields that must be explicitly present, consider setting `default_factory=lambda: ...` with a sentinel value and custom validation, or checking for `None` after loading if the default is not `None`.
Update your dataclass definition: `my_list_param: list[str] = field(default_factory=list)`.
Pass the file path as a string directly to `load_json()` or `save_json()`: `config.load_json('my_config.json')`.Ensure all parameters in your configuration sources are explicitly defined as fields in your `Coqpit` dataclass, or remove the undefined parameter from the source.
No dependency data recorded yet.