Skip to content
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

Keep leading zeros in version labels. Resolves: python-poetry#3705. #167

Merged
merged 2 commits into from
Apr 10, 2021
Merged
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
2 changes: 1 addition & 1 deletion poetry/core/version/pep440/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _get_local(cls, match: Optional[Match[AnyStr]]) -> Optional[LocalSegmentType
return None

return tuple(
part.lower() if not part.isdigit() else int(part)
part.lower()
for part in cls._local_version_separators.split(match.group("local"))
)

Expand Down
4 changes: 3 additions & 1 deletion poetry/core/version/pep440/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ def _make_compare_key(self):
# - Shorter versions sort before longer versions when the prefixes
# match exactly
_local = tuple(
(i, "") if isinstance(i, int) else (-math.inf, i) for i in self.local
# We typecast strings that are integers so that they can be compared
(int(i), "") if str(i).isnumeric() else (-math.inf, i)
for i in self.local
)
return self.epoch, self.release, _pre, _post, _dev, _local

Expand Down
8 changes: 8 additions & 0 deletions tests/version/test_version_pep440.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ def test_pep440_release_tag_next(phase):
"1.2.3.rc1",
PEP440Version(release=Release.from_parts(1, 2, 3), pre=ReleaseTag("rc", 1)),
),
(
"2.2.0dev0+build.05669607",
PEP440Version(
release=Release.from_parts(2, 2, 0),
dev=ReleaseTag("dev", 0),
local=("build", "05669607"),
),
),
],
)
def test_pep440_parse_text(text, result):
Expand Down