YouConfigMe
YouConfigMe helps you manage config in a pythonic way.
Core ideas
Explicit is better than implicit
There are several ways to define configuration variables, with different levels of explicitness. I prefer to go as close as possible to the Twelve Factor App guide since it's what most people expect anyways.
Defaults are reasonable
Sometimes you might need a variable to exist even if it hasn't been defined. So, you should be able to provide defaults.
Types are inherent to the variable
Most of the time, variables are defined as strings, on .ini files or as env vars. But what if your variable is an int? You should be able to get it as an int.
Sections are good
Config sections are a good thing: separate your config vars under reasonable namespaces.
Motivation
The main motivation for youconfigme to exist is that most simple config libraries do not take sections into account. And it bugs me greatly.
Install
Clone this repo, and install it.
pip install .
Or from PyPI.
pip install YouConfigMe
Development
Start by cloning the repo/forking it.
You should install YouConfigMe's dev packages to help.
pip install .[dev]
pip install .[test]
After that, install the pre-commit hooks:
pre-commit install
This will install several code formatting tools and set them up to run before commits. Also, it will run tests before pushing.
You might find nox quite useful to run tests and ensure linting is as expected.
Docs
The docs are updated on pushed tags using GitHub Actions.
Version bumping
This project uses bump to quickly bump versions.
By default running bump will bump the patch version. You can bump minor/major versions like so:
bump --minor
bump --major
Tests
The tests folder contains several tests that run using pytest that should give you an idea of how to use this.
Config discovery
The preferred order should be:
- Environment variables
- Config file
- Default value
Quickstart
Assume you have an .ini file at the root of your project that looks like this:
[a]
key1=1
key2=2
key7=7
[b]
key3=3
key4=4
You can use it like this:
from youconfigme import AutoConfig
import os
os.environ["A_KEY4"] = "key4value"
os.environ["A_KEY7"] = "key7value"
config = AutoConfig()
print(config.a.key1()) # returns '1'
print(config.a.key1(cast=int)) # returns 1
print(config.a.key2(default='default2val')) # returns '2'
print(config.a.key3()) # raises ConfigItemNotFound
print(config.a.key3(default='key3value')) # return 'key3value'
print(config.a.key4()) # returns 'key4value'
print(config.a.key7()) # returns 'key7value'
Since version 0.9.0, YCM supports toml files as well.
Metadata
Release files for youconfigme 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| youconfigme-2.0.0.tar.gz | 10.6 kB | Without provenance | Details for youconfigme-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| youconfigme-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for youconfigme-2.0.0-py3-none-any.whl |
Total release size: 20.7 kB
Release files / youconfigme-2.0.0.tar.gz
| Download URL | youconfigme-2.0.0.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
65b3e07723f9b80a0269fa5a28bdb530fe5f5d76548f57ae3b4fa82f0e7eabfc
|
|
BLAKE2b-256 checksum How to use checksums |
b7c4f74a8a0612085260f5bcb03ccdeee5ce536bf4abd2ef5556feb00249b3b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Release files / youconfigme-2.0.0-py3-none-any.whl
| Download URL | youconfigme-2.0.0-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2130b81c37c779ee291fdc11de9ecab065179192915474e1bd7de73666867c4
|
|
BLAKE2b-256 checksum How to use checksums |
2aa26dedb613f06192b3b3f19cbb2cf57204391d4bbc326f51d00dea16691d9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Security for youconfigme 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.