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)
204204
205205## 📝 更新日志
206206
207- 芝士刚刚发布的插件,还没有更新日志的说 qwq~
207+ ### 0.1.1
208+
209+ - 尝试兼容 Pydantic V1
Original file line number Diff line number Diff line change 1111from .data_source import refresh_infos
1212from .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 = "新一代的图片帮助插件" ,
Original file line number Diff line number Diff line change 11from functools import cached_property
22from 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+ )
510from nonebot import get_plugin
611from nonebot .plugin import Plugin
7- from pydantic import BaseModel , Field
12+ from pydantic import BaseModel , ConfigDict , Field
813
914from .pinyin import PinyinChunkSequence
1015
1116T = 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 )
1429class 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 )
6278class PMNPluginInfo (BaseModel ):
6379 name : str
6480 plugin_id : Optional [str ] = None
You can’t perform that action at this time.
0 commit comments