Skip to main content

基于 Pydantic 的结构化配置管理工具,支持配置的持久化与自动保存,适用于需要高可靠性和易用性的 Python 应用配置场景。

Project description

baihe-config

基于 Pydantic 的结构化配置管理工具,支持配置的持久化与自动保存,适用于需要高可靠性和易用性的 Python 应用配置场景。

特性

  • 基于 Pydantic,类型安全、易于扩展
  • 支持配置自动持久化到本地 JSON 文件
  • 支持自动加载和保存配置变更
  • 适用于需要高可靠性和易用性的 Python 应用

安装

建议使用 uvpip 进行安装:

# 使用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

作者

Project details


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

baihe_config-0.1.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

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

Hashes for baihe_config-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f3c8a12b91f9abdc723679707925f35e5c9c5ce52125a5d6d3d782f96b94cb1e
MD5 edacd4ee301db6dc49fb63d71eb5dcee
BLAKE2b-256 50d0ce63d762bf435dff362b7176a62392046dbaaa080aab5ef64c0cda7de9d7

See more details on using hashes here.

File details

Details for the file baihe_config-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for baihe_config-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac3f302ebc2178c235cdf632f52dc58c82e448de6e69800ba5081a045139c351
MD5 48712f3ce746c3f038f39394f49f2e3a
BLAKE2b-256 3d1c46682fc8392031e87a17dc36b686c8471fa09821745964c369a6fc7ce896

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page