From 1e9d25348fd8ec4c7ddf8f8c8754b40e5301462c Mon Sep 17 00:00:00 2001 From: "Kunz, Immanuel" Date: Fri, 15 Nov 2024 11:26:35 +0100 Subject: [PATCH] code style Signed-off-by: Kunz, Immanuel --- src/univers/version_range.py | 4 ++-- src/univers/versions.py | 2 +- tests/test_version_range.py | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/univers/version_range.py b/src/univers/version_range.py index 373ceaab..8f0194e8 100644 --- a/src/univers/version_range.py +++ b/src/univers/version_range.py @@ -225,10 +225,10 @@ def __contains__(self, version): if self.version_class is AllVersion: return True - + if self.version_class is NoneVersion: return False - + if not isinstance(version, self.version_class): raise TypeError( f"{version!r} is not of expected type: {self.version_class!r}", diff --git a/src/univers/versions.py b/src/univers/versions.py index f99594dd..c06f4ff0 100644 --- a/src/univers/versions.py +++ b/src/univers/versions.py @@ -137,7 +137,7 @@ class AllVersion(Version): @classmethod def is_valid(cls, string): return string == "vers:all/*" - + class NoneVersion(Version): @classmethod diff --git a/tests/test_version_range.py b/tests/test_version_range.py index 93c7403a..104646f8 100644 --- a/tests/test_version_range.py +++ b/tests/test_version_range.py @@ -548,6 +548,7 @@ def test_version_range_normalize_case3(): assert str(nvr) == "vers:pypi/>=1.0.0|<=1.3.0|3.0.0" + def test_version_range_all(): all_vers = VersionRange.from_string("vers:all/*") assert all_vers.contains(Version("1.2.3")) @@ -558,8 +559,9 @@ def test_version_range_all(): with pytest.raises(Exception): VersionRange.from_string("vers:all/*|>1.2.3") + def test_version_range_none(): - none_vers = VersionRange.from_string("vers:none/*") + none_vers = VersionRange.from_string("vers:none/*") assert not none_vers.contains(Version("1.2.3")) assert PypiVersion("2.0.3") not in none_vers # test for invalid all range specification