🎨 isort format code

This commit is contained in:
yanyongyu 2021-09-27 00:19:30 +08:00
parent cfdebb30b7
commit 92a411e3b4
16 changed files with 41 additions and 33 deletions

View File

@ -22,6 +22,6 @@ except Exception:
from ._bot import Bot as Bot from ._bot import Bot as Bot
from ._event import Event as Event from ._event import Event as Event
from ._template import MessageTemplate as MessageTemplate
from ._message import Message as Message from ._message import Message as Message
from ._message import MessageSegment as MessageSegment from ._message import MessageSegment as MessageSegment
from ._template import MessageTemplate as MessageTemplate

View File

@ -2,12 +2,12 @@ import abc
import asyncio import asyncio
from functools import partial from functools import partial
from typing_extensions import Protocol from typing_extensions import Protocol
from typing import Any, Set, Union, Tuple, Optional, TYPE_CHECKING from typing import TYPE_CHECKING, Any, Set, Tuple, Union, Optional
from nonebot.log import logger from nonebot.log import logger
from nonebot.config import Config from nonebot.config import Config
from nonebot.typing import T_CallingAPIHook, T_CalledAPIHook from nonebot.typing import T_CalledAPIHook, T_CallingAPIHook
from nonebot.drivers import Driver, HTTPConnection, HTTPResponse from nonebot.drivers import Driver, HTTPResponse, HTTPConnection
if TYPE_CHECKING: if TYPE_CHECKING:
from ._event import Event from ._event import Event

View File

@ -1,7 +1,7 @@
import abc import abc
from copy import deepcopy from copy import deepcopy
from dataclasses import dataclass, field, asdict from dataclasses import field, asdict, dataclass
from typing import (Any, List, Dict, Type, Union, TypeVar, Mapping, Generic, from typing import (Any, Dict, List, Type, Union, Generic, Mapping, TypeVar,
Iterable) Iterable)
from ._template import MessageTemplate from ._template import MessageTemplate

View File

@ -1,8 +1,8 @@
import functools
import operator import operator
import functools
from string import Formatter from string import Formatter
from typing import (Any, Set, List, Type, Tuple, Union, TypeVar, Mapping, from typing import (TYPE_CHECKING, Any, Set, List, Type, Tuple, Union, Generic,
Generic, Sequence, TYPE_CHECKING) Mapping, TypeVar, Sequence)
if TYPE_CHECKING: if TYPE_CHECKING:
from . import Message from . import Message

View File

@ -17,11 +17,12 @@ import os
from pathlib import Path from pathlib import Path
from datetime import timedelta from datetime import timedelta
from ipaddress import IPv4Address from ipaddress import IPv4Address
from typing import Any, Set, Dict, Union, Tuple, Mapping, Optional from typing import Any, Set, Dict, Tuple, Union, Mapping, Optional
from pydantic import BaseSettings, IPvAnyAddress from pydantic import BaseSettings, IPvAnyAddress
from pydantic.env_settings import SettingsError, InitSettingsSource, EnvSettingsSource from pydantic.env_settings import (SettingsError, EnvSettingsSource,
from pydantic.env_settings import read_env_file, env_file_sentinel, SettingsSourceCallable InitSettingsSource, SettingsSourceCallable,
read_env_file, env_file_sentinel)
class CustomEnvSettings(EnvSettingsSource): class CustomEnvSettings(EnvSettingsSource):

View File

@ -7,8 +7,9 @@
import abc import abc
import asyncio import asyncio
from dataclasses import dataclass, field from dataclasses import field, dataclass
from typing import Any, Set, Dict, Type, Union, Optional, Callable, Awaitable, TYPE_CHECKING from typing import (TYPE_CHECKING, Any, Set, Dict, Type, Union, Callable,
Optional, Awaitable)
from nonebot.log import logger from nonebot.log import logger
from nonebot.utils import escape_tag from nonebot.utils import escape_tag

View File

@ -12,7 +12,7 @@ NoneBot 使用 `loguru`_ 来记录日志信息。
import sys import sys
import logging import logging
from typing import Union, TYPE_CHECKING from typing import TYPE_CHECKING, Union
import loguru import loguru

View File

@ -10,8 +10,8 @@ from types import ModuleType
from datetime import datetime from datetime import datetime
from contextvars import ContextVar from contextvars import ContextVar
from collections import defaultdict from collections import defaultdict
from typing import (TYPE_CHECKING, Any, Dict, List, Type, Union, Mapping, from typing import (TYPE_CHECKING, Any, Dict, List, Type, Union, Callable,
Callable, Iterable, NoReturn, Optional) NoReturn, Optional)
from nonebot.rule import Rule from nonebot.rule import Rule
from nonebot.log import logger from nonebot.log import logger

View File

@ -7,14 +7,15 @@ NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供
import asyncio import asyncio
from datetime import datetime from datetime import datetime
from typing import Set, Type, Optional, TYPE_CHECKING from typing import TYPE_CHECKING, Set, Type, Optional
from nonebot.log import logger from nonebot.log import logger
from nonebot.rule import TrieRule from nonebot.rule import TrieRule
from nonebot.utils import escape_tag from nonebot.utils import escape_tag
from nonebot.matcher import matchers, Matcher from nonebot.matcher import Matcher, matchers
from nonebot.exception import IgnoredException, StopPropagation, NoLogException from nonebot.exception import NoLogException, StopPropagation, IgnoredException
from nonebot.typing import T_State, T_EventPreProcessor, T_RunPreProcessor, T_EventPostProcessor, T_RunPostProcessor from nonebot.typing import (T_State, T_RunPreProcessor, T_RunPostProcessor,
T_EventPreProcessor, T_EventPostProcessor)
if TYPE_CHECKING: if TYPE_CHECKING:
from nonebot.adapters import Bot, Event from nonebot.adapters import Bot, Event

