diff --git a/none/__init__.py b/none/__init__.py index f3a1c128..1284f415 100644 --- a/none/__init__.py +++ b/none/__init__.py @@ -8,14 +8,13 @@ from typing import Any, Optional from aiocqhttp import CQHttp from aiocqhttp.message import Message -from . import default_config from .log import logger class NoneBot(CQHttp): def __init__(self, config_object: Any = None): if config_object is None: - config_object = default_config + from . import default_config as config_object super_kwargs = {k.lower(): v for k, v in config_object.__dict__.items() if k.isupper() and not k.startswith('_')} @@ -64,7 +63,7 @@ class NoneBot(CQHttp): return os.path.join(parent, os.path.basename(rel_path)) -_bot = None +_bot: Optional[NoneBot] = None def init(config_object: Any = None) -> None: @@ -93,7 +92,6 @@ def get_bot() -> NoneBot: """ if _bot is None: raise ValueError('NoneBot instance has not been initialized') - # noinspection PyTypeChecker return _bot diff --git a/none/command.py b/none/command.py index 43cc6029..b2dabc82 100644 --- a/none/command.py +++ b/none/command.py @@ -89,7 +89,7 @@ def on_command(name: Union[str, Tuple[str]], *, if not name: raise ValueError('the name of a command must not be empty') - cmd_name = name if isinstance(name, tuple) else (name,) + cmd_name = (name,) if isinstance(name, str) else name current_parent = _registry for parent_key in cmd_name[:-1]: current_parent[parent_key] = current_parent.get(parent_key) or {}