kitUIN / nonebot-plugin-ncm

✨ 基于go-cqhttp与nonebot2的 网易云 无损音乐 点歌/下载 ✨
Apache License 2.0
81 stars 3 forks source link

[BUG] Use nonebot.plugin.PluginMetadata instead of define your own one #16

Closed XZhouQD closed 1 year ago

XZhouQD commented 1 year ago

Hi, I've just helped on debugging someone's issue and find the use of PluginMetadata is wrong: Check your __init__.py:L24

You should always use nonebot.plugin.PluginMetadata instead of define a new one.

This will cause errors when users are using other help plugins and accessing fields like extra with default values assumed in nonebot.plugin.PluginMetadata while your defined one does not have. For example, nonebot-plugin-picmenu will always read extra field of meta without protection (because this field is always there when using nonebot.plugin.PluginMetadata) and will lead to an error like

funcs=_meta_data.extra['menu_data'] if 'menu_data' in _meta_data.extra else None,
AttributeError: 'PluginMetadata' object has no attribute 'extra'
kitUIN commented 1 year ago

thanks for your help