Skip to content

One-liner Python pyproject config loader. Lightweight, simple, and VCS-aware with root auto-discovery.

License

open-nudge/loadfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

loadfig

One-liner Python pyproject config loader. Lightweight, simple, and VCS-aware with root auto-discovery.

Features 🚀 Quick start 📚 Documentation 🤝 Contribute 👍 Adopters 📜 Legal


Features

loadfig is a Python package designed to load TOML configuration files adhering to modern standards:

  • Unified: Load your configuration either from .mytool.toml or pyproject.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 root using git (or other VCS), no need to specify the path to your configuration file.

Quick start

Installation

> pip install loadfig

Usage

Assume 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.

Contribute

We welcome your contributions! Start here:

Legal

  • 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.

About

One-liner Python pyproject config loader. Lightweight, simple, and VCS-aware with root auto-discovery.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages