From 8a6c26440c8580f13a73d52d22ab6ccd988b5c98 Mon Sep 17 00:00:00 2001 From: StarHeartHunt Date: Fri, 23 Jul 2021 14:46:55 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20sort=20imports=20in=20feishu=20a?= =?UTF-8?q?dapter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nonebot/adapters/feishu/bot.py | 17 +++++++++-------- .../nonebot/adapters/feishu/event.py | 4 ++-- .../nonebot/adapters/feishu/exception.py | 8 ++++---- .../nonebot/adapters/feishu/message.py | 9 +++++---- .../nonebot/adapters/feishu/utils.py | 1 + 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/bot.py b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/bot.py index 9045dbc2..c5ae46e1 100644 --- a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/bot.py +++ b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/bot.py @@ -1,22 +1,23 @@ -import httpx import json import re +from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Union -from aiocache import cached, Cache +import httpx +from aiocache import Cache, cached from aiocache.serializers import PickleSerializer -from typing import Any, Dict, Tuple, Union, Optional, TYPE_CHECKING -from nonebot.log import logger -from nonebot.typing import overrides -from nonebot.message import handle_event from nonebot.adapters import Bot as BaseBot from nonebot.drivers import Driver, HTTPRequest, HTTPResponse +from nonebot.log import logger +from nonebot.message import handle_event +from nonebot.typing import overrides from .config import Config as FeishuConfig -from .event import Event, GroupMessageEvent, MessageEvent, PrivateMessageEvent, Reply, get_event_model +from .event import (Event, GroupMessageEvent, MessageEvent, + PrivateMessageEvent, get_event_model) from .exception import ActionFailed, ApiNotAvailable, NetworkError from .message import Message, MessageSegment, MessageSerializer -from .utils import log, AESCipher +from .utils import AESCipher, log if TYPE_CHECKING: from nonebot.config import Config diff --git a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/event.py b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/event.py index 5abeda95..26c5f4bb 100644 --- a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/event.py +++ b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/event.py @@ -1,9 +1,9 @@ import inspect import json - from typing import Any, Dict, List, Literal, Optional, Type + +from pydantic import BaseModel, Field, root_validator from pygtrie import StringTrie -from pydantic import BaseModel, root_validator, Field from nonebot.adapters import Event as BaseEvent from nonebot.typing import overrides diff --git a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/exception.py b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/exception.py index 791000af..38336e53 100644 --- a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/exception.py +++ b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/exception.py @@ -1,9 +1,9 @@ from typing import Optional -from nonebot.exception import (AdapterException, ActionFailed as - BaseActionFailed, NetworkError as - BaseNetworkError, ApiNotAvailable as - BaseApiNotAvailable) +from nonebot.exception import ActionFailed as BaseActionFailed +from nonebot.exception import AdapterException +from nonebot.exception import ApiNotAvailable as BaseApiNotAvailable +from nonebot.exception import NetworkError as BaseNetworkError class FeishuAdapterException(AdapterException): diff --git a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/message.py b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/message.py index efcea8b1..03f5a858 100644 --- a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/message.py +++ b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/message.py @@ -1,10 +1,11 @@ -import json import itertools - +import json from dataclasses import dataclass -from typing import Any, Dict, List, Optional, Tuple, Type, Union, Mapping, Iterable +from typing import (Any, Dict, Iterable, List, Mapping, Optional, Tuple, Type, + Union) -from nonebot.adapters import Message as BaseMessage, MessageSegment as BaseMessageSegment +from nonebot.adapters import Message as BaseMessage +from nonebot.adapters import MessageSegment as BaseMessageSegment from nonebot.typing import overrides diff --git a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/utils.py b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/utils.py index a04456a6..ba418356 100644 --- a/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/utils.py +++ b/packages/nonebot-adapter-feishu/nonebot/adapters/feishu/utils.py @@ -2,6 +2,7 @@ import base64 import hashlib from Crypto.Cipher import AES + from nonebot.utils import logger_wrapper log = logger_wrapper("FEISHU")