mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-09 22:00:01 +08:00
✨ Compatible with pydantic 2.0 using the pydantic compatibility layer provided by nonebot
This commit is contained in:
@@ -15,7 +15,7 @@ class ChartUtils:
|
||||
@classmethod
|
||||
async def barh(cls, data: Barh) -> BuildImage:
|
||||
"""横向统计图"""
|
||||
to_json = data.dict()
|
||||
to_json = data.to_dict()
|
||||
to_json["background_image"] = (
|
||||
f"./background/{random.choice(os.listdir(BACKGROUND_PATH))}"
|
||||
)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from nonebot.compat import model_dump
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
@@ -8,3 +9,6 @@ class Barh(BaseModel):
|
||||
"""实际数据"""
|
||||
title: str
|
||||
"""标题"""
|
||||
|
||||
def to_dict(self, **kwargs):
|
||||
return model_dump(self, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user