Skip to content

Commit 4192b87

Browse files
authored
Merge branch 'main' into dependabot/github_actions/dot-github/workflows/actions/download-artifact-4.1.7
2 parents 968ee8b + 55b171c commit 4192b87

19 files changed

Lines changed: 335 additions & 94 deletions

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import re
2222
import sys
2323

24+
2425
sys.path.insert(0, os.path.abspath("."))
2526
sys.path.insert(0, os.path.abspath(".."))
2627
sys.path.append(os.path.abspath("extensions"))

docs/extensions/attributetable.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import importlib
44
import inspect
55
import re
6-
from typing import TYPE_CHECKING, Dict, List, NamedTuple, Optional, Sequence, Tuple
6+
from collections.abc import Sequence
7+
from typing import TYPE_CHECKING, NamedTuple
78

89
from docutils import nodes
910
from sphinx import addnodes
@@ -13,6 +14,7 @@
1314
from sphinx.util.docutils import SphinxDirective
1415
from sphinx.util.typing import OptionSpec
1516

17+
1618
if TYPE_CHECKING:
1719
from .builder import DPYHTML5Translator
1820

@@ -96,7 +98,7 @@ class PyAttributeTable(SphinxDirective):
9698
final_argument_whitespace = False
9799
option_spec: OptionSpec = {}
98100

99-
def parse_name(self, content: str) -> Tuple[str, str]:
101+
def parse_name(self, content: str) -> tuple[str, str]:
100102
match = _name_parser_regex.match(content)
101103
if match is None:
102104
raise RuntimeError(f"content {content} somehow doesn't match regex in {self.env.docname}.")
@@ -112,7 +114,7 @@ def parse_name(self, content: str) -> Tuple[str, str]:
112114

113115
return modulename, name
114116

