One-liner Python pyproject config loader. Lightweight, simple, and VCS-aware with root auto-discovery.
✨ Features 🚀 Quick start 📚 Documentation 🤝 Contribute 👍 Adopters 📜 Legal
loadfig is a Python package designed to load
TOML configuration files adhering to modern standards:
- Unified: Load your configuration either from
.mytool.tomlorpyproject.toml(section[tool.mytool]). - One-liner:
loadfig.config(name="mytool")returns a basic Python dictionary and that is all you need. - No dependencies: Python-only, no third-party dependencies.
- Do one thing well: Only load the configuration,
use other libraries like
python-dotenvfor bells and whistles. - Git-aware: Automatically detects project's
rootusing git (or other VCS), no need to specify the path to your configuration file.
> pip install loadfigAssume you have the following section in your pyproject.toml
file at the root of your project:
[tool.mytool]
name = "My Tool"
version = "1.0.0"You can load the configuration for mytool using:
import loadfig
config = loadfig.config("mytool")
config["name"] # "My Tool"
config["version"] # "1.0.0"That is all you will likely need to do to load your configuration for your Python project (in a modern, unified way).
Important
pyproject.toml can be located at the root of your project,
while the loading file can be in a subfolder (e.g. src/mytool/loader.py).
See documentation for more details about the arguments and options available.
We welcome your contributions! Start here:
- This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
- This project is copyrighted by open-nudge - the appropriate copyright notice is included in each file.