Skip to content

Validate vers qualifier #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ package_dir = =src
include_package_data = true
zip_safe = false
install_requires =
univers>=30.12.1

[options.packages.find]
where = src
Expand Down
5 changes: 5 additions & 0 deletions src/packageurl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@

AnyStr = Union[str, bytes]

from univers.version_range import VersionRange

# Python 3
basestring = (bytes, str)

Expand Down Expand Up @@ -221,6 +223,9 @@ def normalize_qualifiers(
if key[0] in string.digits:
raise ValueError(f"A qualifier key cannot start with a number: {key!r}")

if vers := qualifiers_map.get("vers"):
VersionRange.from_string(vers, validate=True)

qualifiers_map = dict(sorted(qualifiers_map.items()))

if not encode:
Expand Down