Skip to content

Commit

Permalink
fix: 不使用 asdict 避免遇到无法处理的类而报错 (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
he0119 authored Oct 21, 2023
1 parent 5570357 commit 5caaff9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/lang/zh-CN/
### Fixed

- 修复未通过标签判断是否是插件发布的问题
- 不使用 asdict 避免遇到无法处理的类而报错

## [3.1.1] - 2023-10-02

Expand Down
15 changes: 8 additions & 7 deletions src/utils/plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

RUNNER = """import json
import os
from dataclasses import asdict
from nonebot import init, load_plugin, require
Expand All @@ -48,12 +47,14 @@ def default(self, obj):
exit(1)
else:
if plugin.metadata:
metadata = asdict(
plugin.metadata,
dict_factory=lambda x: {{
k: v for (k, v) in x if k not in ("config", "extra")
}},
)
metadata = {{
"name": plugin.metadata.name,
"description": plugin.metadata.description,
"usage": plugin.metadata.usage,
"type": plugin.metadata.type,
"homepage": plugin.metadata.homepage,
"supported_adapters": plugin.metadata.supported_adapters,
}}
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf8") as f:
f.write(f"METADATA<<EOF\\n{{json.dumps(metadata, cls=SetEncoder)}}\\nEOF\\n")
Expand Down

0 comments on commit 5caaff9

Please sign in to comment.