From ca130c6890cb1a398ef0d2eaf6f6bdd7ab8097f9 Mon Sep 17 00:00:00 2001 From: Damian Shaw Date: Sun, 13 Oct 2024 13:46:08 -0400 Subject: [PATCH 1/3] Clean up PEP 440 wheel filename deprecation language --- src/pip/_internal/models/wheel.py | 24 ++++-------------------- tests/unit/test_models_wheel.py | 7 +++++++ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/pip/_internal/models/wheel.py b/src/pip/_internal/models/wheel.py index 67318ae55a8..dc5cf255200 100644 --- a/src/pip/_internal/models/wheel.py +++ b/src/pip/_internal/models/wheel.py @@ -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)" ), diff --git a/tests/unit/test_models_wheel.py b/tests/unit/test_models_wheel.py index 0fcd4be874f..e87b2c107a0 100644 --- a/tests/unit/test_models_wheel.py +++ b/tests/unit/test_models_wheel.py @@ -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") From 64b9dbc0e30558bd068511640a4a07d35fa46741 Mon Sep 17 00:00:00 2001 From: Damian Shaw Date: Sun, 13 Oct 2024 13:49:11 -0400 Subject: [PATCH 2/3] NEWS ENTRY --- news/13012.trivial.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/13012.trivial.rst diff --git a/news/13012.trivial.rst b/news/13012.trivial.rst new file mode 100644 index 00000000000..623523a9e09 --- /dev/null +++ b/news/13012.trivial.rst @@ -0,0 +1 @@ +Clean up non PEP 440 wheel filename deprecation language. From ca302173da7000bfa5ecb85c26c68d3095450dc0 Mon Sep 17 00:00:00 2001 From: Damian Shaw Date: Sun, 13 Oct 2024 13:54:19 -0400 Subject: [PATCH 3/3] Fix linting --- src/pip/_internal/models/wheel.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pip/_internal/models/wheel.py b/src/pip/_internal/models/wheel.py index dc5cf255200..ea8560089d3 100644 --- a/src/pip/_internal/models/wheel.py +++ b/src/pip/_internal/models/wheel.py @@ -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