🚨 re-export according to pep484

This commit is contained in:
yanyongyu
2021-09-18 16:11:03 +08:00
parent a273d75b07
commit 4f8771acbd
8 changed files with 79 additions and 34 deletions

View File

@ -29,9 +29,10 @@
"""
import importlib
import pkg_resources
from typing import Any, Dict, Type, Optional
import pkg_resources
from nonebot.adapters import Bot
from nonebot.utils import escape_tag
from nonebot.config import Env, Config
@ -277,8 +278,25 @@ def run(host: Optional[str] = None,
get_driver().run(host, port, *args, **kwargs)
from nonebot.plugin import on_message, on_notice, on_request, on_metaevent, CommandGroup, MatcherGroup
from nonebot.plugin import on_startswith, on_endswith, on_keyword, on_command, on_shell_command, on_regex
from nonebot.plugin import load_plugin, load_plugins, load_all_plugins, load_builtin_plugins
from nonebot.plugin import load_from_json, load_from_toml
from nonebot.plugin import export, require, get_plugin, get_loaded_plugins
from nonebot.plugin import export as export
from nonebot.plugin import require as require
from nonebot.plugin import on_regex as on_regex
from nonebot.plugin import on_notice as on_notice
from nonebot.plugin import get_plugin as get_plugin
from nonebot.plugin import on_command as on_command
from nonebot.plugin import on_keyword as on_keyword
from nonebot.plugin import on_message as on_message
from nonebot.plugin import on_request as on_request
from nonebot.plugin import load_plugin as load_plugin
from nonebot.plugin import on_endswith as on_endswith
from nonebot.plugin import CommandGroup as CommandGroup
from nonebot.plugin import MatcherGroup as MatcherGroup
from nonebot.plugin import load_plugins as load_plugins
from nonebot.plugin import on_metaevent as on_metaevent
from nonebot.plugin import on_startswith as on_startswith
from nonebot.plugin import load_from_json as load_from_json
from nonebot.plugin import load_from_toml as load_from_toml
from nonebot.plugin import load_all_plugins as load_all_plugins
from nonebot.plugin import on_shell_command as on_shell_command
from nonebot.plugin import get_loaded_plugins as get_loaded_plugins
from nonebot.plugin import load_builtin_plugins as load_builtin_plugins

View File

@ -10,20 +10,22 @@ Quart 驱动适配
import asyncio
from dataclasses import dataclass
from typing import List, TypeVar, Callable, Coroutine, Optional
from typing import List, TypeVar, Callable, Optional, Coroutine
import uvicorn
from pydantic import BaseSettings
from nonebot.config import Env
from nonebot.log import logger
from nonebot.utils import escape_tag
from nonebot.typing import overrides
from nonebot.config import Env, Config as NoneBotConfig
from nonebot.drivers import ReverseDriver, HTTPRequest, WebSocket as BaseWebSocket
from nonebot.utils import escape_tag
from nonebot.config import Config as NoneBotConfig
from nonebot.drivers import HTTPRequest, ReverseDriver
from nonebot.drivers import WebSocket as BaseWebSocket
try:
from werkzeug import exceptions
from quart import request as _request
import werkzeug.exceptions as exceptions
from quart import websocket as _websocket
from quart import Quart, Request, Response
from quart import Websocket as QuartWebSocket

View File

@ -10,18 +10,22 @@ from types import ModuleType
from dataclasses import dataclass
from collections import defaultdict
from contextvars import Context, copy_context
from typing import Any, Set, List, Dict, Type, Tuple, Union, Optional, TYPE_CHECKING
from typing import (TYPE_CHECKING, Any, Set, Dict, List, Type, Tuple, Union,
Optional)
import tomlkit
from nonebot.log import logger
from nonebot.matcher import Matcher
from nonebot.handler import Handler
from nonebot.matcher import Matcher
from nonebot.utils import escape_tag
from nonebot.permission import Permission
from nonebot.typing import T_State, T_StateFactory, T_Handler, T_RuleChecker
from nonebot.rule import Rule, startswith, endswith, keyword, command, shell_command, ArgumentParser, regex
from nonebot.typing import T_State, T_Handler, T_RuleChecker, T_StateFactory
from nonebot.rule import (Rule, ArgumentParser, regex, command, keyword,
endswith, startswith, shell_command)
from .export import Export, export, _export
from .export import Export
from .export import export as export
from .manager import PluginManager, _current_plugin
if TYPE_CHECKING:
@ -1072,7 +1076,7 @@ def load_from_toml(file_path: str, encoding: str = "utf-8") -> Set[Plugin]:
- ``Set[Plugin]``
"""
with open(file_path, "r", encoding=encoding) as f:
data = tomlkit.parse(f.read())
data = tomlkit.parse(f.read()) # type: ignore
nonebot_data = data.get("nonebot", {}).get("plugins")
if not nonebot_data:

View File

@ -1,16 +1,16 @@
import re
from types import ModuleType
from dataclasses import dataclass
from typing import Set, List, Dict, Type, Tuple, Union, Optional, TYPE_CHECKING
from typing import Set, Dict, List, Type, Tuple, Union, Optional
from nonebot.matcher import Matcher
from nonebot.handler import Handler
from nonebot.matcher import Matcher
from nonebot.permission import Permission
from nonebot.rule import Rule, ArgumentParser
from nonebot.typing import T_State, T_StateFactory, T_Handler, T_RuleChecker
from nonebot.typing import T_State, T_Handler, T_RuleChecker, T_StateFactory
from .export import Export, export
from .manager import PluginManager
from .export import Export
from .export import export as export
plugins: Dict[str, "Plugin"] = ...
PLUGIN_NAMESPACE: str = ...