Skip to content

Commit

Permalink
Fix missing imports and general code smells.
Browse files Browse the repository at this point in the history
  • Loading branch information
devoxin committed Sep 18, 2024
1 parent f37dadd commit 64a538e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lavalink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__author__ = 'Devoxin'
__license__ = 'MIT'
__copyright__ = 'Copyright 2017-present Devoxin'
__version__ = '5.8.0'
__version__ = '5.8.1'


from typing import Type
Expand Down
13 changes: 7 additions & 6 deletions lavalink/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import logging
from abc import ABC, abstractmethod
from typing import (TYPE_CHECKING, Any, Dict, Generic, List, Optional, TypeVar,
Union)
Union, cast)

from .common import MISSING
from .errors import InvalidTrack, LoadError
from .events import Event, TrackLoadFailedEvent
from .server import AudioTrack
from .server import AudioTrack, RawPlayer

if TYPE_CHECKING:
from .client import Client
Expand Down Expand Up @@ -106,7 +106,7 @@ async def play_track(self,
no_replace: bool = MISSING,
volume: int = MISSING,
pause: bool = MISSING,
**kwargs) -> Optional[Dict[str, Any]]:
**kwargs) -> Optional[RawPlayer]:
"""|coro|
.. _player object: https://lavalink.dev/api/rest.html#Player
Expand Down Expand Up @@ -147,7 +147,7 @@ async def play_track(self,
Returns
-------
Optional[Dict[:class:`str`, Any]]
Optional[:class:`RawPlayer`]
The updated `player object`_, or ``None`` if a request wasn't made due to an empty payload.
"""
if track is MISSING or not isinstance(track, AudioTrack):
Expand Down Expand Up @@ -203,7 +203,8 @@ async def play_track(self,
return

self._next = track
return await self.node.update_player(guild_id=self._internal_id, encoded_track=playable_track, **options)
response = await self.node.update_player(guild_id=self._internal_id, encoded_track=playable_track, **options)
return cast(RawPlayer, response)

def cleanup(self):
pass
Expand Down Expand Up @@ -240,7 +241,7 @@ async def _voice_state_update(self, data):

async def _dispatch_voice_update(self):
if {'sessionId', 'endpoint', 'token'} == self._voice_state.keys():
await self.node.update_player(guild_id=self._internal_id, voice_state=self._voice_state)
await self.node.update_player(guild_id=self._internal_id, voice_state=self._voice_state) # type: ignore

@abstractmethod
async def node_unavailable(self):
Expand Down
3 changes: 2 additions & 1 deletion lavalink/playermanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ def create(self,
raise ClientError('No available nodes!')

id_int = int(guild_id)
self.players[id_int] = player = cls(id_int, best_node)
player = cls(id_int, best_node)
self.players[id_int] = player # type: ignore
_log.debug('Created player with GuildId %d on node \'%s\'', id_int, best_node.name)
return player

Expand Down
2 changes: 1 addition & 1 deletion lavalink/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"""
from enum import Enum as _Enum
from typing import (TYPE_CHECKING, Any, Dict, List, Literal, Optional, Type,
TypedDict, TypeVar, Union)
TypedDict, TypeVar, Union, cast)

from .errors import InvalidTrack

Expand Down

0 comments on commit 64a538e

Please sign in to comment.