基于 Pydantic 的结构化配置管理工具,支持配置的持久化与自动保存,适用于需要高可靠性和易用性的 Python 应用配置场景。
Project description
baihe-config
基于 Pydantic 的结构化配置管理工具,支持配置的持久化与自动保存,适用于需要高可靠性和易用性的 Python 应用配置场景。
特性
- 基于 Pydantic,类型安全、易于扩展
- 支持配置自动持久化到本地 JSON 文件
- 支持自动加载和保存配置变更
- 适用于需要高可靠性和易用性的 Python 应用
安装
# 使用pip
pip install baihe-config
# 使用uv
uv add baihe-config
# 或
uv pip install baihe-config
快速开始
from baihe_config import BaseConfig
class AppConfig(BaseConfig):
username: str = "admin"
password: str = "123456"
# 创建配置对象,启用持久化
config = AppConfig(persistent=True, filepath="app_config.json")
# 修改配置会自动保存到文件
config.username = "new_user"
# 重新加载配置
config.load()
参数说明
persistent:是否启用持久化(bool,默认 False)filepath:持久化文件路径(str or Path,可选,默认以类名生成到当前工作目录)
依赖
- Python >= 3.11
- pydantic >= 2.11.7
作者
- jiangbaihe baiheqiuhan@qq.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
baihe_config-0.1.1.tar.gz
(11.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file baihe_config-0.1.1.tar.gz.
File metadata
- Download URL: baihe_config-0.1.1.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3c8a12b91f9abdc723679707925f35e5c9c5ce52125a5d6d3d782f96b94cb1e
|
|
| MD5 |
edacd4ee301db6dc49fb63d71eb5dcee
|
|
| BLAKE2b-256 |
50d0ce63d762bf435dff362b7176a62392046dbaaa080aab5ef64c0cda7de9d7
|
File details
Details for the file baihe_config-0.1.1-py3-none-any.whl.
File metadata
- Download URL: baihe_config-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac3f302ebc2178c235cdf632f52dc58c82e448de6e69800ba5081a045139c351
|
|
| MD5 |
48712f3ce746c3f038f39394f49f2e3a
|
|
| BLAKE2b-256 |
3d1c46682fc8392031e87a17dc36b686c8471fa09821745964c369a6fc7ce896
|