mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2024-11-23 12:41:05 +08:00
remove some TYPE_CHECKING
This commit is contained in:
parent
86cb098b3d
commit
2340916570
|
@ -1,6 +1,6 @@
|
|||
# Python 兼容版本 3.8+
|
||||
|
||||
from typing import Callable, Tuple
|
||||
from typing import Callable, Tuple, NewType, TYPE_CHECKING, TypeVar
|
||||
|
||||
"""
|
||||
ica.rs
|
||||
|
@ -9,9 +9,9 @@ pub type UserId = i64;
|
|||
pub type MessageId = String;
|
||||
"""
|
||||
class IcaType:
|
||||
RoomId = int
|
||||
UserId = int
|
||||
MessageId = str
|
||||
RoomId = NewType('RoomId', int)
|
||||
UserId = NewType('UserId', int)
|
||||
MessageId = NewType('MessageId', str)
|
||||
|
||||
"""
|
||||
tailchat.rs
|
||||
|
@ -21,10 +21,12 @@ pub type UserId = String;
|
|||
pub type MessageId = String;
|
||||
"""
|
||||
class TailchatType:
|
||||
GroupId = str
|
||||
ConverseId = str
|
||||
UserId = str
|
||||
MessageId = str
|
||||
GroupId = NewType('GroupId', str)
|
||||
ConverseId = NewType('ConverseId', str)
|
||||
UserId = NewType('UserId', str)
|
||||
MessageId = NewType('MessageId', str)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
class IcaStatus:
|
||||
"""
|
||||
|
@ -264,6 +266,22 @@ class ConfigData:
|
|||
def have_key(self, key: str) -> bool:
|
||||
...
|
||||
|
||||
CONFIG_DATA: ConfigData = ConfigData()
|
||||
else:
|
||||
"""
|
||||
正常 Import 的时候使用的类型定义
|
||||
"""
|
||||
IcaStatus = TypeVar("IcaStatus")
|
||||
IcaReplyMessage = TypeVar("IcaReplyMessage")
|
||||
IcaNewMessage = TypeVar("IcaNewMessage")
|
||||
IcaSendMessage = TypeVar("IcaSendMessage")
|
||||
IcaDeleteMessage = TypeVar("IcaDeleteMessage")
|
||||
IcaClient = TypeVar("IcaClient")
|
||||
TailchatReciveMessage = TypeVar("TailchatReciveMessage")
|
||||
TailchatSendingMessage = TypeVar("TailchatSendingMessage")
|
||||
TailchatClient = TypeVar("TailchatClient")
|
||||
ConfigData = TypeVar("ConfigData")
|
||||
|
||||
|
||||
on_load = Callable[[IcaClient], None]
|
||||
# def on_load(client: IcaClient) -> None:
|
||||
|
@ -282,5 +300,3 @@ on_tailchat_message = Callable[[TailchatClient, TailchatReciveMessage], None]
|
|||
# ...
|
||||
|
||||
on_config = Callable[[None], Tuple[str, str]]
|
||||
|
||||
CONFIG_DATA: ConfigData = ConfigData()
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
from typing import TYPE_CHECKING, TypeVar
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ica_typing import IcaNewMessage, IcaClient
|
||||
from ica_typing import TailchatReciveMessage, TailchatClient
|
||||
else:
|
||||
IcaNewMessage = TypeVar("NewMessage")
|
||||
IcaClient = TypeVar("IcaClient")
|
||||
TailchatReciveMessage = TypeVar("TailchatReciveMessage")
|
||||
TailchatClient = TypeVar("TailchatClient")
|
||||
|
||||
def on_ica_message(msg: IcaNewMessage, client: IcaClient) -> None:
|
||||
if not (msg.is_from_self or msg.is_reply):
|
||||
|
|
|
@ -4,16 +4,9 @@ import subprocess
|
|||
|
||||
from pathlib import Path
|
||||
|
||||
from typing import TYPE_CHECKING, TypeVar
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ica_typing import IcaNewMessage, IcaClient, ConfigData
|
||||
|
||||
CONFIG_DATA: ConfigData
|
||||
else:
|
||||
CONFIG_DATA = None # type: ignore
|
||||
IcaNewMessage = TypeVar("NewMessage")
|
||||
IcaClient = TypeVar("IcaClient")
|
||||
|
||||
_version_ = "0.4.2"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user