mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Filter out yanked links from available versions error message
This commit is contained in:
parent
49b9c0470f
commit
510c6acf69
3 changed files with 47 additions and 1 deletions
1
news/12225.bugfix.rst
Normal file
1
news/12225.bugfix.rst
Normal file
|
@ -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. The yanked versions (if any) will be mentioned in a separate error message.
|
|
@ -603,8 +603,26 @@ class Factory:
|
||||||
|
|
||||||
cands = self._finder.find_all_candidates(req.project_name)
|
cands = self._finder.find_all_candidates(req.project_name)
|
||||||
skipped_by_requires_python = self._finder.requires_python_skipped_reasons()
|
skipped_by_requires_python = self._finder.requires_python_skipped_reasons()
|
||||||
versions = [str(v) for v in sorted({c.version for c in cands})]
|
|
||||||
|
|
||||||
|
versions_set: Set[CandidateVersion] = set()
|
||||||
|
yanked_versions_set: Set[CandidateVersion] = set()
|
||||||
|
for c in cands:
|
||||||
|
is_yanked = c.link.is_yanked if c.link else False
|
||||||
|
if is_yanked:
|
||||||
|
yanked_versions_set.add(c.version)
|
||||||
|
else:
|
||||||
|
versions_set.add(c.version)
|
||||||
|
|
||||||
|
versions = [str(v) for v in sorted(versions_set)]
|
||||||
|
yanked_versions = [str(v) for v in sorted(yanked_versions_set)]
|
||||||
|
|
||||||
|
if yanked_versions:
|
||||||
|
# Saying "version X is yanked" isn't entirely accurate.
|
||||||
|
# https://github.com/pypa/pip/issues/11745#issuecomment-1402805842
|
||||||
|
logger.critical(
|
||||||
|
"Ignored the following yanked versions: %s",
|
||||||
|
", ".join(yanked_versions) or "none",
|
||||||
|
)
|
||||||
if skipped_by_requires_python:
|
if skipped_by_requires_python:
|
||||||
logger.critical(
|
logger.critical(
|
||||||
"Ignored the following versions that require a different python "
|
"Ignored the following versions that require a different python "
|
||||||
|
|
|
@ -2242,6 +2242,33 @@ def test_install_yanked_file_and_print_warning(
|
||||||
assert "Successfully installed simple-3.0\n" in result.stdout, str(result)
|
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)
|
||||||
|
# and mentioned in a separate warning:
|
||||||
|
expected_warning = "Ignored the following yanked versions: 3.0"
|
||||||
|
assert expected_warning in result.stderr, str(result)
|
||||||
|
|
||||||
|
|
||||||
def test_error_all_yanked_files_and_no_pin(
|
def test_error_all_yanked_files_and_no_pin(
|
||||||
script: PipTestEnvironment, data: TestData
|
script: PipTestEnvironment, data: TestData
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
Loading…
Reference in a new issue