mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
允许泛类类型
This commit is contained in:
parent
632ec3e46e
commit
ce605a5421
@ -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):
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user