-
Notifications
You must be signed in to change notification settings - Fork 249
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
Added packaging.utils.create_wheel_filename and create_sdist_filename functions #409
Open
e2thenegpii
wants to merge
2
commits into
pypa:main
Choose a base branch
from
e2thenegpii:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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 |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
InvalidWheelFilename, | ||
canonicalize_name, | ||
canonicalize_version, | ||
create_sdist_filename, | ||
create_wheel_filename, | ||
parse_sdist_filename, | ||
parse_wheel_filename, | ||
) | ||
|
@@ -94,6 +96,43 @@ def test_canonicalize_version_no_strip_trailing_zero(version): | |
(1000, "abc"), | ||
{Tag("py3", "none", "any")}, | ||
), | ||
( | ||
"foo_bar-1.0-42-py2.py3-none-any.whl", | ||
"foo-bar", | ||
Version("1.0"), | ||
(42, ""), | ||
{Tag("py2", "none", "any"), Tag("py3", "none", "any")}, | ||
), | ||
], | ||
Comment on lines
+105
to
+106
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. Could you add a test putting |
||
) | ||
def test_create_wheel_filename(filename, name, version, build, tags): | ||
assert create_wheel_filename(name, version, build, tags) == filename | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("filename", "name", "version", "build", "tags"), | ||
[ | ||
( | ||
"foo-1.0-py3-none-any.whl", | ||
"foo", | ||
Version("1.0"), | ||
(), | ||
{Tag("py3", "none", "any")}, | ||
), | ||
( | ||
"foo-1.0-1000-py3-none-any.whl", | ||
"foo", | ||
Version("1.0"), | ||
(1000, ""), | ||
{Tag("py3", "none", "any")}, | ||
), | ||
( | ||
"foo-1.0-1000abc-py3-none-any.whl", | ||
"foo", | ||
Version("1.0"), | ||
(1000, "abc"), | ||
{Tag("py3", "none", "any")}, | ||
), | ||
], | ||
) | ||
def test_parse_wheel_filename(filename, name, version, build, tags): | ||
|
@@ -119,7 +158,17 @@ def test_parse_wheel_invalid_filename(filename): | |
|
||
@pytest.mark.parametrize( | ||
("filename", "name", "version"), | ||
[("foo-1.0.tar.gz", "foo", Version("1.0")), ("foo-1.0.zip", "foo", Version("1.0"))], | ||
[ | ||
("foo-1.0.tar.gz", "foo", Version("1.0")), | ||
("foo_bar-1.0.tar.gz", "foo-bar", Version("1.0")), | ||
], | ||
) | ||
def test_create_sdist_filename(filename, name, version): | ||
assert create_sdist_filename(name, version) == filename | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("filename", "name", "version"), [("foo-1.0.tar.gz", "foo", Version("1.0"))] | ||
) | ||
def test_parse_sdist_filename(filename, name, version): | ||
assert parse_sdist_filename(filename) == (name, version) | ||
|
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 parse -> create feels... asymmetric. My instinctive answer for an alternative to
create
iscompose
and a Google search got me to https://stackoverflow.com/questions/148857/what-is-the-opposite-of-parse as the first result, which makes me feel validated. :)Let's change to this naming scheme: