Skip to content

Commit

Permalink
Clean up PEP 440 wheel filename deprecation language
Browse files Browse the repository at this point in the history
  • Loading branch information
notatallshaw committed Oct 13, 2024
1 parent ec5faea commit ca130c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
24 changes: 4 additions & 20 deletions src/pip/_internal/models/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,15 @@ def __init__(self, filename: str) -> None:
if "_" in _version:
try:
parse_wheel_filename(filename)
except InvalidVersion as e:
deprecated(
reason=(
f"Wheel filename version part {_version!r} is not correctly "
"normalised, and contained an underscore character in the "
"version part. Future versions of pip will fail to recognise "
f"this wheel and report the error: {e.args[0]}."
),
replacement=(
"rename the wheel to use a correctly normalised "
"version part (this may require updating the version "
"in the project metadata)"
),
gone_in="25.1",
issue=12938,
)
except PackagingInvalidWheelName as e:
deprecated(
reason=(
f"The wheel filename {filename!r} is not correctly normalised. "
"Future versions of pip will fail to recognise this wheel. "
f"and report the error: {e.args[0]}."
f"Wheel filename {filename!r} is not correctly normalised. "
"Future versions of pip will raise the following error:\n"
f"{e.args[0]}\n\n"
),
replacement=(
"rename the wheel to use a correctly normalised "
"to rename the wheel to use a correctly normalised "
"name (this may require updating the version in "
"the project metadata)"
),
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/test_models_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,10 @@ def test_version_underscore_conversion(self) -> None:
with pytest.warns(deprecation.PipDeprecationWarning):
w = Wheel("simple-0.1_1-py2-none-any.whl")
assert w.version == "0.1-1"

def test_invalid_wheel_warning(self) -> None:
"""
Test that wheel with invalid name produces warning
"""
with pytest.warns(deprecation.PipDeprecationWarning):
Wheel("six-1.16.0_build1-py3-none-any.whl")

0 comments on commit ca130c6

Please sign in to comment.