From fc60e5ad184bcdacc51f1f3a96fb22323036652a Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Mon, 10 Jun 2024 16:46:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=8Atypevar=E8=BF=99=E5=A0=86=E6=94=B9?= =?UTF-8?q?=E5=9B=9E=E5=8E=BB=EF=BC=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ica-rs/plugins/base.py | 12 ++++++++++-- ica-rs/plugins/namerena.py | 11 +++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ica-rs/plugins/base.py b/ica-rs/plugins/base.py index ef85ddb..952d456 100644 --- a/ica-rs/plugins/base.py +++ b/ica-rs/plugins/base.py @@ -1,5 +1,13 @@ -from ica_typing import IcaNewMessage, IcaClient -from ica_typing import TailchatReciveMessage, TailchatClient +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): diff --git a/ica-rs/plugins/namerena.py b/ica-rs/plugins/namerena.py index 9afa8d1..e34a1d2 100644 --- a/ica-rs/plugins/namerena.py +++ b/ica-rs/plugins/namerena.py @@ -4,9 +4,16 @@ import subprocess from pathlib import Path -from ica_typing import IcaNewMessage, IcaClient, ConfigData +from typing import TYPE_CHECKING, TypeVar -CONFIG_DATA: ConfigData +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"