Skip to content

Commit

Permalink
Merge pull request #13012 from notatallshaw/clean-up-non-PEP-440-whee…
Browse files Browse the repository at this point in the history
…l-filename-deprecation-language

Clean up non PEP 440 wheel filename deprecation language
  • Loading branch information
sbidoul authored Oct 20, 2024
2 parents 6427eac + ca30217 commit 53ba3fb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 24 deletions.
1 change: 1 addition & 0 deletions news/13012.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clean up non PEP 440 wheel filename deprecation language.
29 changes: 5 additions & 24 deletions src/pip/_internal/models/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
from typing import Dict, Iterable, List

from pip._vendor.packaging.tags import Tag
from pip._vendor.packaging.utils import (
InvalidVersion,
parse_wheel_filename,
)
from pip._vendor.packaging.utils import (
InvalidWheelFilename as PackagingInvalidWheelName,
)
from pip._vendor.packaging.utils import parse_wheel_filename

from pip._internal.exceptions import InvalidWheelFilename
from pip._internal.utils.deprecation import deprecated
Expand Down Expand Up @@ -41,31 +38,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 53ba3fb

Please sign in to comment.