diff --git a/core/testcontainers/core/version.py b/core/testcontainers/core/version.py index cac51fc1..71e17ec3 100644 --- a/core/testcontainers/core/version.py +++ b/core/testcontainers/core/version.py @@ -4,27 +4,29 @@ class ComparableVersion: - def __init__(self, version): + """A wrapper around packaging.version.Version that allows for comparison with strings""" + + def __init__(self, version: str) -> None: self.version = Version(version) - def __lt__(self, other: str): + def __lt__(self, other: object) -> bool: return self._apply_op(other, lambda x, y: x < y) - def __le__(self, other: str): + def __le__(self, other: object) -> bool: return self._apply_op(other, lambda x, y: x <= y) - def __eq__(self, other: str): + def __eq__(self, other: object) -> bool: return self._apply_op(other, lambda x, y: x == y) - def __ne__(self, other: str): + def __ne__(self, other: object) -> bool: return self._apply_op(other, lambda x, y: x != y) - def __gt__(self, other: str): + def __gt__(self, other: object) -> bool: return self._apply_op(other, lambda x, y: x > y) - def __ge__(self, other: str): + def __ge__(self, other: object) -> bool: return self._apply_op(other, lambda x, y: x >= y) - def _apply_op(self, other: str, op: Callable[[Version, Version], bool]): - other = Version(other) + def _apply_op(self, other: object, op: Callable[[Version, Version], bool]) -> bool: + other = Version(str(other)) return op(self.version, other)