2121from univers .utils import remove_spaces
2222from univers .version_constraint import VersionConstraint
2323from univers .version_constraint import contains_version
24+ from univers .versions import AllVersion
25+ from univers .versions import NoneVersion
2426
2527
2628class InvalidVersionRange (Exception ):
@@ -76,15 +78,15 @@ def from_native(cls, string):
7678 Return a VersionRange built from a scheme-specific, native version range
7779 ``string``. Subclasses can implement.
7880 """
79- return NotImplementedError
81+ raise NotImplementedError
8082
8183 @classmethod
8284 def from_natives (cls , strings ):
8385 """
8486 Return a VersionRange built from a ``strings`` list of scheme-
8587 specific native version range strings. Subclasses can implement.
8688 """
87- return NotImplementedError
89+ raise NotImplementedError
8890
8991 def to_native (self , * args , ** kwargs ):
9092 """
@@ -93,7 +95,7 @@ def to_native(self, *args, **kwargs):
9395 extra arguments (such as a package name that some scheme may require
9496 like for deb and rpm.)
9597 """
96- return NotImplementedError
98+ raise NotImplementedError
9799
98100 @classmethod
99101 def from_string (cls , vers , simplify = False , validate = False ):
@@ -174,7 +176,7 @@ def from_versions(cls, sequence):
174176 such as ["3.0.0", "1.0.1b", "3.0.2", "0.9.7a", "1.1.1ka"]
175177 """
176178 if not cls .scheme or not cls .version_class :
177- return NotImplementedError
179+ raise NotImplementedError
178180
179181 constraints = []
180182 for version in sequence :
@@ -220,6 +222,13 @@ def __contains__(self, version):
220222 object. A version is contained in a VersionRange if it satisfies its
221223 constraints according to ``vers`` rules.
222224 """
225+
226+ if self .version_class is AllVersion :
227+ return True
228+
229+ if self .version_class is NoneVersion :
230+ return False
231+
223232 if not isinstance (version , self .version_class ):
224233 raise TypeError (
225234 f"{ version !r} is not of expected type: { self .version_class !r} " ,
@@ -712,9 +721,9 @@ class PypiVersionRange(VersionRange):
712721 def from_native (cls , string ):
713722 """
714723 Return a VersionRange built from a PyPI PEP440 version specifiers ``string``.
715- Raise an a univers.versions.InvalidVersion
724+ Raise a univers.versions.InvalidVersion
716725 """
717- # TODO: environment markers are yet supported
726+ # TODO: environment markers are not yet supported
718727 # TODO: handle .* version, ~= and === operators
719728
720729 if ";" in string :
@@ -1182,6 +1191,16 @@ class MattermostVersionRange(VersionRange):
11821191 version_class = versions .SemverVersion
11831192
11841193
1194+ class AllVersionRange (VersionRange ):
1195+ scheme = "all"
1196+ version_class = versions .AllVersion
1197+
1198+
1199+ class NoneVersionRange (VersionRange ):
1200+ scheme = "none"
1201+ version_class = versions .NoneVersion
1202+
1203+
11851204def from_gitlab_native (gitlab_scheme , string ):
11861205 purl_scheme = gitlab_scheme
11871206 if gitlab_scheme not in PURL_TYPE_BY_GITLAB_SCHEME .values ():
@@ -1425,6 +1444,8 @@ def build_range_from_snyk_advisory_string(scheme: str, string: Union[str, List])
14251444 "mattermost" : MattermostVersionRange ,
14261445 "conan" : ConanVersionRange ,
14271446 "intdot" : IntdotVersionRange ,
1447+ "all" : AllVersionRange ,
1448+ "none" : NoneVersionRange ,
14281449}
14291450
14301451PURL_TYPE_BY_GITLAB_SCHEME = {
0 commit comments