loadfig¶
Features¶
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-dotenv⧉ for bells and whistles. - Git-aware: Automatically detects project's
rootusing git (or other VCS), no need to specify the path to your configuration file.
Quick start¶
Installation¶
Usage¶
Assume you have the following section in your pyproject.toml file at the root of your project:
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.