Skip to content

Commit

Permalink
Remove the deprecated pip config --venv option (#7163)
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg authored and xavfernandez committed Oct 9, 2019
1 parent 79b48aa commit af3062a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 51 deletions.
1 change: 1 addition & 0 deletions news/7163.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the deprecated ``--venv`` option from ``pip config``.
28 changes: 0 additions & 28 deletions src/pip/_internal/commands/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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),
Expand Down
23 changes: 0 additions & 23 deletions tests/unit/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit af3062a

Please sign in to comment.