允许泛类类型

This commit is contained in:
molanp 2025-07-11 21:27:26 +08:00
parent 632ec3e46e
commit ce605a5421

View File

@ -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):
"""