🚨 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

@ -1,12 +1,12 @@
from .manager import MatcherManager as MatcherManager
from .provider import MatcherProvider as MatcherProvider
from .provider import DEFAULT_PROVIDER_CLASS as DEFAULT_PROVIDER_CLASS
from .provider import MatcherProvider as MatcherProvider
matchers = MatcherManager()
from .matcher import Matcher as Matcher
from .matcher import current_bot as current_bot
from .matcher import MatcherSource as MatcherSource
from .matcher import current_bot as current_bot
from .matcher import current_event as current_event
from .matcher import current_handler as current_handler
from .matcher import current_matcher as current_matcher

View File

@ -1,5 +1,5 @@
from typing import TYPE_CHECKING, Union, TypeVar, Optional, overload
from collections.abc import Iterator, KeysView, ItemsView, ValuesView, MutableMapping
from collections.abc import ItemsView, Iterator, KeysView, MutableMapping, ValuesView
from typing import TYPE_CHECKING, Optional, TypeVar, Union, overload
from .provider import DEFAULT_PROVIDER_CLASS, MatcherProvider
@ -74,9 +74,9 @@ class MatcherManager(MutableMapping[int, list[type["Matcher"]]]):
self.provider.clear()
def update( # pyright: ignore[reportIncompatibleMethodOverride]
self, __m: MutableMapping[int, list[type["Matcher"]]]
self, m: MutableMapping[int, list[type["Matcher"]]], /
) -> None:
self.provider.update(__m)
self.provider.update(m)
def setdefault(
self, key: int, default: list[type["Matcher"]]

View File

@ -1,34 +1,44 @@
import sys
import inspect
import warnings
from pathlib import Path
from types import ModuleType
from dataclasses import dataclass
from contextvars import ContextVar
from typing_extensions import Self
from collections.abc import Iterable
from datetime import datetime, timedelta
from contextlib import AsyncExitStack, contextmanager
from contextvars import ContextVar
from dataclasses import dataclass
from datetime import datetime, timedelta
import inspect
from pathlib import Path
import sys
from types import ModuleType
from typing import ( # noqa: UP035
TYPE_CHECKING,
Any,
Type,
Union,
TypeVar,
Callable,
ClassVar,
NoReturn,
Optional,
Type,
TypeVar,
Union,
overload,
)
from typing_extensions import Self
import warnings
from exceptiongroup import BaseExceptionGroup, catch
from nonebot.log import logger
from nonebot.internal.rule import Rule
from nonebot.dependencies import Param, Dependent
from nonebot.internal.permission import User, Permission
from nonebot.utils import classproperty, flatten_exception_group
from nonebot.consts import (
ARG_KEY,
LAST_RECEIVE_KEY,
RECEIVE_KEY,
REJECT_CACHE_TARGET,
REJECT_TARGET,
)
from nonebot.dependencies import Dependent, Param
from nonebot.exception import (
FinishedException,
PausedException,
RejectedException,
SkippedException,
StopPropagation,
)
from nonebot.internal.adapter import (
Bot,
Event,
@ -36,37 +46,27 @@ from nonebot.internal.adapter import (
MessageSegment,
MessageTemplate,
)
from nonebot.typing import (
T_State,
T_Handler,
T_TypeUpdater,
T_DependencyCache,
T_PermissionUpdater,
)
from nonebot.consts import (
ARG_KEY,
RECEIVE_KEY,
REJECT_TARGET,
LAST_RECEIVE_KEY,
REJECT_CACHE_TARGET,
)
from nonebot.exception import (
PausedException,
StopPropagation,
SkippedException,
FinishedException,
RejectedException,
)
from nonebot.internal.params import (
Depends,
ArgParam,
BotParam,
EventParam,
StateParam,
DependParam,
DefaultParam,
DependParam,
Depends,
EventParam,
MatcherParam,
StateParam,
)
from nonebot.internal.permission import Permission, User
from nonebot.internal.rule import Rule
from nonebot.log import logger
from nonebot.typing import (
T_DependencyCache,
T_Handler,
T_PermissionUpdater,
T_State,
T_TypeUpdater,
)
from nonebot.utils import classproperty, flatten_exception_group
from . import matchers
@ -861,7 +861,7 @@ class Matcher(metaclass=MatcherMeta):
def _handle_special_exception(
exc_group: BaseExceptionGroup[
Union[FinishedException, RejectedException, PausedException]
]
],
):
nonlocal exc
excs = list(flatten_exception_group(exc_group))

View File

@ -1,7 +1,7 @@
import abc
from typing import TYPE_CHECKING
from collections import defaultdict
from collections.abc import Mapping, MutableMapping
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .matcher import Matcher