Skip to content

Commit

Permalink
refactor(client): Change typings
Browse files Browse the repository at this point in the history
  • Loading branch information
Damego committed Feb 4, 2023
1 parent de956f7 commit 3237efa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions anilibria/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def _on_playlist_update(self, event: PlaylistUpdate):
"on_title_episode", TitleEpisode(title=title, episode=event.updated_episode)
)

def on(self, event: Type[BaseEvent]) -> Callable:
def on(self, event: BaseEvent):
"""
Декоратор для прослушивания событий. Принимает класс события.
Expand All @@ -88,10 +88,12 @@ async def name_you_want(event: PlaylistUpdate):
:param event: Класс ивента
"""
def wrapper(coro: Callable[..., Coroutine]):
def wrapper(coro: Callable[..., Coroutine]) -> Callable[..., Coroutine]:
event_name: str = "on_" + EventType(event).name.lower()
self._websocket.dispatch.register(event_name, coro)

return coro

return wrapper

def listen(self, coro: Callable[..., Coroutine] = MISSING, *, name: str = MISSING):
Expand Down

0 comments on commit 3237efa

Please sign in to comment.