View File

@ -10,7 +10,7 @@ r"""
""" """
import asyncio import asyncio
from typing import Union, Optional, Callable, NoReturn, Awaitable, TYPE_CHECKING from typing import TYPE_CHECKING, Union, Callable, NoReturn, Optional, Awaitable
from nonebot.utils import run_sync from nonebot.utils import run_sync
from nonebot.typing import T_PermissionChecker from nonebot.typing import T_PermissionChecker
@ -141,8 +141,8 @@ def USER(*user: str, perm: Optional[Permission] = None):
""" """
async def _user(bot: "Bot", event: "Event") -> bool: async def _user(bot: "Bot", event: "Event") -> bool:
return bool(event.get_session_id() in user and (perm is None or return bool(event.get_session_id() in user and
await perm(bot, event))) (perm is None or await perm(bot, event)))
return Permission(_user) return Permission(_user)

View File

@ -8,10 +8,10 @@ from types import ModuleType
from collections import Counter from collections import Counter
from contextvars import ContextVar from contextvars import ContextVar
from importlib.abc import MetaPathFinder from importlib.abc import MetaPathFinder
from typing import Set, List, Optional, Iterable from typing import Set, List, Iterable, Optional
from importlib.machinery import PathFinder, SourceFileLoader from importlib.machinery import PathFinder, SourceFileLoader
from .export import _export, Export from .export import Export, _export
_current_plugin: ContextVar[Optional[ModuleType]] = ContextVar( _current_plugin: ContextVar[Optional[ModuleType]] = ContextVar(
"_current_plugin", default=None) "_current_plugin", default=None)

View File

@ -3,7 +3,8 @@ from functools import reduce
from nonebot.rule import to_me from nonebot.rule import to_me
from nonebot.plugin import on_command from nonebot.plugin import on_command
from nonebot.permission import SUPERUSER from nonebot.permission import SUPERUSER
from nonebot.adapters.cqhttp import Bot, unescape, MessageEvent, Message, MessageSegment from nonebot.adapters.cqhttp import (Bot, Message, MessageEvent, MessageSegment,
unescape)
say = on_command("say", to_me(), permission=SUPERUSER) say = on_command("say", to_me(), permission=SUPERUSER)

View File

@ -3,7 +3,8 @@ from typing import Dict, Optional
from nonebot.typing import T_State from nonebot.typing import T_State
from nonebot.matcher import Matcher from nonebot.matcher import Matcher
from nonebot.adapters import Bot, Event from nonebot.adapters import Bot, Event
from nonebot.message import run_preprocessor, run_postprocessor, IgnoredException from nonebot.message import (IgnoredException, run_preprocessor,
run_postprocessor)
_running_matcher: Dict[str, int] = {} _running_matcher: Dict[str, int] = {}

View File

@ -13,8 +13,10 @@ import re
import shlex import shlex
import asyncio import asyncio
from itertools import product from itertools import product
from argparse import Namespace, ArgumentParser as ArgParser from argparse import Namespace
from typing import Any, Dict, Union, Tuple, Optional, Callable, Sequence, NoReturn, Awaitable, TYPE_CHECKING from argparse import ArgumentParser as ArgParser
from typing import (TYPE_CHECKING, Any, Dict, Tuple, Union, Callable, NoReturn,
Optional, Sequence, Awaitable)
from pygtrie import CharTrie from pygtrie import CharTrie
@ -25,7 +27,7 @@ from nonebot.exception import ParserExit
from nonebot.typing import T_State, T_RuleChecker from nonebot.typing import T_State, T_RuleChecker
if TYPE_CHECKING: if TYPE_CHECKING:
from nonebot.adapters import Bot, Event, MessageSegment from nonebot.adapters import Bot, Event
class Rule: class Rule:

View File

@ -18,7 +18,8 @@
https://docs.python.org/3/library/typing.html https://docs.python.org/3/library/typing.html
""" """
from collections.abc import Callable as BaseCallable from collections.abc import Callable as BaseCallable
from typing import Any, Dict, Union, TypeVar, Optional, Callable, NoReturn, Awaitable, TYPE_CHECKING from typing import (TYPE_CHECKING, Any, Dict, Union, TypeVar, Callable,
NoReturn, Optional, Awaitable)
if TYPE_CHECKING: if TYPE_CHECKING:
from nonebot.matcher import Matcher from nonebot.matcher import Matcher

View File

@ -3,7 +3,7 @@ import json
import asyncio import asyncio
import dataclasses import dataclasses
from functools import wraps, partial from functools import wraps, partial
from typing import Any, Optional, Callable, Awaitable from typing import Any, Callable, Optional, Awaitable
from nonebot.log import logger from nonebot.log import logger
from nonebot.typing import overrides from nonebot.typing import overrides