Skip to content

Commit 267716f

Browse files
authored
Use comprehension instead of builder pattern
1 parent e9bc5f3 commit 267716f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/pip/_internal/commands/show.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,11 @@ def _get_requiring_packages(current_dist: BaseDistribution) -> Iterator[str]:
100100
except KeyError:
101101
continue
102102

103-
requires = set()
104-
# Avoid duplicates in requirements due to environment markers
105-
for req in dist.iter_dependencies():
106-
if req.name not in requires:
107-
requires.add(req.name)
108-
requires = sorted(requires, key=str.lower)
103+
requires = sorted(
104+
# Avoid duplicates in requirements (e.g. due to environment markers).
105+
{req.name for req in dist.iter_dependencies()},
106+
key=str.lower,
107+
)
109108
required_by = sorted(_get_requiring_packages(dist), key=str.lower)
110109

111110
try:

0 commit comments

Comments
 (0)