File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -204,4 +204,6 @@ Telegram:[@lgc2333](https://t.me/lgc2333)
204
204
205
205
## 📝 更新日志
206
206
207
- 芝士刚刚发布的插件,还没有更新日志的说 qwq~
207
+ ### 0.1.1
208
+
209
+ - 尝试兼容 Pydantic V1
Original file line number Diff line number Diff line change 11
11
from .data_source import refresh_infos
12
12
from .templates import load_builtin_templates
13
13
14
- __version__ = "0.1.0.post1 "
14
+ __version__ = "0.1.1 "
15
15
__plugin_meta__ = PluginMetadata (
16
16
name = "PicMenu Next" ,
17
17
description = "新一代的图片帮助插件" ,
Original file line number Diff line number Diff line change 1
1
from functools import cached_property
2
2
from typing import Any , Optional , TypeVar , Union
3
3
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
+ )
5
10
from nonebot import get_plugin
6
11
from nonebot .plugin import Plugin
7
- from pydantic import BaseModel , Field
12
+ from pydantic import BaseModel , ConfigDict , Field
8
13
9
14
from .pinyin import PinyinChunkSequence
10
15
11
16
T = TypeVar ("T" )
12
17
13
18
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 )
14
29
class PMDataItem (BaseModel ):
15
30
func : str
16
31
trigger_method : str
@@ -59,6 +74,7 @@ def normalize_input(cls, values: Any): # noqa: N805
59
74
return values
60
75
61
76
77
+ @model_with_model_config (cp_model_config )
62
78
class PMNPluginInfo (BaseModel ):
63
79
name : str
64
80
plugin_id : Optional [str ] = None
You can’t perform that action at this time.
0 commit comments