Priority Config
Universal configuration resolver with clean precedence hierarchy: direct → config → env → default
Installation
pip install priority-config
Quick Start
from priority_config import PriorityConfig
# Create config resolver
config = PriorityConfig(
config_dict={"port": 3000, "debug": True},
env_prefix="MYAPP_"
)
# Resolve with precedence
port = config.resolve("port", None, default=8000, type=int)
# Returns: 3000 (from config_dict)
debug = config.resolve("debug", False, default=True, type=bool)
# Returns: False (direct_value takes precedence)
# Environment variables (MYAPP_HOST) override config
host = config.resolve("host", default="localhost")
# Returns: value from MYAPP_HOST env var, or "localhost"
# See resolution log
config.print_resolutions()
# Configuration Resolution Log:
# --------------------------------------------------
# port = 3000 (config)
# debug = 0 (direct)
# host = localhost (default)
How It Works
The configuration resolution follows a clean precedence hierarchy:
graph TD
A[resolve] --> B{direct_val?}
B -->|Yes| C[Use direct_val]
B -->|No| D{Key in config_dict?}
D -->|Yes| E[Use config_dict value]
D -->|No| F{Environment variable exists?}
F -->|Yes| G[Use env var + type conversion]
F -->|No| H[Use default value]
C --> I[Apply masking if sensitive]
E --> I
G --> I
H --> I
I --> J[Log resolution source]
J --> K[Return final value]
style C fill:#e1f5fe
style E fill:#f3e5f5
style G fill:#e8f5e8
style H fill:#fff3e0
style I fill:#fce4ec
Precedence Order:
- Direct value - Passed directly to
resolve() - Config dictionary - From
config_dictparameter - Environment variable - With
env_prefix+ key - Default value - Fallback if nothing else found
Features
- Clean Precedence:
direct → config → env → default - Automatic Type Conversion:
str,int,float,bool,list - Sensitive Data Masking: Auto-detects and masks passwords, keys, tokens
- Resolution Logging: Track where each value came from
- Zero Dependencies: Pure Python, works with 3.8+
API Reference
PriorityConfig(config_dict=None, env_prefix="", auto_uppercase=True)
config_dict: Dictionary with configuration valuesenv_prefix: Prefix for environment variables (e.g., "MYAPP_")auto_uppercase: Whether to uppercase keys for env lookup
resolve(key, direct_val=None, default=None, type=str, mask=None)
key: Configuration key to resolvedirect_val: Direct value (highest precedence)default: Default value if not found elsewheretype: Type conversion (str,int,float,bool,list)mask: Override automatic masking of sensitive values
print_resolutions()
Print resolution log showing where each value came from.
clear_log()
Clear the resolution log.
License
MIT
Contact
Metadata
Release files for priority-config 0.1.1
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 |
|---|---|---|---|---|
| priority_config-0.1.1.tar.gz | 5.6 kB | Without provenance | Details for priority_config-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| priority_config-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for priority_config-0.1.1-py3-none-any.whl |
Total release size: 11.3 kB
Release files / priority_config-0.1.1.tar.gz
| Download URL | priority_config-0.1.1.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
57d5d4082661f90595fac589814c2d268776ad679c131e4ab21545112fb5bd02
|
|
BLAKE2b-256 checksum How to use checksums |
edd5d19e8fc4294139ea511cd321fb0be7e0715426e5182b35d18d81e25d9fae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.0rc1
|
Release files / priority_config-0.1.1-py3-none-any.whl
| Download URL | priority_config-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
394b5a7b26d28a0ee714ba25853888596c64cdb2d86bbb59b57d7905d433604c
|
|
BLAKE2b-256 checksum How to use checksums |
04d57665a61921aa14adbe67ea6dfe9ceaa178bde8381e9ae2cd3ed43c3648b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.0rc1
|
Security for priority-config 0.1.1
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.