115-
def run(self) -> List[attributetableplaceholder]:
117+
def run(self) -> list[attributetableplaceholder]:
116118
"""If you're curious on the HTML this is meant to generate:
117119
118120
<div class="py-attribute-table">
@@ -149,7 +151,7 @@ def run(self) -> List[attributetableplaceholder]:
149151
return [node]
150152

151153

152-
def build_lookup_table(env: BuildEnvironment) -> Dict[str, List[str]]:
154+
def build_lookup_table(env: BuildEnvironment) -> dict[str, list[str]]:
153155
# Given an environment, load up a lookup table of
154156
# full-class-name: objects
155157
result = {}
@@ -178,7 +180,7 @@ def build_lookup_table(env: BuildEnvironment) -> Dict[str, List[str]]:
178180
class TableElement(NamedTuple):
179181
fullname: str
180182
label: str
181-
badge: Optional[attributetablebadge]
183+
badge: attributetablebadge | None
182184

183185

184186
def process_attributetable(app: Sphinx, doctree: nodes.Node, fromdocname: str) -> None:
@@ -203,12 +205,12 @@ def process_attributetable(app: Sphinx, doctree: nodes.Node, fromdocname: str) -
203205

204206

205207
def get_class_results(
206-
lookup: Dict[str, List[str]], modulename: str, name: str, fullname: str
207-
) -> Dict[str, List[TableElement]]:
208+
lookup: dict[str, list[str]], modulename: str, name: str, fullname: str
209+
) -> dict[str, list[TableElement]]:
208210
module = importlib.import_module(modulename)
209211
cls = getattr(module, name)
210212

211-
groups: Dict[str, List[TableElement]] = {
213+
groups: dict[str, list[TableElement]] = {
212214
_("Attributes"): [],
213215
_("Methods"): [],
214216
}

docs/wavelink.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ An event listener in a cog.
3434
This event can be called many times throughout your bots lifetime, as it will be called when Wavelink successfully
3535
reconnects to your node in the event of a disconnect.
3636

37+
.. function:: on_wavelink_node_disconnected(payload: wavelink.NodeDisconnectedEventPayload)
38+
39+
Called when a Node has disconnected/lost connection to wavelink. **This is NOT** the same as a node being closed.
40+
This event will however be called directly before the :func:`on_wavelink_node_closed` event.
41+
42+
The default behaviour is for wavelink to attempt to reconnect a disconnected Node. This event can change that
43+
behaviour. If you want to close this node completely see: :meth:`Node.close`
44+
45+
This event can be used to manage currrently connected players to this Node.
46+
See: :meth:`Player.switch_node`
47+
48+
.. versionadded:: 3.5.0
49+
3750
.. function:: on_wavelink_stats_update(payload: wavelink.StatsEventPayload)
3851

3952
Called when the ``stats`` OP is received by Lavalink.
@@ -128,6 +141,11 @@ Types
128141
129142
tracks: wavelink.Search = await wavelink.Playable.search("Ocean Drive")
130143
144+
.. attributetable:: PlayerBasicState
145+
146+
.. autoclass:: PlayerBasicState
147+
148+
131149

132150
Payloads
133151
---------
@@ -136,6 +154,11 @@ Payloads
136154
.. autoclass:: NodeReadyEventPayload
137155
:members:
138156

157+
.. attributetable:: NodeDisconnectedEventPayload
158+
159+
.. autoclass:: NodeDisconnectedEventPayload
160+
:members:
161+
139162
.. attributetable:: TrackStartEventPayload
140163

141164
.. autoclass:: TrackStartEventPayload
@@ -442,6 +465,8 @@ Exceptions
442465
Exception raised when a :class:`Node` is tried to be retrieved from the
443466
:class:`Pool` without existing, or the ``Pool`` is empty.
444467

468+
This exception is also raised when providing an invalid node to :meth:`Player.switch_node`.
469+
445470
.. py:exception:: LavalinkException
446471
447472
Exception raised when Lavalink returns an invalid response.

examples/simple.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async def play(ctx: commands.Context, *, query: str) -> None:
8686
return
8787

8888
player: wavelink.Player
89-
player = cast(wavelink.Player, ctx.voice_client) # type: ignore
89+
player = cast("wavelink.Player", ctx.voice_client) # type: ignore
9090

9191
if not player:
9292
try:
@@ -143,7 +143,7 @@ async def play(ctx: commands.Context, *, query: str) -> None:
143143
@bot.command()
144144
async def skip(ctx: commands.Context) -> None:
145145
"""Skip the current song."""
146-
player: wavelink.Player = cast(wavelink.Player, ctx.voice_client)
146+
player: wavelink.Player = cast("wavelink.Player", ctx.voice_client)
147147
if not player:
148148
return
149149

@@ -154,7 +154,7 @@ async def skip(ctx: commands.Context) -> None:
154154
@bot.command()
155155
async def nightcore(ctx: commands.Context) -> None:
156156
"""Set the filter to a nightcore style."""
157-
player: wavelink.Player = cast(wavelink.Player, ctx.voice_client)
157+
player: wavelink.Player = cast("wavelink.Player", ctx.voice_client)
158158
if not player:
159159
return
160160

@@ -168,7 +168,7 @@ async def nightcore(ctx: commands.Context) -> None:
168168
@bot.command(name="toggle", aliases=["pause", "resume"])
169169
async def pause_resume(ctx: commands.Context) -> None:
170170
"""Pause or Resume the Player depending on its current state."""
171-
player: wavelink.Player = cast(wavelink.Player, ctx.voice_client)
171+
player: wavelink.Player = cast("wavelink.Player", ctx.voice_client)
172172
if not player:
173173
return
174174

@@ -179,7 +179,7 @@ async def pause_resume(ctx: commands.Context) -> None:
179179
@bot.command()
180180
async def volume(ctx: commands.Context, value: int) -> None:
181181
"""Change the volume of the player."""
182-
player: wavelink.Player = cast(wavelink.Player, ctx.voice_client)
182+
player: wavelink.Player = cast("wavelink.Player", ctx.voice_client)
183183
if not player:
184184
return
185185

@@ -190,7 +190,7 @@ async def volume(ctx: commands.Context, value: int) -> None:
190190
@bot.command(aliases=["dc"])
191191
async def disconnect(ctx: commands.Context) -> None:
192192
"""Disconnect the Player."""
193-
player: wavelink.Player = cast(wavelink.Player, ctx.voice_client)
193+
player: wavelink.Player = cast("wavelink.Player", ctx.voice_client)
194194
if not player:
195195
return
196196

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "wavelink"
7-
version = "3.4.1"
7+
version = "3.5.1"
8+
89
authors = [
910
{ name="PythonistaGuild, EvieePy", email="evieepy@gmail.com" },
1011
]
@@ -76,7 +77,8 @@ ignore = [
7677
"PTH123",
7778
"E203",
7879
"E501",
79-
"RUF006"
80+
"RUF006",
81+
"SIM910",
8082
]
8183

8284
[tool.ruff.lint.isort]
@@ -97,7 +99,7 @@ skip-magic-trailing-comma = false
9799
line-ending = "auto"
98100

99101
[tool.pyright]
100-
exclude = ["venv"]
102+
exclude = ["venv", "**/node_modules", "**/__pycache__", "**/.*", ".venv"]
101103
ignore = ["test*.py", "examples/*.py", "docs/*"]
102104
useLibraryCodeForTypes = true
103105
typeCheckingMode = "strict"

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
aiohttp>=3.7.4,<4
2-
discord.py>=2.0.1
2+
discord.py>=2.7.0
33
yarl>=1.9.2
44
async_timeout
55
typing_extensions

wavelink/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
__author__ = "PythonistaGuild, EvieePy"
2727
__license__ = "MIT"
2828
__copyright__ = "Copyright 2019-Present (c) PythonistaGuild, EvieePy"
29-
__version__ = "3.4.1"
30-
29+
__version__ = "3.5.1"
3130

3231
from .enums import *
3332
from .exceptions import *
@@ -38,4 +37,5 @@
3837
from .player import Player as Player
3938
from .queue import *
4039
from .tracks import *
40+
from .types.state import PlayerBasicState as PlayerBasicState
4141
from .utils import ExtrasNamespace as ExtrasNamespace

wavelink/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
def get_debug_info() -> None:
1717
python_info = "\n".join(sys.version.split("\n"))
1818
java_version = subprocess.check_output(["java", "-version"], stderr=subprocess.STDOUT)
19-
java_version = f'\n{" " * 8}- '.join(v for v in java_version.decode().split("\r\n") if v)
19+
java_version = f"\n{' ' * 8}- ".join(v for v in java_version.decode().split("\r\n") if v)
2020

2121
info: str = f"""
2222
wavelink: {wavelink.__version__}

