Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply more ruff rules #633

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,14 @@ extend-exclude = ["src/wheel/vendored"]
[tool.ruff.lint]
extend-select = [
"B", # flake8-bugbear
"FLY", # flynt
"G", # flake8-logging-format
"I", # isort
"ISC", # flake8-implicit-str-concat
"PERF", # Perflint
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PLC", # Pylint
"RUF100", # unused noqa (yesqa)
"UP", # pyupgrade
"W", # pycodestyle warnings
Expand Down
2 changes: 1 addition & 1 deletion src/wheel/_bdist_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@
for impl in impl_tag.split("."):
for abi in abi_tag.split("."):
for plat in plat_tag.split("."):
msg["Tag"] = "-".join((impl, abi, plat))
msg["Tag"] = f"{impl}-{abi}-{plat}"

Check warning on line 485 in src/wheel/_bdist_wheel.py

View check run for this annotation

Codecov / codecov/patch

src/wheel/_bdist_wheel.py#L485

Added line #L485 was not covered by tests

wheelfile_path = os.path.join(wheelfile_base, "WHEEL")
log.info(f"creating {wheelfile_path}")
Expand Down
2 changes: 1 addition & 1 deletion src/wheel/macosx_libfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def calculate_macosx_platform_tag(archive_root: StrPath, platform_tag: str) -> s
versions_dict: dict[str, tuple[int, int]] = {}
for dirpath, _dirnames, filenames in os.walk(archive_root):
for filename in filenames:
if filename.endswith(".dylib") or filename.endswith(".so"):
if filename.endswith((".dylib", ".so")):
lib_path = os.path.join(dirpath, filename)
min_ver = extract_macosx_min_system_version(lib_path)
if min_ver is not None:
Expand Down
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
2 changes: 1 addition & 1 deletion tests/test_bdist_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def test_licenses_override(dummy_dist, monkeypatch, tmp_path, config_file, confi
)
with WheelFile("dist/dummy_dist-1.0-py2.py3-none-any.whl") as wf:
license_files = {
"dummy_dist-1.0.dist-info/" + fname for fname in {"DUMMYFILE", "LICENSE"}
"dummy_dist-1.0.dist-info/" + fname for fname in ("DUMMYFILE", "LICENSE")
}
assert set(wf.namelist()) == DEFAULT_FILES | license_files

Expand Down
Loading