From 632ec3e46e15c242c3515dfb0e2816882a4265b7 Mon Sep 17 00:00:00 2001 From: molanp <104612722+molanp@users.noreply.github.com> Date: Fri, 11 Jul 2025 17:15:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(zhenxun):=20=E4=BF=AE=E5=A4=8D=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E7=B1=BB=E5=9E=8B=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= =?UTF-8?q?=20(#1971)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改了配置类型判断逻辑,当 reg_config.type 为 None 时,使用 reg_config.value 的类型 - 这样可以更准确地处理配置项的类型,避免潜在的类型错误 --- zhenxun/builtin_plugins/init/init_config.py | 2 +- zhenxun/configs/utils/models.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zhenxun/builtin_plugins/init/init_config.py b/zhenxun/builtin_plugins/init/init_config.py index 7baaa971..51a7da47 100644 --- a/zhenxun/builtin_plugins/init/init_config.py +++ b/zhenxun/builtin_plugins/init/init_config.py @@ -46,7 +46,7 @@ def _handle_config(plugin: Plugin, exists_module: list[str]): reg_config.value, help=reg_config.help, default_value=reg_config.default_value, - type=reg_config.type or type(reg_config.value), + type=reg_config.type, arg_parser=reg_config.arg_parser, _override=False, ) diff --git a/zhenxun/configs/utils/models.py b/zhenxun/configs/utils/models.py index d3c0db7f..f60fdc92 100644 --- a/zhenxun/configs/utils/models.py +++ b/zhenxun/configs/utils/models.py @@ -1,6 +1,6 @@ from collections.abc import Callable from datetime import datetime -from typing import Any, Literal +from typing import Any, Literal, Type # noqa: UP035 from nonebot.compat import model_dump from pydantic import BaseModel, Field @@ -65,7 +65,7 @@ class RegisterConfig(BaseModel): """配置注解""" default_value: Any | None = None """默认值""" - type: Any = None + type: Type = str # noqa: UP006 """参数类型""" arg_parser: Callable | None = None """参数解析"""