From 4c96b70da5f34931207064a8e8a2522d3b71af8b Mon Sep 17 00:00:00 2001 From: Oliver Wilkes Date: Sat, 4 Feb 2023 21:24:47 +0000 Subject: [PATCH] fix(stats): framestats is actually ommitable freyacodes/lavalink#827 --- mafic/stats.py | 2 +- mafic/typings/common.py | 7 +++++-- mafic/warnings.py | 11 ++++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mafic/stats.py b/mafic/stats.py index 39baadd..7ff65c8 100644 --- a/mafic/stats.py +++ b/mafic/stats.py @@ -118,5 +118,5 @@ def __init__(self, data: Stats) -> None: self.memory: MemoryStats = MemoryStats(data["memory"]) self.cpu: CPUStats = CPUStats(data["cpu"]) self.frame_stats: FrameStats | None = ( - FrameStats(data["frameStats"]) if data["frameStats"] is not None else None + FrameStats(data["frameStats"]) if "frameStats" in data else None ) diff --git a/mafic/typings/common.py b/mafic/typings/common.py index 42807fe..1b73ba5 100644 --- a/mafic/typings/common.py +++ b/mafic/typings/common.py @@ -2,10 +2,13 @@ from __future__ import annotations -from typing import Literal, TypedDict +from typing import TYPE_CHECKING, Literal, TypedDict from .misc import PayloadWithGuild +if TYPE_CHECKING: + from typing_extensions import NotRequired + __all__ = ( "Filters", "ChannelMix", @@ -165,4 +168,4 @@ class Stats(TypedDict): uptime: int memory: Memory cpu: CPU - frameStats: FrameStats | None + frameStats: NotRequired[FrameStats] diff --git a/mafic/warnings.py b/mafic/warnings.py index ee0c3b1..44a7f5a 100644 --- a/mafic/warnings.py +++ b/mafic/warnings.py @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT -__all__ = ("UnsupportedVersionWarning",) +__all__ = ("UnsupportedVersionWarning", "UnknownVersionWarning") class UnsupportedVersionWarning(UserWarning): @@ -11,3 +11,12 @@ class UnsupportedVersionWarning(UserWarning): "The version of Lavalink you are using is not supported by Mafic. " "It should still work but not all features are supported." ) + + +class UnknownVersionWarning(UserWarning): + """Represents a warning for an unknown version of Lavalink.""" + + message: str = ( + "The version of Lavalink you are using is unknown to Mafic. " + "It should still work but not all features are supported." + )