cleanup / type stuff

This commit is contained in:
VP 2021-10-20 14:36:12 +03:00
parent 584f6e5286
commit 7b83a9fc69
3 changed files with 15 additions and 9 deletions

View File

@ -18,7 +18,6 @@ __author__ = "cloudwithax"
from .enums import SearchType
from .events import *
from .exceptions import *
from .spotify import *
from .filters import *
from .objects import *
from .player import Player

View File

@ -6,7 +6,7 @@ import random
import re
import socket
import time
from typing import Dict, Optional, Type, TYPE_CHECKING
from typing import Dict, Optional, TYPE_CHECKING
from urllib.parse import quote
import aiohttp
@ -27,7 +27,7 @@ from .exceptions import (
TrackLoadError
)
from .objects import Playlist, Track
from .utils import ExponentialBackoff, NodeStats
from .utils import ClientType, ExponentialBackoff, NodeStats
if TYPE_CHECKING:
from .player import Player
@ -54,7 +54,7 @@ class Node:
self,
*,
pool,
bot: Type[discord.Client],
bot: ClientType,
host: str,
port: int,
password: str,
@ -88,7 +88,7 @@ class Node:
"Client-Name": f"Pomice/{__version__}"
}
self._players = {}
self._players: Dict[int, Player] = {}
self._spotify_client_id = spotify_client_id
self._spotify_client_secret = spotify_client_secret
@ -132,7 +132,7 @@ class Node:
return self._players
@property
def bot(self) -> Type[discord.Client]:
def bot(self) -> ClientType:
"""Property which returns the discord.py client linked to this node"""
return self._bot
@ -486,7 +486,7 @@ class NodePool:
async def create_node(
cls,
*,
bot: Type[discord.Client],
bot: ClientType,
host: str,
port: str,
password: str,

View File

@ -20,12 +20,19 @@ DEALINGS IN THE SOFTWARE.
import random
import time
from typing import Union
from discord import AutoShardedClient, Client
from discord.ext.commands import AutoShardedBot, Bot
__all__ = [
'ExponentialBackoff',
'PomiceStats'
'NodeStats',
'ClientType'
]
ClientType = Union[AutoShardedBot, AutoShardedClient, Bot, Client]
class ExponentialBackoff:
@ -77,4 +84,4 @@ class NodeStats:
self.uptime = data.get('uptime')
def __repr__(self) -> str:
return f'<Pomice.NodeStats total_players={self.players_total} playing_active={self.players_active}>'
return f'<Pomice.NodeStats total_players={self.players_total!r} playing_active={self.players_active!r}>'