Skip to content

Commit

Permalink
Merge pull request #9493 from pfmoore/extra_at_end
Browse files Browse the repository at this point in the history
Remove support for extras after specifier in requirements
  • Loading branch information
pfmoore authored Jan 23, 2021
2 parents 95e1c00 + d6a2101 commit d41356f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 36 deletions.
4 changes: 1 addition & 3 deletions src/pip/_internal/req/constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from pip._internal.models.wheel import Wheel
from pip._internal.pyproject import make_pyproject_path
from pip._internal.req.req_install import InstallRequirement
from pip._internal.utils.deprecation import deprecated
from pip._internal.utils.filetypes import is_archive_file
from pip._internal.utils.misc import is_installable_dir
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
Expand Down Expand Up @@ -365,8 +364,7 @@ def with_source(text):
spec_str = str(spec)
if spec_str.endswith(']'):
msg = f"Extras after version '{spec_str}'."
replace = "moving the extras before version specifiers"
deprecated(msg, replacement=replace, gone_in="21.0")
raise InstallationError(msg)
else:
req = None

Expand Down
11 changes: 4 additions & 7 deletions tests/functional/test_install_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,22 @@ def test_nonexistent_options_listed_in_order(script, data):
assert matches == ['nonexistent', 'nope']


def test_install_deprecated_extra(script, data):
def test_install_fails_if_extra_at_end(script, data):
"""
Warn about deprecated order of specifiers and extras.
Fail if order of specifiers and extras is incorrect.
Test uses a requirements file to avoid a testing issue where
the specifier gets interpreted as shell redirect.
"""
script.scratch_path.joinpath("requirements.txt").write_text(
"requires_simple_extra>=0.1[extra]"
)
simple = script.site_packages / 'simple'

result = script.pip(
'install', '--no-index', '--find-links=' + data.find_links,
'-r', script.scratch_path / 'requirements.txt', expect_stderr=True,
'-r', script.scratch_path / 'requirements.txt', expect_error=True,
)

result.did_create(simple)
assert ("DEPRECATION: Extras after version" in result.stderr)
assert "Extras after version" in result.stderr


def test_install_special_extra(script):
Expand Down
26 changes: 0 additions & 26 deletions tests/functional/test_new_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,32 +226,6 @@ def test_new_resolver_installs_extras(tmpdir, script, root_dep):
assert_installed(script, base="0.1.0", dep="0.1.0")


def test_new_resolver_installs_extras_deprecated(tmpdir, script):
req_file = tmpdir.joinpath("requirements.txt")
req_file.write_text("base >= 0.1.0[add]")

create_basic_wheel_for_package(
script,
"base",
"0.1.0",
extras={"add": ["dep"]},
)
create_basic_wheel_for_package(
script,
"dep",
"0.1.0",
)
result = script.pip(
"install",
"--no-cache-dir", "--no-index",
"--find-links", script.scratch_path,
"-r", req_file,
expect_stderr=True
)
assert "DEPRECATION: Extras after version" in result.stderr
assert_installed(script, base="0.1.0", dep="0.1.0")


def test_new_resolver_installs_extras_warn_missing(script):
create_basic_wheel_for_package(
script,
Expand Down

0 comments on commit d41356f

Please sign in to comment.