Skip to content

Commit f21882b

Browse files
committed
u
1 parent 59a38f2 commit f21882b

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,6 @@ Telegram:[@lgc2333](https://t.me/lgc2333)
204204

205205
## 📝 更新日志
206206

207-
芝士刚刚发布的插件,还没有更新日志的说 qwq~
207+
### 0.1.1
208+
209+
- 尝试兼容 Pydantic V1

nonebot_plugin_picmenu_next/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .data_source import refresh_infos
1212
from .templates import load_builtin_templates
1313

14-
__version__ = "0.1.0.post1"
14+
__version__ = "0.1.1"
1515
__plugin_meta__ = PluginMetadata(
1616
name="PicMenu Next",
1717
description="新一代的图片帮助插件",

nonebot_plugin_picmenu_next/data_source/models.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
from functools import cached_property
22
from typing import Any, Optional, TypeVar, Union
33

4-
from cookit.pyd import model_validator, type_dump_python
4+
from cookit.pyd import (
5+
PYDANTIC_V2,
6+
model_validator,
7+
model_with_model_config,
8+
type_dump_python,
9+
)
510
from nonebot import get_plugin
611
from nonebot.plugin import Plugin
7-
from pydantic import BaseModel, Field
12+
from pydantic import BaseModel, ConfigDict, Field
813

914
from .pinyin import PinyinChunkSequence
1015

1116
T = TypeVar("T")
1217

1318

19+
if PYDANTIC_V2:
20+
cp_model_config: ConfigDict = {}
21+
else:
22+
cp_model_config: ConfigDict = {
23+
"arbitrary_types_allowed": True,
24+
"keep_untouched": (cached_property,),
25+
}
26+
27+
28+
@model_with_model_config(cp_model_config)
1429
class PMDataItem(BaseModel):
1530
func: str
1631
trigger_method: str
@@ -59,6 +74,7 @@ def normalize_input(cls, values: Any): # noqa: N805
5974
return values
6075

6176

77+
@model_with_model_config(cp_model_config)
6278
class PMNPluginInfo(BaseModel):
6379
name: str
6480
plugin_id: Optional[str] = None

0 commit comments

Comments
 (0)