🚨 Develop: 完全使用 ruff 替代 isort 与 black (#3151)

This commit is contained in:
Ju4tCode
2024-12-01 12:31:11 +08:00
committed by GitHub
parent 6dad4d2a74
commit 081dc8352d
83 changed files with 1815 additions and 1769 deletions

View File

@ -38,10 +38,10 @@ FrontMatter:
description: nonebot.plugin 模块
"""
from contextvars import ContextVar
from itertools import chain
from types import ModuleType
from contextvars import ContextVar
from typing import TypeVar, Optional
from typing import Optional, TypeVar
from pydantic import BaseModel
@ -175,30 +175,30 @@ def get_plugin_config(config: type[C]) -> C:
return type_validate_python(config, model_dump(get_driver().config))
from .on import on as on
from .manager import PluginManager
from .on import on_type as on_type
from .model import Plugin as Plugin
from .load import require as require
from .on import on_regex as on_regex
from .on import on_notice as on_notice
from .on import on_command as on_command
from .on import on_keyword as on_keyword
from .on import on_message as on_message
from .on import on_request as on_request
from .on import on_endswith as on_endswith
from .load import load_plugin as load_plugin
from .on import CommandGroup as CommandGroup
from .on import MatcherGroup as MatcherGroup
from .on import on_fullmatch as on_fullmatch
from .on import on_metaevent as on_metaevent
from .load import load_plugins as load_plugins
from .on import on_startswith as on_startswith
from .load import load_from_json as load_from_json
from .load import load_from_toml as load_from_toml
from .model import PluginMetadata as PluginMetadata
from .on import on_shell_command as on_shell_command
from .load import inherit_supported_adapters as inherit_supported_adapters
from .load import load_all_plugins as load_all_plugins
from .load import load_builtin_plugin as load_builtin_plugin
from .load import load_builtin_plugins as load_builtin_plugins
from .load import inherit_supported_adapters as inherit_supported_adapters
from .load import load_from_json as load_from_json
from .load import load_from_toml as load_from_toml
from .load import load_plugin as load_plugin
from .load import load_plugins as load_plugins
from .load import require as require
from .manager import PluginManager
from .model import Plugin as Plugin
from .model import PluginMetadata as PluginMetadata
from .on import CommandGroup as CommandGroup
from .on import MatcherGroup as MatcherGroup
from .on import on as on
from .on import on_command as on_command
from .on import on_endswith as on_endswith
from .on import on_fullmatch as on_fullmatch
from .on import on_keyword as on_keyword
from .on import on_message as on_message
from .on import on_metaevent as on_metaevent
from .on import on_notice as on_notice
from .on import on_regex as on_regex
from .on import on_request as on_request
from .on import on_shell_command as on_shell_command
from .on import on_startswith as on_startswith
from .on import on_type as on_type

View File

@ -7,17 +7,17 @@ FrontMatter:
description: nonebot.plugin.load 模块
"""
from collections.abc import Iterable
import json
from pathlib import Path
from types import ModuleType
from typing import Union, Optional
from collections.abc import Iterable
from typing import Optional, Union
from nonebot.utils import path_to_module_name
from .model import Plugin
from . import _managers, _module_name_to_plugin_id, get_plugin
from .manager import PluginManager
from . import _managers, get_plugin, _module_name_to_plugin_id
from .model import Plugin
try: # pragma: py-gte-311
import tomllib # pyright: ignore[reportMissingImports]

View File

@ -9,28 +9,28 @@ FrontMatter:
description: nonebot.plugin.manager 模块
"""
import sys
import pkgutil
import importlib
from pathlib import Path
from itertools import chain
from typing import Optional
from types import ModuleType
from importlib.abc import MetaPathFinder
from collections.abc import Iterable, Sequence
import importlib
from importlib.abc import MetaPathFinder
from importlib.machinery import PathFinder, SourceFileLoader
from itertools import chain
from pathlib import Path
import pkgutil
import sys
from types import ModuleType
from typing import Optional
from nonebot.log import logger
from nonebot.utils import escape_tag, path_to_module_name
from .model import Plugin, PluginMetadata
from . import (
_current_plugin,
_managers,
_module_name_to_plugin_id,
_new_plugin,
_revert_plugin,
_current_plugin,
_module_name_to_plugin_id,
)
from .model import Plugin, PluginMetadata
class PluginManager:

View File

@ -8,9 +8,9 @@ FrontMatter:
"""
import contextlib
from dataclasses import dataclass, field
from types import ModuleType
from dataclasses import field, dataclass
from typing import TYPE_CHECKING, Any, Type, Optional # noqa: UP035
from typing import TYPE_CHECKING, Any, Optional, Type # noqa: UP035
from pydantic import BaseModel

View File

@ -7,34 +7,34 @@ FrontMatter:
description: nonebot.plugin.on 模块
"""
import re
import inspect
import warnings
from types import ModuleType
from typing import Any, Union, Optional
from datetime import datetime, timedelta
import inspect
import re
from types import ModuleType
from typing import Any, Optional, Union
import warnings
from nonebot.adapters import Event
from nonebot.permission import Permission
from nonebot.dependencies import Dependent
from nonebot.matcher import Matcher, MatcherSource
from nonebot.typing import T_State, T_Handler, T_RuleChecker, T_PermissionChecker
from nonebot.permission import Permission
from nonebot.rule import (
Rule,
ArgumentParser,
regex,
Rule,
command,
is_type,
keyword,
endswith,
fullmatch,
startswith,
is_type,
keyword,
regex,
shell_command,
startswith,
)
from nonebot.typing import T_Handler, T_PermissionChecker, T_RuleChecker, T_State
from .model import Plugin
from .manager import _current_plugin
from . import get_plugin_by_module_name
from .manager import _current_plugin
from .model import Plugin
def store_matcher(matcher: type[Matcher]) -> None:

View File

@ -1,14 +1,14 @@
import re
from typing import Any
from types import ModuleType
from datetime import datetime, timedelta
import re
from types import ModuleType
from typing import Any
from nonebot.adapters import Event
from nonebot.permission import Permission
from nonebot.dependencies import Dependent
from nonebot.rule import Rule, ArgumentParser
from nonebot.matcher import Matcher, MatcherSource
from nonebot.typing import T_State, T_Handler, T_RuleChecker, T_PermissionChecker
from nonebot.permission import Permission
from nonebot.rule import ArgumentParser, Rule
from nonebot.typing import T_Handler, T_PermissionChecker, T_RuleChecker, T_State
from .model import Plugin