mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-20 09:56:05 -05:00
[V3 Downloader] Allow to specify minimum and maximum bot version in info.json (#2605)
* feat(downloader): add `min_bot_version` and `max_bot_version` Adds actually working way of specifying minimum and maximum bot version and removes not working `bot_version` BREAKING CHANGE: - removal of `bot_version` attribute in `Installable` * test(downloader): `Installable` tests fix for new bot version attributes * docs(changelog): added changelog entries for this PR
This commit is contained in:
@@ -119,8 +119,14 @@ class VersionInfo:
|
||||
"dev_release": self.dev_release,
|
||||
}
|
||||
|
||||
def __lt__(self, other: "VersionInfo") -> bool:
|
||||
tups: _List[_Tuple[int, int, int, int, int, int, int]] = []
|
||||
def _generate_comparison_tuples(
|
||||
self, other: "VersionInfo"
|
||||
) -> _List[
|
||||
_Tuple[int, int, int, int, _Union[int, float], _Union[int, float], _Union[int, float]]
|
||||
]:
|
||||
tups: _List[
|
||||
_Tuple[int, int, int, int, _Union[int, float], _Union[int, float], _Union[int, float]]
|
||||
] = []
|
||||
for obj in (self, other):
|
||||
tups.append(
|
||||
(
|
||||
@@ -133,8 +139,20 @@ class VersionInfo:
|
||||
obj.dev_release if obj.dev_release is not None else _inf,
|
||||
)
|
||||
)
|
||||
return tups
|
||||
|
||||
def __lt__(self, other: "VersionInfo") -> bool:
|
||||
tups = self._generate_comparison_tuples(other)
|
||||
return tups[0] < tups[1]
|
||||
|
||||
def __eq__(self, other: "VersionInfo") -> bool:
|
||||
tups = self._generate_comparison_tuples(other)
|
||||
return tups[0] == tups[1]
|
||||
|
||||
def __le__(self, other: "VersionInfo") -> bool:
|
||||
tups = self._generate_comparison_tuples(other)
|
||||
return tups[0] <= tups[1]
|
||||
|
||||
def __str__(self) -> str:
|
||||
ret = f"{self.major}.{self.minor}.{self.micro}"
|
||||
if self.releaselevel != self.FINAL:
|
||||
|
||||
Reference in New Issue
Block a user