-
Notifications
You must be signed in to change notification settings - Fork 190
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
Using packaging.version instead of pkg_resources #2825
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4f099fc
Using packaging.version instead of pkg_resources
asp8200 ae59ec0
[automated] Update CHANGELOG.md
nf-core-bot be43511
fix type
mashehu a674310
Merge branch 'dev' into 1984_avoid_importing_pkg_resources
asp8200 d70671e
Merge branch 'dev' into 1984_avoid_importing_pkg_resources
asp8200 3a05c73
Merge branch 'dev' into 1984_avoid_importing_pkg_resources
tomiles File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
import rich | ||
import rich.progress | ||
from git.exc import GitCommandError, InvalidGitRepositoryError | ||
from pkg_resources import parse_version as version_parser | ||
from packaging.version import Version | ||
|
||
import nf_core | ||
import nf_core.list | ||
|
@@ -1664,9 +1664,7 @@ def tidy_tags_and_branches(self): | |
else: | ||
# desired revisions may contain arbitrary branch names that do not correspond to valid sematic versioning patterns. | ||
valid_versions = [ | ||
version_parser(v) | ||
for v in desired_revisions | ||
if re.match(r"\d+\.\d+(?:\.\d+)*(?:[\w\-_])*", v) | ||
str(Version(v)) for v in desired_revisions if re.match(r"\d+\.\d+(?:\.\d+)*(?:[\w\-_])*", v) | ||
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. A separate issue is the conversion of the
|
||
] | ||
# valid versions sorted in ascending order, last will be aliased as "latest". | ||
latest = sorted(valid_versions)[-1] | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The problem with the usage of
packaging.Version()
as it stands here now is mentioned in the comment above.And
packaging.Version
has its own definition of what a valid version identifier is and it is not completely compatible with semantic versions either.As an example:
This will not work nicely if any of the desired revisions fails validity checking inside
Version()
.The previous version parser
from pkg_resources import parse_version
returns a LegacyVersion if it can't parse the identifier, which makes it much better suited in this context thanpackaging.Version
.I am not versed enough to know what kind of strings can appear in
desired_revisions
but I believe this code should be able to sort a broader range of version specifiers.