feat: add literal types for v3 and v4 versions

can be used as helpers for type unions
This commit is contained in:
NiceAesth 2024-02-23 13:46:17 +02:00
parent aaa16c029b
commit e400a5f396
1 changed files with 18 additions and 1 deletions

View File

@ -1,4 +1,6 @@
from typing import NamedTuple from typing import Literal, NamedTuple, Union
__all__ = ("LavalinkVersion",)
class LavalinkVersion(NamedTuple): class LavalinkVersion(NamedTuple):
@ -25,3 +27,18 @@ class LavalinkVersion(NamedTuple):
if self.fix > other.fix: if self.fix > other.fix:
return False return False
return True return True
class LavalinkVersion3Type(LavalinkVersion):
major: Literal[3]
minor: int
fix: int
class LavalinkVersion4Type(LavalinkVersion):
major: Literal[4]
minor: int
fix: int
LavalinkVersionType = Union[LavalinkVersion3Type, LavalinkVersion4Type, LavalinkVersion]