Fix typehint for callback in UpdateMethods (#3119)

This commit is contained in:
alexkoay 2021-08-04 00:33:46 +08:00 committed by GitHub
parent e2d97b44c5
commit 196cef66fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,8 @@ if typing.TYPE_CHECKING:
from .telegramclient import TelegramClient from .telegramclient import TelegramClient
Callback = typing.Callable[[typing.Any], typing.Any]
class UpdateMethods: class UpdateMethods:
# region Public methods # region Public methods
@ -104,7 +106,7 @@ class UpdateMethods:
def add_event_handler( def add_event_handler(
self: 'TelegramClient', self: 'TelegramClient',
callback: callable, callback: Callback,
event: EventBuilder = None): event: EventBuilder = None):
""" """
Registers a new event handler callback. Registers a new event handler callback.
@ -153,7 +155,7 @@ class UpdateMethods:
def remove_event_handler( def remove_event_handler(
self: 'TelegramClient', self: 'TelegramClient',
callback: callable, callback: Callback,
event: EventBuilder = None) -> int: event: EventBuilder = None) -> int:
""" """
Inverse operation of `add_event_handler()`. Inverse operation of `add_event_handler()`.
@ -191,7 +193,7 @@ class UpdateMethods:
return found return found
def list_event_handlers(self: 'TelegramClient')\ def list_event_handlers(self: 'TelegramClient')\
-> 'typing.Sequence[typing.Tuple[callable, EventBuilder]]': -> 'typing.Sequence[typing.Tuple[Callback, EventBuilder]]':
""" """
Lists all registered event handlers. Lists all registered event handlers.