From 25e20203c6724c5195a26f189f9aaca924b86cea Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Mon, 7 Oct 2019 21:51:41 +0530 Subject: [PATCH 1/2] Remove the deprecated pip config --venv option --- src/pip/_internal/commands/configuration.py | 28 --------------------- tests/unit/test_options.py | 23 ----------------- 2 files changed, 51 deletions(-) diff --git a/src/pip/_internal/commands/configuration.py b/src/pip/_internal/commands/configuration.py index 9b6eb1602da..efcf5bb3699 100644 --- a/src/pip/_internal/commands/configuration.py +++ b/src/pip/_internal/commands/configuration.py @@ -13,9 +13,7 @@ kinds, ) from pip._internal.exceptions import PipError -from pip._internal.utils.deprecation import deprecated from pip._internal.utils.misc import get_prog, write_output -from pip._internal.utils.virtualenv import running_under_virtualenv logger = logging.getLogger(__name__) @@ -87,17 +85,6 @@ def __init__(self, *args, **kwargs): help='Use the current environment configuration file only' ) - self.cmd_opts.add_option( - '--venv', - dest='venv_file', - action='store_true', - default=False, - help=( - '[Deprecated] Use the current environment configuration ' - 'file in a virtual environment only' - ) - ) - self.parser.insert_option_group(0, self.cmd_opts) def run(self, options, args): @@ -144,21 +131,6 @@ def run(self, options, args): return SUCCESS def _determine_file(self, options, need_value): - # Convert legacy venv_file option to site_file or error - if options.venv_file and not options.site_file: - if running_under_virtualenv(): - options.site_file = True - deprecated( - "The --venv option has been deprecated.", - replacement="--site", - gone_in="19.3", - ) - else: - raise PipError( - "Legacy --venv option requires a virtual environment. " - "Use --site instead." - ) - file_options = [key for key, value in ( (kinds.USER, options.user_file), (kinds.GLOBAL, options.global_file), diff --git a/tests/unit/test_options.py b/tests/unit/test_options.py index c49801d99de..a67f34e83cb 100644 --- a/tests/unit/test_options.py +++ b/tests/unit/test_options.py @@ -421,26 +421,3 @@ def test_config_file_options(self, monkeypatch, args, expect): cmd._determine_file(options, need_value=False) else: assert expect == cmd._determine_file(options, need_value=False) - - def test_config_file_venv_option(self, monkeypatch): - cmd = create_command('config') - # Replace a handler with a no-op to avoid side effects - monkeypatch.setattr(cmd, "get_name", lambda *a: None) - - collected_warnings = [] - - def _warn(message, *a, **kw): - collected_warnings.append(message) - monkeypatch.setattr("warnings.warn", _warn) - - options, args = cmd.parser.parse_args(["--venv", "get", "name"]) - assert "site" == cmd._determine_file(options, need_value=False) - assert collected_warnings - assert "--site" in collected_warnings[0] - - # No warning or error if both "--venv" and "--site" are specified - collected_warnings[:] = [] - options, args = cmd.parser.parse_args(["--venv", "--site", "get", - "name"]) - assert "site" == cmd._determine_file(options, need_value=False) - assert not collected_warnings From a3a1ff400caab78d4d692cbe0aac2ca98447309f Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Tue, 8 Oct 2019 13:18:07 +0530 Subject: [PATCH 2/2] :newspaper: --- news/7163.removal | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/7163.removal diff --git a/news/7163.removal b/news/7163.removal new file mode 100644 index 00000000000..e5c7edeefab --- /dev/null +++ b/news/7163.removal @@ -0,0 +1 @@ +Remove the deprecated ``--venv`` option from ``pip config``.