Skip to content

Commit

Permalink
Use comprehension instead of builder pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr authored Sep 27, 2023
1 parent e9bc5f3 commit 267716f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/pip/_internal/commands/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,11 @@ def _get_requiring_packages(current_dist: BaseDistribution) -> Iterator[str]:
except KeyError:
continue

requires = set()
# Avoid duplicates in requirements due to environment markers
for req in dist.iter_dependencies():
if req.name not in requires:
requires.add(req.name)
requires = sorted(requires, key=str.lower)
requires = sorted(
# Avoid duplicates in requirements (e.g. due to environment markers).
{req.name for req in dist.iter_dependencies()},
key=str.lower,
)
required_by = sorted(_get_requiring_packages(dist), key=str.lower)

try:
Expand Down

0 comments on commit 267716f

Please sign in to comment.