From ac51fa4630d32b595f6188fcdda080ad3e95a7e7 Mon Sep 17 00:00:00 2001 From: Xavier Fernandez Date: Fri, 30 Oct 2020 00:13:52 +0100 Subject: [PATCH] freeze: make --all the default & deprecate it --- news/4256.removal.rst | 2 ++ src/pip/_internal/commands/freeze.py | 16 +++++++++------- tests/functional/test_freeze.py | 13 +++++-------- 3 files changed, 16 insertions(+), 15 deletions(-) create mode 100644 news/4256.removal.rst diff --git a/news/4256.removal.rst b/news/4256.removal.rst new file mode 100644 index 00000000000..21db2a89a38 --- /dev/null +++ b/news/4256.removal.rst @@ -0,0 +1,2 @@ +Stop filtering the ``pip``, ``setuptools``, ``distribute`` and ``wheel`` packages from ``pip freeze``. +The equivalent option ``--all`` is now deprecated and does nothing. diff --git a/src/pip/_internal/commands/freeze.py b/src/pip/_internal/commands/freeze.py index 430d1018f04..9190344f7cb 100644 --- a/src/pip/_internal/commands/freeze.py +++ b/src/pip/_internal/commands/freeze.py @@ -9,8 +9,6 @@ from pip._internal.utils.compat import stdlib_pkgs from pip._internal.utils.deprecation import deprecated -DEV_PKGS = {'pip', 'setuptools', 'distribute', 'wheel'} - class FreezeCommand(Command): """ @@ -58,10 +56,9 @@ def add_options(self): self.cmd_opts.add_option(cmdoptions.list_path()) self.cmd_opts.add_option( '--all', - dest='freeze_all', + dest='freeze_all_used', action='store_true', - help='Do not skip these packages in the output:' - ' {}'.format(', '.join(DEV_PKGS))) + help='Deprecated - Does nothing.') self.cmd_opts.add_option( '--exclude-editable', dest='exclude_editable', @@ -74,8 +71,13 @@ def add_options(self): def run(self, options, args): # type: (Values, List[str]) -> int skip = set(stdlib_pkgs) - if not options.freeze_all: - skip.update(DEV_PKGS) + + if options.freeze_all_used: + deprecated( + "--all is now the default behavior and does nothing", + None, + gone_in="23.3", + ) if options.excludes: skip.update(options.excludes) diff --git a/tests/functional/test_freeze.py b/tests/functional/test_freeze.py index 858e43931db..f53dd55c4d8 100644 --- a/tests/functional/test_freeze.py +++ b/tests/functional/test_freeze.py @@ -79,7 +79,7 @@ def test_basic_freeze(script): def test_freeze_with_pip(script): """Test pip shows itself""" - result = script.pip('freeze', '--all') + result = script.pip('freeze') assert 'pip==' in result.stdout @@ -93,13 +93,10 @@ def test_exclude_and_normalization(script, tmpdir): assert "Normalizable-Name" not in result.stdout -def test_freeze_multiple_exclude_with_all(script, with_wheel): - result = script.pip('freeze', '--all') - assert 'pip==' in result.stdout - assert 'wheel==' in result.stdout - result = script.pip('freeze', '--all', '--exclude', 'pip', '--exclude', 'wheel') - assert 'pip==' not in result.stdout - assert 'wheel==' not in result.stdout +def test_freeze_all_deprecated(script): + """Test that using --all option produces a warning""" + result = script.pip('freeze', '--all', expect_stderr=True) + assert '--all is now the default behavior and does nothing' in result.stderr def test_freeze_with_invalid_names(script):