wavelink/enums.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import enum
2626

2727

28-
__all__ = ("NodeStatus", "TrackSource", "DiscordVoiceCloseType", "AutoPlayMode", "QueueMode")
28+
__all__ = ("AutoPlayMode", "DiscordVoiceCloseType", "NodeStatus", "QueueMode", "TrackSource")
2929

3030

3131
class NodeStatus(enum.Enum):

wavelink/exceptions.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@
3232

3333

3434
__all__ = (
35-
"WavelinkException",
36-
"NodeException",
37-
"InvalidClientException",
3835
"AuthorizationFailedException",
36+
"ChannelTimeoutException",
37+
"InvalidChannelStateException",
38+
"InvalidClientException",
3939
"InvalidNodeException",
4040
"LavalinkException",
4141
"LavalinkLoadException",
42-
"InvalidChannelStateException",
43-
"ChannelTimeoutException",
42+
"NodeException",
4443
"QueueEmpty",
44+
"WavelinkException",
4545
)
4646

4747

@@ -82,6 +82,8 @@ class AuthorizationFailedException(WavelinkException):
8282
class InvalidNodeException(WavelinkException):
8383
"""Exception raised when a :class:`Node` is tried to be retrieved from the
8484
:class:`Pool` without existing, or the ``Pool`` is empty.
85+
86+
This exception is also raised when providing an invalid node to :meth:`~wavelink.Player.switch_node`.
8587
"""
8688

8789

0 commit comments

Comments
 (0)