Skip to content

Commit af3062a

Browse files
pradyunsgxavfernandez
authored andcommitted
Remove the deprecated pip config --venv option (#7163)
1 parent 79b48aa commit af3062a

File tree

3 files changed

+1
-51
lines changed

3 files changed

+1
-51
lines changed

news/7163.removal

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove the deprecated ``--venv`` option from ``pip config``.

src/pip/_internal/commands/configuration.py

-28
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
kinds,
1414
)
1515
from pip._internal.exceptions import PipError
16-
from pip._internal.utils.deprecation import deprecated
1716
from pip._internal.utils.misc import get_prog, write_output
18-
from pip._internal.utils.virtualenv import running_under_virtualenv
1917

2018
logger = logging.getLogger(__name__)
2119

@@ -87,17 +85,6 @@ def __init__(self, *args, **kwargs):
8785
help='Use the current environment configuration file only'
8886
)
8987

90-
self.cmd_opts.add_option(
91-
'--venv',
92-
dest='venv_file',
93-
action='store_true',
94-
default=False,
95-
help=(
96-
'[Deprecated] Use the current environment configuration '
97-
'file in a virtual environment only'
98-
)
99-
)
100-
10188
self.parser.insert_option_group(0, self.cmd_opts)
10289

10390
def run(self, options, args):
@@ -144,21 +131,6 @@ def run(self, options, args):
144131
return SUCCESS
145132

146133
def _determine_file(self, options, need_value):
147-
# Convert legacy venv_file option to site_file or error
148-
if options.venv_file and not options.site_file:
149-
if running_under_virtualenv():
150-
options.site_file = True
151-
deprecated(
152-
"The --venv option has been deprecated.",
153-
replacement="--site",
154-
gone_in="19.3",
155-
)
156-
else:
157-
raise PipError(
158-
"Legacy --venv option requires a virtual environment. "
159-
"Use --site instead."
160-
)
161-
162134
file_options = [key for key, value in (
163135
(kinds.USER, options.user_file),
164136
(kinds.GLOBAL, options.global_file),

tests/unit/test_options.py

-23
Original file line numberDiff line numberDiff line change
@@ -421,26 +421,3 @@ def test_config_file_options(self, monkeypatch, args, expect):
421421
cmd._determine_file(options, need_value=False)
422422
else:
423423
assert expect == cmd._determine_file(options, need_value=False)
424-
425-
def test_config_file_venv_option(self, monkeypatch):
426-
cmd = create_command('config')
427-
# Replace a handler with a no-op to avoid side effects
428-
monkeypatch.setattr(cmd, "get_name", lambda *a: None)
429-
430-
collected_warnings = []
431-
432-
def _warn(message, *a, **kw):
433-
collected_warnings.append(message)
434-
monkeypatch.setattr("warnings.warn", _warn)
435-
436-
options, args = cmd.parser.parse_args(["--venv", "get", "name"])
437-
assert "site" == cmd._determine_file(options, need_value=False)
438-
assert collected_warnings
439-
assert "--site" in collected_warnings[0]
440-
441-
# No warning or error if both "--venv" and "--site" are specified
442-
collected_warnings[:] = []
443-
options, args = cmd.parser.parse_args(["--venv", "--site", "get",
444-
"name"])
445-
assert "site" == cmd._determine_file(options, need_value=False)
446-
assert not collected_warnings

0 commit comments

Comments
 (0)