From 80594cffb694ff702700de75b678517716af9c43 Mon Sep 17 00:00:00 2001 From: Ju4tCode <42488585+yanyongyu@users.noreply.github.com> Date: Fri, 20 May 2022 17:34:15 +0800 Subject: [PATCH] :loud_sound: add export deprecation warning (#983) --- nonebot/plugin/export.py | 7 +++++++ nonebot/plugin/load.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/nonebot/plugin/export.py b/nonebot/plugin/export.py index d49cc362..f27740ed 100644 --- a/nonebot/plugin/export.py +++ b/nonebot/plugin/export.py @@ -7,6 +7,8 @@ FrontMatter: description: nonebot.plugin.export 模块 """ +import warnings + from . import _current_plugin @@ -51,6 +53,11 @@ class Export(dict): def export() -> Export: """获取当前插件的导出内容对象""" + warnings.warn( + "nonebot.export() is deprecated. " + "See https://github.com/nonebot/nonebot2/issues/935.", + DeprecationWarning, + ) plugin = _current_plugin.get() if not plugin: raise RuntimeError("Export outside of the plugin!") diff --git a/nonebot/plugin/load.py b/nonebot/plugin/load.py index 03d5dbde..7e762b69 100644 --- a/nonebot/plugin/load.py +++ b/nonebot/plugin/load.py @@ -107,7 +107,7 @@ def load_from_toml(file_path: str, encoding: str = "utf-8") -> Set[Plugin]: nonebot_data = data.get("nonebot", {}).get("plugins") if nonebot_data: warnings.warn( - "[nonebot.plugins] table are now deprecated. Use [tool.nonebot] instead.", + "[nonebot.plugins] table is deprecated. Use [tool.nonebot] instead.", DeprecationWarning, ) else: