Skip to content

Commit 7cdc1aa

Browse files
sbidouluranusjr
andcommitted
Use metadata['name'] to get requirement name
Co-authored-by: Tzu-ping Chung <[email protected]>
1 parent 63071d4 commit 7cdc1aa

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/pip/_internal/commands/install.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,15 @@ def run(self, options: Values, args: List[str]) -> int:
354354
)
355355

356356
if options.dry_run:
357-
items = [
358-
f"{item.name}-{item.metadata['version']}"
359-
for item in sorted(
360-
requirement_set.all_requirements, key=lambda x: str(x.name)
357+
would_install_items = sorted(
358+
(r.metadata["name"], r.metadata["version"])
359+
for r in requirement_set.all_requirements
360+
)
361+
if would_install_items:
362+
write_output(
363+
"Would install %s",
364+
" ".join("-".join(item) for item in would_install_items),
361365
)
362-
]
363-
if items:
364-
write_output("Would install %s", " ".join(items))
365366
return SUCCESS
366367

367368
try:

0 commit comments

Comments
 (0)