From 5d6b4e46ee4d2ed7720121215d95297b6cee87ab Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:37:32 +0000 Subject: [PATCH] style: auto fixes from pre-commit hooks --- docs/conf.py | 4 ++-- mafic/__libraries.py | 6 +++--- mafic/__main__.py | 1 + mafic/errors.py | 1 + mafic/events.py | 11 ++++++----- mafic/filter.py | 25 +++++++++++-------------- mafic/ip.py | 11 ++++++----- mafic/node.py | 11 ++++++----- mafic/player.py | 1 + mafic/playlist.py | 1 + mafic/plugin.py | 1 + mafic/pool.py | 1 + mafic/region.py | 1 + mafic/search_type.py | 1 + mafic/stats.py | 7 ++++--- mafic/strategy.py | 1 + mafic/track.py | 3 ++- mafic/type_variables.py | 1 + mafic/typings/common.py | 12 ++++++------ mafic/typings/http.py | 21 ++++++++++----------- mafic/typings/incoming.py | 2 +- mafic/typings/misc.py | 2 +- mafic/typings/outgoing.py | 2 +- mafic/utils/__init__.py | 1 + mafic/utils/classproperty.py | 1 + mafic/warnings.py | 3 ++- test_bot/bot/__main__.py | 2 +- 27 files changed, 74 insertions(+), 60 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 76443d6..32c8f04 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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" @@ -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 = { diff --git a/mafic/__libraries.py b/mafic/__libraries.py index 7bf8050..e3aa6fc 100644 --- a/mafic/__libraries.py +++ b/mafic/__libraries.py @@ -14,13 +14,13 @@ from .errors import MultipleCompatibleLibraries, NoCompatibleLibraries __all__ = ( + "MISSING", "Client", "Connectable", "ExponentialBackoff", "Guild", "GuildChannel", "GuildVoiceStatePayload", - "MISSING", "StageChannel", "VoiceChannel", "VoiceProtocol", @@ -120,8 +120,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 ) diff --git a/mafic/__main__.py b/mafic/__main__.py index 44f8c7e..bb03a14 100644 --- a/mafic/__main__.py +++ b/mafic/__main__.py @@ -1,4 +1,5 @@ """Mafic CLI tools.""" + # SPDX-License-Identifier: MIT from __future__ import annotations diff --git a/mafic/errors.py b/mafic/errors.py index 98e17a8..41c93f1 100644 --- a/mafic/errors.py +++ b/mafic/errors.py @@ -1,4 +1,5 @@ """Errors raised by Mafic.""" + # SPDX-License-Identifier: MIT from __future__ import annotations diff --git a/mafic/events.py b/mafic/events.py index 07f1bfd..d9bf39e 100644 --- a/mafic/events.py +++ b/mafic/events.py @@ -1,4 +1,5 @@ """Objects for dispatched events via the client.""" + # SPDX-License-Identifier: MIT # pyright: reportImportCycles=false # Player import. @@ -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 @@ -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 @@ -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 @@ -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, @@ -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 diff --git a/mafic/filter.py b/mafic/filter.py index 1fb9c3e..6c31c57 100644 --- a/mafic/filter.py +++ b/mafic/filter.py @@ -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 @@ -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, @@ -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 diff --git a/mafic/ip.py b/mafic/ip.py index 6234ebc..d2c9aeb 100644 --- a/mafic/ip.py +++ b/mafic/ip.py @@ -1,4 +1,5 @@ """The Lavalink route planner API.""" + # SPDX-License-Identifier: MIT from __future__ import annotations @@ -20,12 +21,12 @@ ) __all__ = ( - "IPRoutePlannerType", - "IPBlockType", - "IPBlock", - "FailingAddress", - "BaseIPRoutePlannerStatus", "BalancingIPRoutePlannerStatus", + "BaseIPRoutePlannerStatus", + "FailingAddress", + "IPBlock", + "IPBlockType", + "IPRoutePlannerType", "NanoIPRoutePlannerStatus", "RotatingIPRoutePlannerStatus", "RotatingNanoIPRoutePlannerStatus", diff --git a/mafic/node.py b/mafic/node.py index 9e6a81d..f479480 100644 --- a/mafic/node.py +++ b/mafic/node.py @@ -1,4 +1,5 @@ """Node class to represent one Lavalink instance.""" + # SPDX-License-Identifier: MIT # pyright: reportImportCycles=false # Player import. @@ -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", ) diff --git a/mafic/player.py b/mafic/player.py index 278ddd2..cfdfd88 100644 --- a/mafic/player.py +++ b/mafic/player.py @@ -1,4 +1,5 @@ """A Player is used to connect to a channel.""" + # SPDX-License-Identifier: MIT from __future__ import annotations diff --git a/mafic/playlist.py b/mafic/playlist.py index 457e4fe..92c3fff 100644 --- a/mafic/playlist.py +++ b/mafic/playlist.py @@ -1,4 +1,5 @@ """The module containing :class:`Playlist`.""" + # SPDX-License-Identifier: MIT from __future__ import annotations diff --git a/mafic/plugin.py b/mafic/plugin.py index 69bc5ea..5a4f0a4 100644 --- a/mafic/plugin.py +++ b/mafic/plugin.py @@ -1,4 +1,5 @@ """The Lavalink plugin system.""" + # SPDX-License-Identifier: MIT from __future__ import annotations diff --git a/mafic/pool.py b/mafic/pool.py index a199b06..28a89ae 100644 --- a/mafic/pool.py +++ b/mafic/pool.py @@ -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 diff --git a/mafic/region.py b/mafic/region.py index 7fa8800..7b3be89 100644 --- a/mafic/region.py +++ b/mafic/region.py @@ -1,4 +1,5 @@ """A module contains region enums for voice regions and groups.""" + # SPDX-License-Identifier: MIT from __future__ import annotations diff --git a/mafic/search_type.py b/mafic/search_type.py index 7c00086..f620887 100644 --- a/mafic/search_type.py +++ b/mafic/search_type.py @@ -1,4 +1,5 @@ """Represents a search type for Lavalink.""" + # SPDX-License-Identifier: MIT from __future__ import annotations diff --git a/mafic/stats.py b/mafic/stats.py index 1714c55..267b6b5 100644 --- a/mafic/stats.py +++ b/mafic/stats.py @@ -1,4 +1,5 @@ """A module containing classes to represent node statistics.""" + # SPDX-License-Identifier: MIT from __future__ import annotations @@ -31,7 +32,7 @@ class CPUStats: The load Lavalink is using. """ - __slots__ = ("cores", "system_load", "lavalink_load") + __slots__ = ("cores", "lavalink_load", "system_load") def __init__(self, payload: CPU) -> None: self.cores: int = payload["cores"] @@ -54,7 +55,7 @@ class MemoryStats: The amount of reservable memory for the node. Set by ``-Xmx`` for Java. """ - __slots__ = ("free", "used", "allocated", "reservable") + __slots__ = ("allocated", "free", "reservable", "used") def __init__(self, payload: Memory) -> None: self.free: int = payload["free"] @@ -76,7 +77,7 @@ class FrameStats: The amount of frames deficit. """ - __slots__ = ("sent", "nulled", "deficit") + __slots__ = ("deficit", "nulled", "sent") def __init__(self, payload: FrameStatsPayload) -> None: self.sent: int = payload["sent"] diff --git a/mafic/strategy.py b/mafic/strategy.py index 2436591..a3c917c 100644 --- a/mafic/strategy.py +++ b/mafic/strategy.py @@ -1,4 +1,5 @@ """The strategy system for selecting a :class:`Node` from a :class:`NodePool`.""" + # SPDX-License-Identifier: MIT from __future__ import annotations diff --git a/mafic/track.py b/mafic/track.py index c08b672..19a6e8a 100644 --- a/mafic/track.py +++ b/mafic/track.py @@ -1,4 +1,5 @@ """The module containing :class:`Track`.""" + # SPDX-License-Identifier: MIT from __future__ import annotations @@ -72,8 +73,8 @@ class Track: """ __slots__ = ( - "author", "artwork_url", + "author", "id", "identifier", "isrc", diff --git a/mafic/type_variables.py b/mafic/type_variables.py index b68e11e..78b40c4 100644 --- a/mafic/type_variables.py +++ b/mafic/type_variables.py @@ -1,4 +1,5 @@ """Type variables used in mafic.""" + # SPDX-License-Identifier: MIT # This was originally made to avoid the import cycle of # mafic.pool -> mafic.node -> mafic.pool diff --git a/mafic/typings/common.py b/mafic/typings/common.py index 5473d49..722bdb1 100644 --- a/mafic/typings/common.py +++ b/mafic/typings/common.py @@ -10,16 +10,20 @@ from typing_extensions import NotRequired __all__ = ( - "Filters", + "CPU", "ChannelMix", - "EQBand", "Distortion", + "EQBand", + "Filters", "Filters", + "FrameStats", "Karaoke", "LowPass", + "Memory", "Player", "PlaylistInfo", "Rotation", + "Stats", "Timescale", "TrackInfo", "TrackWithInfo", @@ -27,10 +31,6 @@ "Vibrato", "VoiceState", "VoiceStateRequest", - "Memory", - "CPU", - "FrameStats", - "Stats", ) diff --git a/mafic/typings/http.py b/mafic/typings/http.py index fe2e074..8c9e12a 100644 --- a/mafic/typings/http.py +++ b/mafic/typings/http.py @@ -16,36 +16,36 @@ __all__ = ( "BalancingIPRouteDetails", "BalancingIPRoutePlanner", + "BalancingIPRoutePlanner", "BaseDetails", "ConfigureResumingResponse", - "FailingIPAddress", + "EmptyRoutePlanner", "EmptyRoutePlanner", "Error", + "FailingIPAddress", "GenericTracks", "Git", + "Git", "IPBlock", "Info", + "Info", "NanoIPRouteDetails", "NanoIPRoutePlanner", + "NanoIPRoutePlanner", "NoMatches", "PlaylistTracks", "PluginData", "RotatingIPRouteDetails", "RotatingIPRoutePlanner", + "RotatingIPRoutePlanner", "RotatingNanoIPRouteDetails", "RotatingNanoIPRoutePlanner", + "RotatingNanoIPRoutePlanner", + "RoutePlannerStatus", "RoutePlannerStatus", "TrackLoadingResult", "TracksFailed", "Version", - "Git", - "Info", - "RotatingIPRoutePlanner", - "NanoIPRoutePlanner", - "RotatingNanoIPRoutePlanner", - "BalancingIPRoutePlanner", - "EmptyRoutePlanner", - "RoutePlannerStatus", ) @@ -182,8 +182,7 @@ class RotatingNanoIPRouteDetails(BaseDetails): ) -class BalancingIPRouteDetails(BaseDetails): - ... +class BalancingIPRouteDetails(BaseDetails): ... BalancingIPRoutePlanner = TypedDict( diff --git a/mafic/typings/incoming.py b/mafic/typings/incoming.py index 18bf5aa..5cfa2e2 100644 --- a/mafic/typings/incoming.py +++ b/mafic/typings/incoming.py @@ -16,9 +16,9 @@ __all__ = ( "EventPayload", + "IncomingMessage", "PlayerUpdatePayload", "PlayerUpdateState", - "IncomingMessage", "TrackEndEvent", "TrackExceptionEvent", "TrackStartEvent", diff --git a/mafic/typings/misc.py b/mafic/typings/misc.py index e47c0d4..cfc1539 100644 --- a/mafic/typings/misc.py +++ b/mafic/typings/misc.py @@ -7,8 +7,8 @@ __all__ = ( "Coro", - "LavalinkException", "ExceptionSeverity", + "LavalinkException", "PayloadWithGuild", ) T = TypeVar("T") diff --git a/mafic/typings/outgoing.py b/mafic/typings/outgoing.py index b05319c..902853b 100644 --- a/mafic/typings/outgoing.py +++ b/mafic/typings/outgoing.py @@ -13,8 +13,8 @@ "OutgoingParams", "TrackLoadParams", "UnmarkAddressPayload", - "UpdatePlayerPayload", "UpdatePlayerParams", + "UpdatePlayerPayload", "UpdateSessionPayload", ) diff --git a/mafic/utils/__init__.py b/mafic/utils/__init__.py index c3c97bb..c12adf6 100644 --- a/mafic/utils/__init__.py +++ b/mafic/utils/__init__.py @@ -1,4 +1,5 @@ """Utilities for both Mafic users and internal uses.""" + # SPDX-License-Identifier: MIT from .classproperty import * diff --git a/mafic/utils/classproperty.py b/mafic/utils/classproperty.py index 309c747..6fcc9e4 100644 --- a/mafic/utils/classproperty.py +++ b/mafic/utils/classproperty.py @@ -1,4 +1,5 @@ """Contains a decorator to merge properties and classmethods.""" + # SPDX-License-Identifier: MIT from __future__ import annotations diff --git a/mafic/warnings.py b/mafic/warnings.py index a7d574b..cf49b8a 100644 --- a/mafic/warnings.py +++ b/mafic/warnings.py @@ -1,8 +1,9 @@ """Contains the warnings shown from Mafic.""" + # SPDX-License-Identifier: MIT -__all__ = ("UnsupportedVersionWarning", "UnknownVersionWarning") +__all__ = ("UnknownVersionWarning", "UnsupportedVersionWarning") class UnsupportedVersionWarning(UserWarning): diff --git a/test_bot/bot/__main__.py b/test_bot/bot/__main__.py index c3a98e2..8e348c0 100644 --- a/test_bot/bot/__main__.py +++ b/test_bot/bot/__main__.py @@ -75,7 +75,7 @@ async def before_identify_hook( # gateway-proxy return - async def add_nodes(self) -> None: # noqa: PLR0912 + async def add_nodes(self) -> None: with open(environ["LAVALINK_FILE"], "rb") as f: data: list[LavalinkInfo] = orjson.loads(f.read())