Skip to content

Commit 06b0684

Browse files
committed
fix: 插件测试使用 logger 来提示错误
1 parent 7451b13 commit 06b0684

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/utils/plugin_test.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
RUNNER = """import json
3232
import os
3333
34-
from nonebot import init, load_plugin, require
34+
from nonebot import init, load_plugin, require, logger
3535
from pydantic import BaseModel
3636
3737
@@ -59,12 +59,8 @@ def default(self, obj):
5959
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf8") as f:
6060
f.write(f"METADATA<<EOF\\n{{json.dumps(metadata, cls=SetEncoder)}}\\nEOF\\n")
6161
62-
try:
63-
if plugin.metadata.config and not issubclass(plugin.metadata.config, BaseModel):
64-
print("插件配置项不是 Pydantic BaseModel 的子类")
65-
exit(1)
66-
except TypeError:
67-
print("插件配置项应该为 Pydantic BaseModel 子类而不是实例")
62+
if plugin.metadata.config and not issubclass(plugin.metadata.config, BaseModel):
63+
logger.error("插件配置项不是 Pydantic BaseModel 的子类")
6864
exit(1)
6965
7066
{}

0 commit comments

Comments
 (0)