修复:升级 Pydantic v2 兼容性,修复插件加载错误
- 更新 danding_points 配置使用 pydantic_settings.BaseSettings 和 SettingsConfigDict - 更新 onmyoji_gacha 配置使用 pydantic_settings.BaseSettings - 修复 danding_qqpush 配置加载使用 model_validate 替代 parse_obj - 添加 group_horse_racing 插件的详细 README 文档 这些修复解决了 Pydantic v2 迁移中的导入错误和 API 变更问题。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,26 +1,31 @@
|
||||
from pydantic import BaseSettings, validator
|
||||
from pydantic import field_validator
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class Config(BaseSettings):
|
||||
"""Points system configuration."""
|
||||
|
||||
model_config = SettingsConfigDict(
|
||||
env_prefix="DANDING_",
|
||||
case_sensitive=True,
|
||||
extra="ignore",
|
||||
)
|
||||
|
||||
POINTS_DB_FILE: str = "data/danding_points/points.db"
|
||||
POINTS_MAX_BALANCE: int = 0 # 0 = unlimited
|
||||
POINTS_MAX_PER_OPERATION: int = 0 # 0 = unlimited
|
||||
POINTS_LOG_RETENTION_DAYS: int = 365
|
||||
|
||||
class Config:
|
||||
env_prefix = "DANDING_"
|
||||
case_sensitive = True
|
||||
|
||||
@validator("POINTS_MAX_BALANCE", "POINTS_MAX_PER_OPERATION", "POINTS_LOG_RETENTION_DAYS")
|
||||
@field_validator("POINTS_MAX_BALANCE", "POINTS_MAX_PER_OPERATION", "POINTS_LOG_RETENTION_DAYS")
|
||||
@classmethod
|
||||
def validate_non_negative(cls, v):
|
||||
if v < 0:
|
||||
raise ValueError("Value must be non-negative")
|
||||
return v
|
||||
|
||||
@validator("POINTS_DB_FILE")
|
||||
@field_validator("POINTS_DB_FILE")
|
||||
@classmethod
|
||||
def validate_db_path(cls, v):
|
||||
if not v:
|
||||
raise ValueError("Database file path cannot be empty")
|
||||
|
||||
Reference in New Issue
Block a user