🐛 Fix handler type hint in python-telegram-bot v21.6

This commit is contained in:
xtaodada 2024-09-27 22:36:19 +08:00
parent e060fcac75
commit 7129322f6d
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
3 changed files with 7 additions and 6 deletions

View File

@ -18,10 +18,10 @@ UT = TypeVar("UT")
CCT = TypeVar("CCT", bound="CallbackContext[Any, Any, Any, Any]") CCT = TypeVar("CCT", bound="CallbackContext[Any, Any, Any, Any]")
class AdminHandler(BaseHandler[Update, CCT]): class AdminHandler(BaseHandler[Update, CCT, RT]):
_lock = asyncio.Lock() _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.handler = handler
self.application = application self.application = application
self.user_service: Optional["UserAdminService"] = None self.user_service: Optional["UserAdminService"] = None

View File

@ -17,11 +17,12 @@ if TYPE_CHECKING:
from telegram import Bot from telegram import Bot
from gram_core.application import Application from gram_core.application import Application
RT = TypeVar("RT")
UT = TypeVar("UT") UT = TypeVar("UT")
CCT = TypeVar("CCT", bound="CallbackContext[Any, Any, Any, Any]") 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()
__lock = asyncio.Lock() __lock = asyncio.Lock()
@ -101,7 +102,7 @@ class GroupHandler(BaseHandler[UT, CCT]):
await group_service.remove_update(chat.id) await group_service.remove_update(chat.id)
raise e 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: if update.inline_query is not None:
return return
if update.effective_chat: if update.effective_chat:

View File

@ -21,11 +21,11 @@ T_PreprocessorsFunc = Callable[
] ]
class HookHandler(BaseHandler[Update, CCT]): class HookHandler(BaseHandler[Update, CCT, RT]):
def __init__( def __init__(
self, self,
handler: BaseHandler[Update, CCT], handler: BaseHandler[Update, CCT, RT],
handler_data: Union["HandlerData", "ConversationData"], handler_data: Union["HandlerData", "ConversationData"],
application: "Application", application: "Application",
) -> None: ) -> None: