|
19 | 19 | from univers import versions
|
20 | 20 | from univers.conan.version_range import VersionRange as conan_version_range
|
21 | 21 | from univers.utils import remove_spaces
|
| 22 | +from univers.versions import AllVersion |
| 23 | +from univers.versions import NoneVersion |
22 | 24 | from univers.version_constraint import VersionConstraint
|
23 | 25 | from univers.version_constraint import contains_version
|
24 | 26 |
|
@@ -220,6 +222,13 @@ def __contains__(self, version):
|
220 | 222 | object. A version is contained in a VersionRange if it satisfies its
|
221 | 223 | constraints according to ``vers`` rules.
|
222 | 224 | """
|
| 225 | + |
| 226 | + if self.version_class is AllVersion: |
| 227 | + return True |
| 228 | + |
| 229 | + if self.version_class is NoneVersion: |
| 230 | + return False |
| 231 | + |
223 | 232 | if not isinstance(version, self.version_class):
|
224 | 233 | raise TypeError(
|
225 | 234 | f"{version!r} is not of expected type: {self.version_class!r}",
|
@@ -712,9 +721,9 @@ class PypiVersionRange(VersionRange):
|
712 | 721 | def from_native(cls, string):
|
713 | 722 | """
|
714 | 723 | Return a VersionRange built from a PyPI PEP440 version specifiers ``string``.
|
715 |
| - Raise an a univers.versions.InvalidVersion |
| 724 | + Raise a univers.versions.InvalidVersion |
716 | 725 | """
|
717 |
| - # TODO: environment markers are yet supported |
| 726 | + # TODO: environment markers are not yet supported |
718 | 727 | # TODO: handle .* version, ~= and === operators
|
719 | 728 |
|
720 | 729 | if ";" in string:
|
@@ -1177,6 +1186,16 @@ class MattermostVersionRange(VersionRange):
|
1177 | 1186 | version_class = versions.SemverVersion
|
1178 | 1187 |
|
1179 | 1188 |
|
| 1189 | +class AllVersionRange(VersionRange): |
| 1190 | + scheme = "all" |
| 1191 | + version_class = versions.AllVersion |
| 1192 | + |
| 1193 | + |
| 1194 | +class NoneVersionRange(VersionRange): |
| 1195 | + scheme = "none" |
| 1196 | + version_class = versions.NoneVersion |
| 1197 | + |
| 1198 | + |
1180 | 1199 | def from_gitlab_native(gitlab_scheme, string):
|
1181 | 1200 | purl_scheme = gitlab_scheme
|
1182 | 1201 | if gitlab_scheme not in PURL_TYPE_BY_GITLAB_SCHEME.values():
|
@@ -1419,6 +1438,8 @@ def build_range_from_snyk_advisory_string(scheme: str, string: Union[str, List])
|
1419 | 1438 | "openssl": OpensslVersionRange,
|
1420 | 1439 | "mattermost": MattermostVersionRange,
|
1421 | 1440 | "conan": ConanVersionRange,
|
| 1441 | + "all": AllVersionRange, |
| 1442 | + "none": NoneVersionRange, |
1422 | 1443 | }
|
1423 | 1444 |
|
1424 | 1445 | PURL_TYPE_BY_GITLAB_SCHEME = {
|
|
0 commit comments