mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-27 18:45:05 +08:00
🚨 remove linter warning
This commit is contained in:
parent
512d77de0d
commit
ecb9d6bc28
@ -2,12 +2,12 @@ import re
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from base64 import b64encode
|
||||
from typing import Type, Union, Tuple, Mapping, Iterable, Optional
|
||||
from typing import Any, Type, Tuple, Union, Mapping, Iterable, Optional, cast
|
||||
|
||||
from nonebot.typing import overrides
|
||||
from nonebot.adapters import Message as BaseMessage, MessageSegment as BaseMessageSegment
|
||||
|
||||
from .utils import log, escape, unescape, _b2s
|
||||
from .utils import log, _b2s, escape, unescape
|
||||
from nonebot.adapters import Message as BaseMessage
|
||||
from nonebot.adapters import MessageSegment as BaseMessageSegment
|
||||
|
||||
|
||||
class MessageSegment(BaseMessageSegment["Message"]):
|
||||
@ -258,6 +258,7 @@ class Message(BaseMessage[MessageSegment]):
|
||||
msg: Union[str, Mapping,
|
||||
Iterable[Mapping]]) -> Iterable[MessageSegment]:
|
||||
if isinstance(msg, Mapping):
|
||||
msg = cast(Mapping[str, Any], msg)
|
||||
yield MessageSegment(msg["type"], msg.get("data") or {})
|
||||
return
|
||||
elif isinstance(msg, Iterable) and not isinstance(msg, str):
|
||||
|
@ -1,8 +1,9 @@
|
||||
from copy import copy
|
||||
from typing import Any, Dict, Type, Union, Mapping, Iterable
|
||||
from typing import Any, Dict, Type, Union, Mapping, Iterable, cast
|
||||
|
||||
from nonebot.typing import overrides
|
||||
from nonebot.adapters import Message as BaseMessage, MessageSegment as BaseMessageSegment
|
||||
from nonebot.adapters import Message as BaseMessage
|
||||
from nonebot.adapters import MessageSegment as BaseMessageSegment
|
||||
|
||||
|
||||
class MessageSegment(BaseMessageSegment["Message"]):
|
||||
@ -173,6 +174,7 @@ class Message(BaseMessage[MessageSegment]):
|
||||
msg: Union[str, Mapping,
|
||||
Iterable[Mapping]]) -> Iterable[MessageSegment]:
|
||||
if isinstance(msg, Mapping):
|
||||
msg = cast(Mapping[str, Any], msg)
|
||||
yield MessageSegment(msg["type"], msg.get("data") or {})
|
||||
elif isinstance(msg, str):
|
||||
yield MessageSegment.text(msg)
|
||||
|
@ -1,21 +1,20 @@
|
||||
import re
|
||||
import json
|
||||
from typing import (TYPE_CHECKING, Any, Dict, Tuple, Union, Iterable, Optional,
|
||||
AsyncIterable)
|
||||
AsyncIterable, cast)
|
||||
|
||||
import httpx
|
||||
from aiocache import Cache, cached
|
||||
from aiocache.serializers import PickleSerializer
|
||||
|
||||
from nonebot.log import logger
|
||||
from .utils import AESCipher, log
|
||||
from nonebot.typing import overrides
|
||||
from nonebot.utils import escape_tag
|
||||
from nonebot.message import handle_event
|
||||
from .config import Config as FeishuConfig
|
||||
from nonebot.adapters import Bot as BaseBot
|
||||
from nonebot.drivers import Driver, HTTPRequest, HTTPResponse
|
||||
|
||||
from .utils import AESCipher, log
|
||||
from .config import Config as FeishuConfig
|
||||
from .message import Message, MessageSegment, MessageSerializer
|
||||
from .exception import ActionFailed, NetworkError, ApiNotAvailable
|
||||
from .event import (Event, MessageEvent, GroupMessageEvent, PrivateMessageEvent,
|
||||
@ -124,6 +123,7 @@ def _handle_api_result(
|
||||
- ``ActionFailed``: API 调用失败
|
||||
"""
|
||||
if isinstance(result, dict):
|
||||
result = cast(Dict[str, Any], result)
|
||||
if result.get("code") != 0:
|
||||
raise ActionFailed(**result)
|
||||
return result.get("data")
|
||||
|
@ -1,12 +1,12 @@
|
||||
import itertools
|
||||
import json
|
||||
import itertools
|
||||
from dataclasses import dataclass
|
||||
from typing import (Any, Dict, Iterable, List, Mapping, Optional, Tuple, Type,
|
||||
Union)
|
||||
from typing import (Any, Dict, List, Type, Tuple, Union, Mapping, Iterable,
|
||||
Optional, cast)
|
||||
|
||||
from nonebot.typing import overrides
|
||||
from nonebot.adapters import Message as BaseMessage
|
||||
from nonebot.adapters import MessageSegment as BaseMessageSegment
|
||||
from nonebot.typing import overrides
|
||||
|
||||
|
||||
class MessageSegment(BaseMessageSegment["Message"]):
|
||||
@ -150,6 +150,7 @@ class Message(BaseMessage[MessageSegment]):
|
||||
msg: Union[str, Mapping,
|
||||
Iterable[Mapping]]) -> Iterable[MessageSegment]:
|
||||
if isinstance(msg, Mapping):
|
||||
msg = cast(Mapping[str, Any], msg)
|
||||
yield MessageSegment(msg["type"], msg.get("data") or {})
|
||||
return
|
||||
elif isinstance(msg, str):
|
||||
|
Loading…
Reference in New Issue
Block a user