🔊 add export deprecation warning (#983)

This commit is contained in:
Ju4tCode 2022-05-20 17:34:15 +08:00 committed by GitHub
parent 6d4c5cbc2d
commit 80594cffb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -7,6 +7,8 @@ FrontMatter:
description: nonebot.plugin.export 模块 description: nonebot.plugin.export 模块
""" """
import warnings
from . import _current_plugin from . import _current_plugin
@ -51,6 +53,11 @@ class Export(dict):
def export() -> Export: def export() -> Export:
"""获取当前插件的导出内容对象""" """获取当前插件的导出内容对象"""
warnings.warn(
"nonebot.export() is deprecated. "
"See https://github.com/nonebot/nonebot2/issues/935.",
DeprecationWarning,
)
plugin = _current_plugin.get() plugin = _current_plugin.get()
if not plugin: if not plugin:
raise RuntimeError("Export outside of the plugin!") raise RuntimeError("Export outside of the plugin!")

View File

@ -107,7 +107,7 @@ def load_from_toml(file_path: str, encoding: str = "utf-8") -> Set[Plugin]:
nonebot_data = data.get("nonebot", {}).get("plugins") nonebot_data = data.get("nonebot", {}).get("plugins")
if nonebot_data: if nonebot_data:
warnings.warn( warnings.warn(
"[nonebot.plugins] table are now deprecated. Use [tool.nonebot] instead.", "[nonebot.plugins] table is deprecated. Use [tool.nonebot] instead.",
DeprecationWarning, DeprecationWarning,
) )
else: else: