cleanup / type stuff
This commit is contained in:
parent
584f6e5286
commit
7b83a9fc69
|
|
@ -18,7 +18,6 @@ __author__ = "cloudwithax"
|
||||||
from .enums import SearchType
|
from .enums import SearchType
|
||||||
from .events import *
|
from .events import *
|
||||||
from .exceptions import *
|
from .exceptions import *
|
||||||
from .spotify import *
|
|
||||||
from .filters import *
|
from .filters import *
|
||||||
from .objects import *
|
from .objects import *
|
||||||
from .player import Player
|
from .player import Player
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import random
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
from typing import Dict, Optional, Type, TYPE_CHECKING
|
from typing import Dict, Optional, TYPE_CHECKING
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
@ -27,7 +27,7 @@ from .exceptions import (
|
||||||
TrackLoadError
|
TrackLoadError
|
||||||
)
|
)
|
||||||
from .objects import Playlist, Track
|
from .objects import Playlist, Track
|
||||||
from .utils import ExponentialBackoff, NodeStats
|
from .utils import ClientType, ExponentialBackoff, NodeStats
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .player import Player
|
from .player import Player
|
||||||
|
|
@ -54,7 +54,7 @@ class Node:
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
pool,
|
pool,
|
||||||
bot: Type[discord.Client],
|
bot: ClientType,
|
||||||
host: str,
|
host: str,
|
||||||
port: int,
|
port: int,
|
||||||
password: str,
|
password: str,
|
||||||
|
|
@ -88,7 +88,7 @@ class Node:
|
||||||
"Client-Name": f"Pomice/{__version__}"
|
"Client-Name": f"Pomice/{__version__}"
|
||||||
}
|
}
|
||||||
|
|
||||||
self._players = {}
|
self._players: Dict[int, Player] = {}
|
||||||
|
|
||||||
self._spotify_client_id = spotify_client_id
|
self._spotify_client_id = spotify_client_id
|
||||||
self._spotify_client_secret = spotify_client_secret
|
self._spotify_client_secret = spotify_client_secret
|
||||||
|
|
@ -132,7 +132,7 @@ class Node:
|
||||||
return self._players
|
return self._players
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def bot(self) -> Type[discord.Client]:
|
def bot(self) -> ClientType:
|
||||||
"""Property which returns the discord.py client linked to this node"""
|
"""Property which returns the discord.py client linked to this node"""
|
||||||
return self._bot
|
return self._bot
|
||||||
|
|
||||||
|
|
@ -486,7 +486,7 @@ class NodePool:
|
||||||
async def create_node(
|
async def create_node(
|
||||||
cls,
|
cls,
|
||||||
*,
|
*,
|
||||||
bot: Type[discord.Client],
|
bot: ClientType,
|
||||||
host: str,
|
host: str,
|
||||||
port: str,
|
port: str,
|
||||||
password: str,
|
password: str,
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,19 @@ DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
from discord import AutoShardedClient, Client
|
||||||
|
from discord.ext.commands import AutoShardedBot, Bot
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'ExponentialBackoff',
|
'ExponentialBackoff',
|
||||||
'PomiceStats'
|
'NodeStats',
|
||||||
|
'ClientType'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
ClientType = Union[AutoShardedBot, AutoShardedClient, Bot, Client]
|
||||||
|
|
||||||
|
|
||||||
class ExponentialBackoff:
|
class ExponentialBackoff:
|
||||||
|
|
||||||
|
|
@ -77,4 +84,4 @@ class NodeStats:
|
||||||
self.uptime = data.get('uptime')
|
self.uptime = data.get('uptime')
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
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}>'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue