Skip to content
Merged
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
8 changes: 6 additions & 2 deletions validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from collections.abc import Mapping
from typing import NamedTuple

import packaging.tags
from packaging.tags import Tag
from packaging.utils import parse_wheel_filename
from packaging.version import Version
Expand Down Expand Up @@ -53,8 +54,11 @@ def _pythons_to_check(tags: frozenset[Tag]) -> tuple[str, ...]:
ret.add(_py_exe(*_parse_cp_tag(tag.interpreter)))
elif tag.interpreter == "py2":
continue
elif tag.interpreter == "py3":
ret.update(_py_exe(*py) for py in PYTHONS)
elif tag.interpreter.startswith("py3"):
for py in PYTHONS:
if tag not in packaging.tags.compatible_tags(py):
raise AssertionError(f"{tag} is not compatible with python {py}")
ret.update(_py_exe(*py) for py in PYTHONS)
Comment on lines +59 to +61

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential bug: The logic for py3 tags incorrectly raises an AssertionError on incompatibility, causing crashes, and also redundantly adds all Python versions to the result set on each successful check.
  • Description: The logic for handling tags starting with py3 is flawed in two ways. First, it raises an AssertionError if a version-specific tag (e.g., py311-none-any) is found to be incompatible with any of the Python versions being checked (e.g., 3.12), causing the validation to crash for valid wheels. Second, if a tag is compatible, the code proceeds to add all Python versions to the result set via ret.update(_py_exe(*py) for py in PYTHONS). This ignores the specific version py that was just checked and leads to redundant operations within the loop.

  • Suggested fix: The loop should be refactored to only add Python versions that are compatible with the tag, without raising an error for incompatibilities. This can be achieved by checking for compatibility and then using ret.add(_py_exe(*py)) to add only the specific matching version py inside the conditional block.
    severity: 0.85, confidence: 0.99

Did we get this right? 👍 / 👎 to inform future reviews.

else:
raise AssertionError(f"unexpected tag: {tag}")

Expand Down
Loading