Skip to content

Commit

Permalink
Re-do PypiVer parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Sep 8, 2024
1 parent 6b7271f commit 43826f4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/antsibull/collection_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@


def _convert_pypi_version(v: t.Any) -> t.Any:
if not isinstance(v, str):
raise ValueError(f"must be a string, got {v!r}")
if not v:
raise ValueError(f"must be a non-trivial string, got {v!r}")
version = PypiVer(v)
if isinstance(v, str):
if not v:
raise ValueError(f"must be a non-trivial string, got {v!r}")
version = PypiVer(v)
elif isinstance(v, PypiVer):
version = v
else:
raise ValueError(f"must be a string or PypiVer object, got {v!r}")

if len(version.release) != 3:
raise ValueError(
f"must be a version with three release numbers (e.g. 1.2.3, 2.3.4a1), got {v!r}"
Expand Down

0 comments on commit 43826f4

Please sign in to comment.