| ▲ | Show HN: Pyconject – Ditch messy YAML loading in Python with config injection(github.com) | |
| 2 points by neolaw 2 days ago | 1 comments | ||
| ▲ | neolaw 2 days ago | parent [-] | |
Hi HN, I’ve always found Python’s standard configuration management patterns to be overly verbose. Loading nested YAML files and assigning values to variables just to pass them into standard functions creates a lot of noise. pyconject is a library I wrote to abstract all of that away using configuration injection. It works by mapping your directory and function structures directly to your YAML hierarchy. How it works: Instead of writing boilerplate to parse configs.yml, you just wrap your target and open a context: ``` from my_module import black_func from pyconject import pyconject # Explicitly wrap the function black_func = pyconject.wrap(black_func) # Inject parameters from configs.yml (and optional environment targets) with pyconject.cntx(target="stg"): black_func() ``` It handles hierarchical resolution (falling back from configs-stg.yml to configs.yml), supports custom file paths, and allows library developers to register default configurations that end-users can seamlessly override. You can check out the source code and usage examples here: https://github.com/neolaw84/pyconject Looking forward to your thoughts and critiques! | ||