Skip to content

Commit bceb840

Browse files
committed
Filter out yanked links from available versions error message
1 parent 0778c1c commit bceb840

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

news/12225.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

src/pip/_internal/resolution/resolvelib/factory.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,9 @@ def _report_single_requirement_conflict(
603603

604604
cands = self._finder.find_all_candidates(req.project_name)
605605
skipped_by_requires_python = self._finder.requires_python_skipped_reasons()
606-
versions = [str(v) for v in sorted({c.version for c in cands})]
606+
versions = [
607+
str(v) for v in sorted({c.version for c in cands if not c.link.is_yanked})
608+
]
607609

608610
if skipped_by_requires_python:
609611
logger.critical(

tests/functional/test_install.py

+21
Original file line numberDiff line numberDiff line change
@@ -2242,6 +2242,27 @@ def test_install_yanked_file_and_print_warning(
22422242
assert "Successfully installed simple-3.0\n" in result.stdout, str(result)
22432243

22442244

2245+
def test_yanked_version_missing_from_availble_versions_error_message(
2246+
script: PipTestEnvironment, data: TestData
2247+
) -> None:
2248+
"""
2249+
Test yanked version is missing from available versions error message.
2250+
2251+
Yanked files are always ignored, unless they are the only file that
2252+
matches a version specifier that "pins" to an exact version (PEP 592).
2253+
"""
2254+
result = script.pip(
2255+
"install",
2256+
"simple==",
2257+
"--index-url",
2258+
data.index_url("yanked"),
2259+
expect_stderr=True,
2260+
)
2261+
# the yanked version (3.0) is filtered out from the output:
2262+
expected_warning = "Could not find a version that satisfies the requirement simple== (from versions: 1.0, 2.0)"
2263+
assert expected_warning in result.stderr, str(result)
2264+
2265+
22452266
def test_error_all_yanked_files_and_no_pin(
22462267
script: PipTestEnvironment, data: TestData
22472268
) -> None:

0 commit comments

Comments
 (0)