Compare commits

...

2 Commits

Author SHA1 Message Date
c02fdfc47f 🔖 1.0.0.a17 2024-04-30 02:27:31 +08:00
93b169fa40 🐛 修复对 Pydantic V1 的适配 2024-04-30 02:27:08 +08:00
3 changed files with 5 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ from datetime import datetime
from typing import Any from typing import Any
from nonebot.adapters import Message from nonebot.adapters import Message
from nonebot.compat import type_validate_json
from nonebot_plugin_orm import Model from nonebot_plugin_orm import Model
from pydantic import BaseModel, ValidationError from pydantic import BaseModel, ValidationError
from sqlalchemy import JSON, DateTime, Dialect, PickleType, String, TypeDecorator from sqlalchemy import JSON, DateTime, Dialect, PickleType, String, TypeDecorator
@@ -30,7 +31,7 @@ class PydanticType(TypeDecorator):
if isinstance(value, str | bytes): if isinstance(value, str | bytes):
for i in self.get_model(): for i in self.get_model():
try: try:
return i.model_validate_json(value) return type_validate_json(i, value)
except ValidationError: # noqa: PERF203 except ValidationError: # noqa: PERF203
... ...
raise TypeError raise TypeError

View File

@@ -155,8 +155,8 @@ class Processor(ProcessorMeta):
failover_code=[502], failover_code=[502],
failover_exc=(TimeoutException,), failover_exc=(TimeoutException,),
) )
self.processed_data.user_profile[params] = UserProfile.model_validate_json( self.processed_data.user_profile[params] = type_validate_json(
self.raw_response.user_profile[params] UserProfile, self.raw_response.user_profile[params]
) )
return self.processed_data.user_profile[params] return self.processed_data.user_profile[params]

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = 'nonebot-plugin-tetris-stats' name = 'nonebot-plugin-tetris-stats'
version = '1.0.0.a16' version = '1.0.0.a17'
description = '一款基于 NoneBot2 的用于查询 Tetris 相关游戏数据的插件' description = '一款基于 NoneBot2 的用于查询 Tetris 相关游戏数据的插件'
authors = ['scdhh <wallfjjd@gmail.com>'] authors = ['scdhh <wallfjjd@gmail.com>']
readme = 'README.md' readme = 'README.md'