From 7129322f6dd9ae82880807a0a5a8579a5f150369 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Fri, 27 Sep 2024 22:36:19 +0800 Subject: [PATCH] :bug: Fix handler type hint in python-telegram-bot v21.6 --- handler/adminhandler.py | 4 ++-- handler/grouphandler.py | 5 +++-- handler/hookhandler.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/handler/adminhandler.py b/handler/adminhandler.py index e8c7096..5494595 100644 --- a/handler/adminhandler.py +++ b/handler/adminhandler.py @@ -18,10 +18,10 @@ UT = TypeVar("UT") CCT = TypeVar("CCT", bound="CallbackContext[Any, Any, Any, Any]") -class AdminHandler(BaseHandler[Update, CCT]): +class AdminHandler(BaseHandler[Update, CCT, RT]): _lock = asyncio.Lock() - def __init__(self, handler: BaseHandler[Update, CCT], application: "Application") -> None: + def __init__(self, handler: BaseHandler[Update, CCT, RT], application: "Application") -> None: self.handler = handler self.application = application self.user_service: Optional["UserAdminService"] = None diff --git a/handler/grouphandler.py b/handler/grouphandler.py index 789b9c0..9a9fac7 100644 --- a/handler/grouphandler.py +++ b/handler/grouphandler.py @@ -17,11 +17,12 @@ if TYPE_CHECKING: from telegram import Bot from gram_core.application import Application +RT = TypeVar("RT") UT = TypeVar("UT") CCT = TypeVar("CCT", bound="CallbackContext[Any, Any, Any, Any]") -class GroupHandler(BaseHandler[UT, CCT]): +class GroupHandler(BaseHandler[UT, CCT, RT]): _lock = asyncio.Lock() __lock = asyncio.Lock() @@ -101,7 +102,7 @@ class GroupHandler(BaseHandler[UT, CCT]): await group_service.remove_update(chat.id) raise e - async def message_check_callback(self, update: Update, _: ContextTypes.DEFAULT_TYPE): + async def message_check_callback(self, update: Update, _: ContextTypes.DEFAULT_TYPE) -> RT: if update.inline_query is not None: return if update.effective_chat: diff --git a/handler/hookhandler.py b/handler/hookhandler.py index 9a9e1b5..5a01c7e 100644 --- a/handler/hookhandler.py +++ b/handler/hookhandler.py @@ -21,11 +21,11 @@ T_PreprocessorsFunc = Callable[ ] -class HookHandler(BaseHandler[Update, CCT]): +class HookHandler(BaseHandler[Update, CCT, RT]): def __init__( self, - handler: BaseHandler[Update, CCT], + handler: BaseHandler[Update, CCT, RT], handler_data: Union["HandlerData", "ConversationData"], application: "Application", ) -> None: