Closed yajo closed 2 years ago
Technically, I wouldn't say that v2.0.0.alpha1
is a "valid PEP-440 version", but rather that it's a legacy syntax for which PEP-440 defines how to convert it into a valid version. Or I suppose you could say it's a valid input version, but not a valid output version.
https://www.python.org/dev/peps/pep-0440/#normalization
In order to maintain better compatibility with existing versions there are a number of "alternative" syntaxes that MUST be taken into account when parsing versions. These syntaxes MUST be considered when parsing a version, however they should be "normalized" to the standard syntax defined above.
"Existing versions" meaning pre-PEP-440.
PEP-440 says that these legacy syntaxes must be considered when "parsing a version", but strictly speaking, Dunamai isn't parsing a version, but rather parsing a version-like tag. For example, you might have a tag like v-a1-1.2.3
and then define Dunamai's --pattern
such that it's converted into the version 1.2.3a1
.
Essentially, the request here is to recognize the pre-normalized alternative syntaxes when parsing a version-like tag (i.e., expand Dunamai's default tag regex) and then normalize them in serialize_pep440()
. Some of these are supported already as a side effect of supporting multiple versioning styles (e.g., v2.0.0-alpha1
is already recognized in tags, although alpha
isn't normalized to a
for PEP 440), so I think it makes sense to fill in the gaps (e.g., v2.0.0.alpha1
and v2.0.0_alpha1
currently aren't recognized in tags).
Your tag v2.0.0.alpha1
will now work as expected in Dunamai v1.7.0:
$ dunamai from git
2.0.0a1
With a repo like this:
You get a version like this:
However packaging seems to parse the version just fine:
Because
v2.0.0.alpha1
is a valid PEP440 version. See: