Skip to content

Commit

Permalink
Apply ruff/Perflint rule PERF401
Browse files Browse the repository at this point in the history
PERF401 Use a list comprehension to create a transformed list
  • Loading branch information
DimitriPapadopoulos committed Aug 24, 2024
1 parent 7bb46d7 commit a2bf5b9
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/wheel/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,14 @@ def safe_name(name: str) -> str:
def requires_to_requires_dist(requirement: Requirement) -> str:
"""Return the version specifier for a requirement in PEP 345/566 fashion."""
if requirement.url:
return " @ " + requirement.url
return f" @ {requirement.url}"

requires_dist: list[str] = []
for spec in requirement.specifier:
requires_dist.append(spec.operator + spec.version)
if requirement.specifier:
return " " + ",".join(
sorted(spec.operator + spec.version for spec in requirement.specifier)
)

if requires_dist:
return " " + ",".join(sorted(requires_dist))
else:
return ""
return ""


def convert_requirements(requirements: list[str]) -> Iterator[str]:
Expand Down

0 comments on commit a2bf5b9

Please sign in to comment.