mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-05-08 17:58:55 +08:00
⬆️ 适配 Pydantic V2 (#484)
* ⬆️ 适配 Pydantic V2 * 🐛 修复测试报错 * 🐛 适配忘记的 from_orm * 🐛 忘记的 class-based `config` * 🐛 更新 red 适配器版本
This commit is contained in:
@@ -3,9 +3,10 @@ from datetime import datetime
|
||||
from typing import TYPE_CHECKING, Literal
|
||||
|
||||
import jinja2
|
||||
from pydantic import BaseModel, root_validator
|
||||
from pydantic import BaseModel
|
||||
from nonebot_plugin_saa import Text, Image, MessageSegmentFactory
|
||||
|
||||
from nonebot_bison.compat import model_validator
|
||||
from nonebot_bison.theme.utils import convert_to_qr
|
||||
from nonebot_bison.theme import Theme, ThemeRenderError, ThemeRenderUnsupportError
|
||||
|
||||
@@ -35,7 +36,7 @@ class CeoboContent(BaseModel):
|
||||
image: str | None
|
||||
text: str | None
|
||||
|
||||
@root_validator
|
||||
@model_validator(mode="before")
|
||||
def check(cls, values):
|
||||
if values["image"] is None and values["text"] is None:
|
||||
raise ValueError("image and text cannot be both None")
|
||||
|
||||
Reference in New Issue
Block a user