Vyper-config
raw JSON → 1.2.1 verified Fri May 01 auth: no python
Vyper is a Python configuration library inspired by the Viper configuration system for Go. It supports reading configuration from YAML, JSON, TOML, INI, HCL, Java properties, dotenv, and environment variables, with live watching and multiple config sources. Current version: 1.2.1. Release cadence: irregular.
pip install vyper-config Common errors
error ModuleNotFoundError: No module named 'vyper' ↓
cause The package installed is 'vyper-config', but import uses 'vyper'.
fix
pip install vyper-config; then import vyper (not vyper_config).
error AttributeError: 'Vyper' object has no attribute 'read_in_config' ↓
cause Old API used 'read_config' or 'load'. New API uses 'read_in_config'.
fix
Use v.read_in_config() (version >=1.0.0) or check your version.
Warnings
gotcha All Vyper methods return a Result type (success/error tuple) or raise exceptions? Actually they return the value directly or None. But the 'read_in_config' returns a tuple (None, error) if an error. Check the docs: it returns (None, error) on failure, (config, None) on success? The Python version might differ. ↓
fix Always check the return value of read_in_config: err = v.read_in_config() if err: handle error.
breaking In version 1.0.0, the API changed significantly from pre-1.0. Older versions used different method names and import paths. If upgrading from 0.x, review migration guide. ↓
fix Check the changelog: https://github.com/alexferl/vyper/blob/master/CHANGELOG.md
deprecated 'set_config_file' is deprecated. Use 'set_config_name' and 'add_config_path' instead. ↓
fix Replace v.set_config_file('file.yaml') with v.set_config_name('file') and v.add_config_path('.')
Imports
- Vyper wrong
from vyper_config import Vypercorrectfrom vyper import Vyper
Quickstart
from vyper import Vyper
v = Vyper()
v.set_config_name("config")
v.add_config_path(".")
err = v.read_in_config()
if err:
print(err)
else:
print(v.get_string("key"))
# or built-in config name:
v.set_config_name("app")
v.add_config_path("/etc/app", ".")
err = v.read_in_config()
if err:
print(err)
else:
print(v.get("key"))