From ce605a542197f786c807924609da29b8e29beb84 Mon Sep 17 00:00:00 2001 From: molanp <104612722+molanp@users.noreply.github.com> Date: Fri, 11 Jul 2025 21:27:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=81=E8=AE=B8=E6=B3=9B=E7=B1=BB=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zhenxun/configs/utils/models.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/zhenxun/configs/utils/models.py b/zhenxun/configs/utils/models.py index f60fdc92..163469c1 100644 --- a/zhenxun/configs/utils/models.py +++ b/zhenxun/configs/utils/models.py @@ -2,7 +2,7 @@ from collections.abc import Callable from datetime import datetime from typing import Any, Literal, Type # noqa: UP035 -from nonebot.compat import model_dump +from nonebot.compat import PYDANTIC_V2, model_dump from pydantic import BaseModel, Field from zhenxun.utils.enum import BlockType, LimitWatchType, PluginLimitType, PluginType @@ -65,11 +65,18 @@ class RegisterConfig(BaseModel): """配置注解""" default_value: Any | None = None """默认值""" - type: Type = str # noqa: UP006 + type: Type | Any = str # noqa: UP006 """参数类型""" arg_parser: Callable | None = None """参数解析""" + if PYDANTIC_V2: + model_config = {"arbitrary_types_allowed": True} + else: + + class Config: + arbitrary_types_allowed = True + class ConfigModel(BaseModel): """