From c7d93069ef39df715c4483739ec42e6ba318bb70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=B5=E5=91=B5=E3=81=A7=E3=81=99?= <51957264+shoucandanghehe@users.noreply.github.com> Date: Wed, 23 Oct 2024 00:00:22 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E5=85=BC=E5=AE=B9pydantic=20v1?= =?UTF-8?q?=20(#489)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../games/tetrio/api/schemas/leaderboards/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/leaderboards/__init__.py b/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/leaderboards/__init__.py index a4a6020..e37caac 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/leaderboards/__init__.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/leaderboards/__init__.py @@ -1,5 +1,6 @@ from typing import Any +from nonebot.compat import PYDANTIC_V2 from pydantic import BaseModel, Field from ...typing import Prisecter @@ -12,4 +13,6 @@ class Parameter(BaseModel): country: str | None = None def to_params(self) -> dict[str, Any]: - return self.model_dump(exclude_defaults=True) + if PYDANTIC_V2: + return self.model_dump(exclude_defaults=True) + return self.dict(exclude_defaults=True)