-
Notifications
You must be signed in to change notification settings - Fork 5
Version._parse_version_str(version) fails if version is a packaging.version.LegacyVersion #9
Comments
I do not have the bandwidth to take care of this right now. A PR would be greatly appreciated! |
@JMSwag I would have some time to create a PR for a quick fix, but I'm not sure what would be best. Some options:
I guess anything beyond that, such as the proposal in issue290, would become a lot more invasive. |
@dennisvang I like option 1. |
@JMSwag After some more digging I'm not sure this is the way to go. For example, pyupdater's Package expects This ability was removed here: e964aa2 If you drop support for non-pep440-compliant version strings, as is currently the case (though inadvertently), In that case, is there a compelling reason to keep |
The current implementation of This breaks e.g. pyupdater.client.updates.get_highest_version, as can be seen in pyupdater's TestChannelStrict failing. |
The following fails for pre-release version strings, although it passes for basic stable version strings. version_string = "1.0a"
v = Version(version_string)
assert v == Version(str(v)) |
Description
PyUpdater 4.0 fails due to
dsdev-utils.helpers.Version._parse_version_str()
with anAttributeError: 'LegacyVersion' object has no attribute 'major'
if version string is not PEP440 compliant.Cause
This line assumes
version
is apackaging.version.Version
, so packaging.version.LegacyVersion is not handled.The problem is introduced in pr #8 (issue #7).
How to reproduce
Using dsdev-utils 1.3.0 on python 3.9.7:
Notes
The
LegacyVersion
is deprecated, although it is still used by packaging.version.parse().I think it would be nice to handle e.g. output of
git describe
gracefully, if it starts with a valid PEP440 version, such as'1.18.0-64-g987cb3c'
. Could treat this as a dev release with local identifier, for example doing something along the lines of:On the other hand, perhaps it makes more sense just to require PEP440 compliance and let the user handle this...
Anyway, even if PEP440 compliance is required, I think the non-compliant (
LegacyVersion
) case should still be handled gracefully by_parse_version_str()
.The text was updated successfully, but these errors were encountered: