-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Format and lint Python code with ruff
- Loading branch information
Showing
2 changed files
with
25 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,43 @@ | ||
#!/usr/bin/env python | ||
""" Filter out wheel filenames not supported on this platform | ||
""" | ||
from __future__ import print_function | ||
"""Filter out wheel filenames not supported on this platform.""" | ||
|
||
from __future__ import annotations | ||
|
||
import sys | ||
from os.path import basename | ||
from typing import TYPE_CHECKING | ||
|
||
from packaging.tags import sys_tags | ||
|
||
if TYPE_CHECKING: | ||
from collections.abc import Iterator | ||
|
||
try: | ||
from wheel.install import WHEEL_INFO_RE as wheel_matcher | ||
from wheel.install import WHEEL_INFO_RE as wheel_matcher # noqa: N811 | ||
except ImportError: # As of Wheel 0.32.0 | ||
from wheel.wheelfile import WHEEL_INFO_RE | ||
|
||
wheel_matcher = WHEEL_INFO_RE.match | ||
|
||
|
||
def tags_for(fname): | ||
# Copied from WheelFile code | ||
parsed_filename = wheel_matcher(basename(fname)) | ||
def tags_for(fname: str) -> Iterator[tuple[str, str, str]]: | ||
"""Copied from WheelFile code.""" # noqa: D401 | ||
parsed_filename = wheel_matcher(basename(fname)) # noqa: PTH119 | ||
tags = parsed_filename.groupdict() | ||
for pyver in tags['pyver'].split('.'): | ||
for abi in tags['abi'].split('.'): | ||
for plat in tags['plat'].split('.'): | ||
for pyver in tags["pyver"].split("."): | ||
for abi in tags["abi"].split("."): | ||
for plat in tags["plat"].split("."): | ||
yield (pyver, abi, plat) | ||
|
||
|
||
def main(): | ||
supported = { | ||
(tag.interpreter, tag.abi, tag.platform) for tag in sys_tags() | ||
} | ||
def main() -> None: | ||
"""Print filenames of all supported wheels.""" | ||
supported = {(tag.interpreter, tag.abi, tag.platform) for tag in sys_tags()} | ||
for fname in sys.argv[1:]: | ||
tags = set(tags_for(fname)) | ||
if supported.intersection(tags): | ||
print(fname) | ||
print(fname) # noqa: T201 | ||
|
||
|
||
if __name__ == '__main__': | ||
if __name__ == "__main__": | ||
main() |