Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ ci:
autofix_commit_msg: |
style: auto fixes from pre-commit hooks
repos:
- repo: https://github.com/psf/black
rev: 23.12.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.5.1
hooks:
- id: black
name: Running black in all files.

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.8
rev: v0.15.17
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
name: Running ruff in all files.

- repo: https://github.com/ariebovenberg/slotscheck
rev: v0.17.1
rev: v0.20.0
hooks:
- id: slotscheck
name: Running slotscheck in all files.
exclude: "^(?!mafic/)"
additional_dependencies: [nextcord, aiohttp]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v6.0.0
hooks:
- id: check-ast
name: Check if python files are valid syntax for the ast parser
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath(".."))
sys.path.append(os.path.abspath("extensions"))
from mafic import __version__ # noqa: E402
from mafic import __version__

project = "Mafic"
copyright = "2022-present, Oliver Wilkes"
Expand Down Expand Up @@ -91,7 +91,7 @@


def typehints_formatter(annotation: Any, _: Config) -> str | None: # noqa: ANN401
return aliases.get(annotation, None)
return aliases.get(annotation)


intersphinx_mapping = {
Expand Down
6 changes: 3 additions & 3 deletions mafic/__libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from .errors import MultipleCompatibleLibraries, NoCompatibleLibraries

__all__ = (
"MISSING",
"Client",
"Connectable",
"ExponentialBackoff",
"Guild",
"GuildChannel",
"GuildVoiceStatePayload",
"MISSING",
"StageChannel",
"VoiceChannel",
"VoiceProtocol",
Expand Down Expand Up @@ -138,8 +138,8 @@

if TYPE_CHECKING:
from discord.types.voice import (
GuildVoiceState as GuildVoiceStatePayload, # noqa: TCH004
VoiceServerUpdate as VoiceServerUpdatePayload, # noqa: TCH004
GuildVoiceState as GuildVoiceStatePayload, # noqa: TC004
VoiceServerUpdate as VoiceServerUpdatePayload, # noqa: TC004
)


Expand Down
1 change: 1 addition & 0 deletions mafic/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Mafic CLI tools."""

# SPDX-License-Identifier: MIT

from __future__ import annotations
Expand Down
1 change: 1 addition & 0 deletions mafic/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Errors raised by Mafic."""

# SPDX-License-Identifier: MIT

from __future__ import annotations
Expand Down
11 changes: 6 additions & 5 deletions mafic/events.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Objects for dispatched events via the client."""

# SPDX-License-Identifier: MIT
# pyright: reportImportCycles=false
# Player import.
Expand Down Expand Up @@ -71,7 +72,7 @@ class WebSocketClosedEvent(Generic[PlayerT]):
The player that the event was dispatched from.
"""

__slots__ = ("code", "reason", "by_discord", "player")
__slots__ = ("by_discord", "code", "player", "reason")

def __init__(
self, *, payload: WebSocketClosedEventPayload, player: PlayerT
Expand Down Expand Up @@ -100,7 +101,7 @@ class TrackStartEvent(Generic[PlayerT]):
The player that the event was dispatched from.
"""

__slots__ = ("track", "player")
__slots__ = ("player", "track")

def __init__(self, *, track: Track, player: PlayerT) -> None:
self.track: Track = track
Expand All @@ -124,7 +125,7 @@ class TrackEndEvent(Generic[PlayerT]):
The player that the event was dispatched from.
"""

__slots__ = ("track", "reason", "player")
__slots__ = ("player", "reason", "track")

def __init__(
self, *, track: Track, payload: TrackEndEventPayload, player: PlayerT
Expand Down Expand Up @@ -157,7 +158,7 @@ class TrackExceptionEvent(Generic[PlayerT]):
The player that the event was dispatched from.
"""

__slots__ = ("track", "exception", "player")
__slots__ = ("exception", "player", "track")

def __init__(
self,
Expand Down Expand Up @@ -190,7 +191,7 @@ class TrackStuckEvent(Generic[PlayerT]):
The player that the event was dispatched from.
"""

__slots__ = ("track", "threshold_ms", "player")
__slots__ = ("player", "threshold_ms", "track")

def __init__(
self, *, track: Track, payload: TrackStuckEventPayload, player: PlayerT
Expand Down
25 changes: 11 additions & 14 deletions mafic/filter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Filters that can be applied to a Player."""

# SPDX-License-Identifier: MIT
# Reference to filter meanings can be found in:
# https://github.com/natanbc/lavadsp
Expand Down Expand Up @@ -601,26 +602,24 @@ class Filter:
"""

__slots__ = (
"channel_mix",
"distortion",
"equalizer",
"karaoke",
"low_pass",
"rotation",
"timescale",
"tremolo",
"vibrato",
"rotation",
"distortion",
"channel_mix",
"low_pass",
"volume",
)

def __init__(
self,
*,
equalizer: Equalizer
| list[tuple[int, float]]
| list[float]
| list[EQBand]
| None = None,
equalizer: (
Equalizer | list[tuple[int, float]] | list[float] | list[EQBand] | None
) = None,
karaoke: Karaoke | None = None,
timescale: Timescale | None = None,
tremolo: Tremolo | None = None,
Expand All @@ -644,11 +643,9 @@ def __init__(

def _convert_equalizer(
self,
equalizer: Equalizer
| list[tuple[int, float]]
| list[float]
| list[EQBand]
| None,
equalizer: (
Equalizer | list[tuple[int, float]] | list[float] | list[EQBand] | None
),
) -> Equalizer | None:
if equalizer is None:
return None
Expand Down
11 changes: 6 additions & 5 deletions mafic/ip.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The Lavalink route planner API."""

# SPDX-License-Identifier: MIT

from __future__ import annotations
Expand All @@ -20,12 +21,12 @@
)

__all__ = (
"IPRoutePlannerType",
"IPBlockType",
"IPBlock",
"FailingAddress",
"BaseIPRoutePlannerStatus",
"BalancingIPRoutePlannerStatus",
"BaseIPRoutePlannerStatus",
"FailingAddress",
"IPBlock",
"IPBlockType",
"IPRoutePlannerType",
"NanoIPRoutePlannerStatus",
"RotatingIPRoutePlannerStatus",
"RotatingNanoIPRoutePlannerStatus",
Expand Down
21 changes: 11 additions & 10 deletions mafic/node.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Node class to represent one Lavalink instance."""

# SPDX-License-Identifier: MIT
# pyright: reportImportCycles=false
# Player import.
Expand Down Expand Up @@ -178,25 +179,25 @@ class Node(Generic[ClientT]):
"_checked_version",
"_client",
"_connect_task",
"_event_queue",
"_heartbeat",
"_host",
"_label",
"_msg_tasks",
"_players",
"_port",
"_resume_key",
"_secure",
"_timeout",
"_ready",
"_rest_uri",
"_resume_key",
"_resuming_session_id",
"_secure",
"_session_id",
"_stats",
"_timeout",
"_version",
"_ws",
"_ws_uri",
"_ws_task",
"_event_queue",
"_ws_uri",
"regions",
"shard_ids",
)
Expand Down Expand Up @@ -858,7 +859,7 @@ async def _handle_msg(self, data: IncomingMessage) -> None:
self._ready.set()
else:
# Of course pyright considers this to be `Never`, so this is to keep types.
op = cast(str, data["op"])
op = cast("str", data["op"])
_log.warn("Unknown incoming message op code %s", op)

async def _handle_event(self, data: EventPayload) -> None:
Expand Down Expand Up @@ -1272,17 +1273,17 @@ async def fetch_route_planner_status(self) -> RoutePlannerStatus | None:

if data["class"] == "RotatingIpRoutePlanner":
return RotatingIPRoutePlannerStatus(
cast(RotatingIPRouteDetails, data["details"])
cast("RotatingIPRouteDetails", data["details"])
)
elif data["class"] == "NanoIpRoutePlanner":
return NanoIPRoutePlannerStatus(cast(NanoIPRouteDetails, data["details"]))
return NanoIPRoutePlannerStatus(cast("NanoIPRouteDetails", data["details"]))
elif data["class"] == "RotatingNanoIpRoutePlanner":
return RotatingNanoIPRoutePlannerStatus(
cast(RotatingNanoIPRouteDetails, data["details"])
cast("RotatingNanoIPRouteDetails", data["details"])
)
elif data["class"] == "BalancingIpRoutePlanner":
return BalancingIPRoutePlannerStatus(
cast(BalancingIPRouteDetails, data["details"])
cast("BalancingIPRouteDetails", data["details"])
)
elif data["class"] is None:
return None
Expand Down
11 changes: 6 additions & 5 deletions mafic/player.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A Player is used to connect to a channel."""

# SPDX-License-Identifier: MIT

from __future__ import annotations
Expand Down Expand Up @@ -260,7 +261,7 @@ def dispatch_event(self, data: EventPayload) -> None:
track = (
self._current
if self.node.version == 3
else Track.from_data_with_info(cast(TrackWithInfo, data.get("track")))
else Track.from_data_with_info(cast("TrackWithInfo", data.get("track")))
)

if track is None:
Expand All @@ -277,7 +278,7 @@ def dispatch_event(self, data: EventPayload) -> None:
track = (
self._last_track
if self.node.version == 3
else Track.from_data_with_info(cast(TrackWithInfo, data.get("track")))
else Track.from_data_with_info(cast("TrackWithInfo", data.get("track")))
)

if track is None:
Expand All @@ -296,7 +297,7 @@ def dispatch_event(self, data: EventPayload) -> None:
track = (
self._current
if self.node.version == 3
else Track.from_data_with_info(cast(TrackWithInfo, data.get("track")))
else Track.from_data_with_info(cast("TrackWithInfo", data.get("track")))
)

if track is None:
Expand All @@ -313,7 +314,7 @@ def dispatch_event(self, data: EventPayload) -> None:
track = (
self._current
if self.node.version == 3
else Track.from_data_with_info(cast(TrackWithInfo, data.get("track")))
else Track.from_data_with_info(cast("TrackWithInfo", data.get("track")))
)

if track is None:
Expand All @@ -329,7 +330,7 @@ def dispatch_event(self, data: EventPayload) -> None:
# Pyright expects this to never happen, so do I, I really hope.
# Nobody expects the Spanish Inquisition, neither does pyright.

event_type = cast(str, data["type"])
event_type = cast("str", data["type"])
_log.warning("Unknown incoming event type %s", event_type)

async def on_voice_state_update( # pyright: ignore[reportIncompatibleMethodOverride]
Expand Down
1 change: 1 addition & 0 deletions mafic/playlist.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The module containing :class:`Playlist`."""

# SPDX-License-Identifier: MIT

from __future__ import annotations
Expand Down
1 change: 1 addition & 0 deletions mafic/plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The Lavalink plugin system."""

# SPDX-License-Identifier: MIT

from __future__ import annotations
Expand Down
1 change: 1 addition & 0 deletions mafic/pool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
r"""A module containing a :class:`NodePool`, used to manage :class:`Node`\s."""

# SPDX-License-Identifier: MIT

from __future__ import annotations
Expand Down
1 change: 1 addition & 0 deletions mafic/region.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module contains region enums for voice regions and groups."""

# SPDX-License-Identifier: MIT

from __future__ import annotations
Expand Down
1 change: 1 addition & 0 deletions mafic/search_type.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Represents a search type for Lavalink."""

# SPDX-License-Identifier: MIT

from __future__ import annotations
Expand Down
Loading
Loading