基于 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.2.tar.gz
(11.7 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.2.tar.gz.
File metadata
- Download URL: baihe_config-0.1.2.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37d6d8e42f93b43e58cd915c949c15dd79e89f7bdd907c8faae577332f883a9b
|
|
| MD5 |
6a4ec2697282d5cd83d5d5cfb28cda91
|
|
| BLAKE2b-256 |
1d0080417e3d91eedc02093b1a42441d3b6d4f634489b23d9c38e6a4407a11bb
|
File details
Details for the file baihe_config-0.1.2-py3-none-any.whl.
File metadata
- Download URL: baihe_config-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af2bcff3a73d8842cb57afdc1827256bde07b57a00345de819c610d92b0e409f
|
|
| MD5 |
6f8e948caf290735cd7bb02492d0b3c8
|
|
| BLAKE2b-256 |
d255cccb1a80ad157483f670f3e7848129ff1db20bbebb1f9c224f714bd0124d
|