
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
setconfig
Advanced tools
[!TIP] Don't forget to star this repo if you like it! ⭐
Some developers prefer to use @dataclass while others prefer BaseModel.
This holy war is not going to end soon.
So now they can use the same loader and config file in different parts/microservices of one project.
Currently supported:
@dataclassBaseModelSimpleNamespace (dotted dict)Features:
pip install setconfig
from dataclasses import dataclass
from setconfig import load_config
@dataclass
class Node:
host: str
port: int
@dataclass
class Config:
nodes: list[Node]
config = load_config('config.yaml', into=Config)
print(config)
# >>> Config(nodes=[Node(host='1.1.1.1', port=1000)])
print(config.nodes[0].host)
# >>> '1.1.1.1'
from pydantic import BaseModel
from setconfig import load_config
class Node(BaseModel):
host: str
port: int
class Config(BaseModel):
nodes: list[Node]
config = load_config('config.yaml', into=Config)
print(config)
# >>> Config(nodes=[Node(host='1.1.1.1', port=1000)])
print(config.nodes[0].host)
# >>> '1.1.1.1'
from setconfig import load_config
config = load_config('config.yaml')
print(config)
# >>> Config(nodes=[Node(host='1.1.1.1', port=1000)])
print(config.nodes[0].host)
# >>> '1.1.1.1'
from setconfig import load_config_stream
config = load_config_stream('done: true')
config = load_config('config.base.yaml', 'config.dev.yaml', 'config.feature-x.yaml', into=Config)
Configs are processed in the order they are passed to load_config (from left to right), where
last overrides the previous ones
config = load_config('config.yaml', into=Config, override={'timeout': 10})
config = load_config('config.yaml', into=Config, check_types=False)
Where check_types is a dacite flag, see https://github.com/konradhalas/dacite#type-checking
There is known issue in dacite that raises type error
when loading list into tuple. Pull request with fix is ready
since May 2023, but not merged yet... That's why setconfig has its own fix
There should be one-- and preferably only one --obvious way to do it
X packageCreate an issue or PR :)
PyPI: https://pypi.org/project/setconfig
Repository: https://github.com/abionics/setconfig
Developer: Alex Ermolaev (Abionics)
Email: abionics.dev@gmail.com
License: MIT (see LICENSE.txt)
FAQs
Multi-structure YAML config loader 🐍🔌
We found that setconfig demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.