From a5c548c9a8351a99a1d3ec2ead94c156cbf0ff26 Mon Sep 17 00:00:00 2001 From: Felipe Peter Date: Mon, 3 Oct 2022 21:55:00 +0800 Subject: [PATCH 1/3] Disallow combination of pip list --outdated with freeze format --- src/pip/_internal/commands/list.py | 5 +++++ tests/functional/test_list.py | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/pip/_internal/commands/list.py b/src/pip/_internal/commands/list.py index a9b08a0bc88..8e1426dbb6c 100644 --- a/src/pip/_internal/commands/list.py +++ b/src/pip/_internal/commands/list.py @@ -155,6 +155,11 @@ def run(self, options: Values, args: List[str]) -> int: if options.outdated and options.uptodate: raise CommandError("Options --outdated and --uptodate cannot be combined.") + if options.outdated and options.list_format == "freeze": + raise CommandError( + "List format 'freeze' can not be used with the --outdated option." + ) + cmdoptions.check_list_path_option(options) skip = set(stdlib_pkgs) diff --git a/tests/functional/test_list.py b/tests/functional/test_list.py index c799aabd255..c7fdec2f2fc 100644 --- a/tests/functional/test_list.py +++ b/tests/functional/test_list.py @@ -577,7 +577,7 @@ def test_outdated_formats(script: PipTestEnvironment, data: TestData) -> None: assert "Package Version Latest Type" in result.stdout assert "simple 1.0 1.1 wheel" in result.stdout - # Check freeze + # Check that freeze is not allowed result = script.pip( "list", "--no-index", @@ -585,8 +585,12 @@ def test_outdated_formats(script: PipTestEnvironment, data: TestData) -> None: wheelhouse_path, "--outdated", "--format=freeze", + expect_error=True, + ) + assert ( + "List format 'freeze' can not be used with the --outdated option." + in result.stderr ) - assert "simple==1.0" in result.stdout # Check json result = script.pip( From 611ed3f43218047fdc9fb82afec5f4e988c86892 Mon Sep 17 00:00:00 2001 From: Felipe Peter Date: Mon, 3 Oct 2022 22:04:34 +0800 Subject: [PATCH 2/3] Add news fragment --- news/9789.removal.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/9789.removal.rst diff --git a/news/9789.removal.rst b/news/9789.removal.rst new file mode 100644 index 00000000000..f8f12d57de2 --- /dev/null +++ b/news/9789.removal.rst @@ -0,0 +1 @@ +Remove the ability to use 'pip list --outdated' in combination with "--format=freeze". From 1e2f1f733c5898c342148aab6a40e4babe206262 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Tue, 4 Oct 2022 14:32:26 +0800 Subject: [PATCH 3/3] Use inline code in fragment --- news/9789.removal.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/9789.removal.rst b/news/9789.removal.rst index f8f12d57de2..90ded923507 100644 --- a/news/9789.removal.rst +++ b/news/9789.removal.rst @@ -1 +1 @@ -Remove the ability to use 'pip list --outdated' in combination with "--format=freeze". +Remove the ability to use ``pip list --outdated`` in combination with ``--format=freeze``.