diff --git a/news/9789.removal.rst b/news/9789.removal.rst new file mode 100644 index 00000000000..90ded923507 --- /dev/null +++ b/news/9789.removal.rst @@ -0,0 +1 @@ +Remove the ability to use ``pip list --outdated`` in combination with ``--format=freeze``. 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(