Skip to content

Commit

Permalink
Filter out yanked links from available versions error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelange committed Aug 14, 2023
1 parent 0778c1c commit 7eb7afa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/12225.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Filter out yanked links from the available versions error message: "(from versions: 1.0, 2.0, 3.0)" will not contain yanked versions conform PEP 592.
7 changes: 6 additions & 1 deletion src/pip/_internal/resolution/resolvelib/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,12 @@ def _report_single_requirement_conflict(

cands = self._finder.find_all_candidates(req.project_name)
skipped_by_requires_python = self._finder.requires_python_skipped_reasons()
versions = [str(v) for v in sorted({c.version for c in cands})]
versions = [
str(v)
for v in sorted(
{c.version for c in cands if not getattr(c.link, "is_yanked", False)}
)
]

if skipped_by_requires_python:
logger.critical(
Expand Down
24 changes: 24 additions & 0 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2242,6 +2242,30 @@ def test_install_yanked_file_and_print_warning(
assert "Successfully installed simple-3.0\n" in result.stdout, str(result)


def test_yanked_version_missing_from_availble_versions_error_message(
script: PipTestEnvironment, data: TestData
) -> None:
"""
Test yanked version is missing from available versions error message.
Yanked files are always ignored, unless they are the only file that
matches a version specifier that "pins" to an exact version (PEP 592).
"""
result = script.pip(
"install",
"simple==",
"--index-url",
data.index_url("yanked"),
expect_error=True,
)
# the yanked version (3.0) is filtered out from the output:
expected_warning = (
"Could not find a version that satisfies the requirement simple== "
"(from versions: 1.0, 2.0)"
)
assert expected_warning in result.stderr, str(result)


def test_error_all_yanked_files_and_no_pin(
script: PipTestEnvironment, data: TestData
) -> None:
Expand Down

0 comments on commit 7eb7afa

Please sign in to comment.