Skip to content

Commit 19df53f

Browse files
committed
Add is_yanked to installation report
1 parent 0778c1c commit 19df53f

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/pip/_internal/models/installation_report.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ def _install_req_to_dict(cls, ireq: InstallRequirement) -> Dict[str, Any]:
2323
# includes editable requirements), and false if the requirement was
2424
# downloaded from a PEP 503 index or --find-links.
2525
"is_direct": ireq.is_direct,
26+
# is_yanked is true if the requirement was yanked from the index, but
27+
# still was selected by pip conform PEP 592
28+
"is_yanked": ireq.link.is_yanked,
2629
# requested is true if the requirement was specified by the user (aka
2730
# top level requirement), and false if it was installed as a dependency of a
2831
# requirement. https://peps.python.org/pep-0376/#requested

tests/functional/test_install_report.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,31 @@ def test_install_report_dep(
6464
assert _install_dict(report)["simple"]["requested"] is False
6565

6666

67+
def test_yanked_version(
68+
script: PipTestEnvironment, data: TestData, tmp_path: Path
69+
) -> None:
70+
"""
71+
Test yanked version is missing from available versions error message.
72+
Yanked files are always ignored, unless they are the only file that
73+
matches a version specifier that "pins" to an exact version (PEP 592).
74+
"""
75+
report_path = tmp_path / "report.json"
76+
result = script.pip(
77+
"install",
78+
"simple==3.0",
79+
"--index-url",
80+
data.index_url("yanked"),
81+
"--dry-run",
82+
"--report",
83+
str(report_path),
84+
)
85+
report = json.loads(report_path.read_text())
86+
simple_report = _install_dict(report)["simple"]
87+
assert simple_report["requested"] is True
88+
assert simple_report["is_direct"] is False
89+
assert simple_report["is_yanked"] is True
90+
91+
6792
@pytest.mark.network
6893
def test_install_report_index(script: PipTestEnvironment, tmp_path: Path) -> None:
6994
"""Test report for sdist obtained from index."""

0 commit comments

Comments
 (0)