-
Notifications
You must be signed in to change notification settings - Fork 95
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
Replace pkg_resources.parse_version with packaging.version.parse #693
Changes from 5 commits
8a1e957
ff1483b
57f13b1
c4c1049
a228a51
d8e4d15
cd20317
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -36,14 +36,15 @@ | |||||
|
||||||
import os | ||||||
import functools | ||||||
import re | ||||||
import shutil | ||||||
import subprocess | ||||||
import tempfile | ||||||
|
||||||
from subprocess import PIPE | ||||||
from subprocess import CalledProcessError | ||||||
|
||||||
from pkg_resources import parse_version | ||||||
from packaging import version | ||||||
|
||||||
from bloom.logging import debug | ||||||
from bloom.logging import error | ||||||
|
@@ -686,7 +687,9 @@ def get_last_tag_by_version(directory=None): | |||||
versions = [] | ||||||
for line in output.splitlines(): | ||||||
tags.append(line.strip()) | ||||||
versions.append(parse_version(line.strip())) | ||||||
ver = re.match("[0-9]+.[0-9]+.[0-9]+", line) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Since dots are regex metacharacters they need to be escaped for an exact match. Or is the intent that any character could separate these digits? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is likely what was intended. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved in cd20317 |
||||||
if ver: | ||||||
versions.append(ver) | ||||||
return tags[versions.index(max(versions))] if versions else '' | ||||||
|
||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being a bit of a python outsider, I've always disliked that a function's utility is sometimes obfuscated when the functions are imported outside their module.
Does using the alias-on-import feature make sense so that
parse
doesn't lose its context.If using the alias-on-import feature is not seen as idiomatic then I could live with it as is, but I think it improves local legibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another alternative that is used in the other files is to import the entire version module which would afford the same context as the function would be invoked as
version.parse()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say the function name should just be something more specific than parse, but I think your first suggestion is just fine for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like I've avoided using
from packaging import version
, because the parameter for theversion_check
method was alsoversion
and there was a conflict.But I can go with parse_version.