From e16ec2decc6d02ca83a441beaa91ec357ae8dbac Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Fri, 10 May 2024 21:27:33 +0200 Subject: [PATCH] Attempt for improvment based on review --- src/packaging/tags.py | 22 +++++++++++----------- tasks/check.py | 33 +++++++++++++++++++++++---------- tests/test_requirements.py | 2 +- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/packaging/tags.py b/src/packaging/tags.py index d1e12d29..bbc733a5 100644 --- a/src/packaging/tags.py +++ b/src/packaging/tags.py @@ -434,20 +434,22 @@ def mac_platforms( if (10, 0) <= version and version < (11, 0): # Prior to Mac OS 11, each yearly release of Mac OS bumped the # "minor" version number. The major version was always 10. + major_version = 10 for minor_version in range(version[1], -1, -1): - compat_version = 10, minor_version + compat_version = major_version, minor_version binary_formats = _mac_binary_formats(compat_version, arch) for binary_format in binary_formats: - yield f"macosx_10_{minor_version}_{binary_format}" + yield f"macosx_{major_version}_{minor_version}_{binary_format}" if version >= (11, 0): # Starting with Mac OS 11, each yearly release bumps the major version # number. The minor versions are now the midyear updates. + minor_version = 0 for major_version in range(version[0], 10, -1): - compat_version = major_version, 0 + compat_version = major_version, minor_version binary_formats = _mac_binary_formats(compat_version, arch) for binary_format in binary_formats: - yield f"macosx_{major_version}_0_{binary_format}" + yield f"macosx_{major_version}_{minor_version}_{binary_format}" if version >= (11, 0): # Mac OS 11 on x86_64 is compatible with binaries from previous releases. @@ -457,20 +459,18 @@ def mac_platforms( # However, the "universal2" binary format can have a # macOS version earlier than 11.0 when the x86_64 part of the binary supports # that version of macOS. + major_version = 10 if arch == "x86_64": for minor_version in range(16, 3, -1): - compat_version = 10, minor_version + compat_version = major_version, minor_version binary_formats = _mac_binary_formats(compat_version, arch) for binary_format in binary_formats: - yield ( - f"macosx_{compat_version[0]}_{compat_version[1]}" - f"_{binary_format}" - ) + yield f"macosx_{major_version}_{minor_version}_{binary_format}" else: for minor_version in range(16, 3, -1): - compat_version = 10, minor_version + compat_version = major_version, minor_version binary_format = "universal2" - yield f"macosx_{compat_version[0]}_{compat_version[1]}_{binary_format}" + yield f"macosx_{major_version}_{minor_version}_{binary_format}" def _linux_platforms(is_32bit: bool = _32_BIT_INTERPRETER) -> Iterator[str]: diff --git a/tasks/check.py b/tasks/check.py index 2c99a5ac..b8f89e65 100644 --- a/tasks/check.py +++ b/tasks/check.py @@ -107,22 +107,35 @@ def pep440(cached=False): # Print out our findings print( - f"Total Version Compatibility: {len(parsed_versions)}/" - f"{len(all_versions)} ({len(parsed_versions) / len(all_versions):.2%})" + "Total Version Compatibility: {}/{} ({:.2%})".format( # noqa: UP032 + len(parsed_versions), + len(all_versions), + len(parsed_versions) / len(all_versions), + ) ) print( - f"Total Sorting Compatibility (Unfiltered): {len(compatible_sorting)}/" - f"{len(data)} ({len(compatible_sorting) / len(data):.2%})" + "Total Sorting Compatibility (Unfiltered): {}/{} ({:.2%})".format( # noqa: UP032 + len(compatible_sorting), len(data), len(compatible_sorting) / len(data) + ) ) print( - f"Total Sorting Compatibility (Filtered): {len(filtered_compatible_sorting)}/" - f"{len(data)} ({len(filtered_compatible_sorting) / len(data):.2%})" + "Total Sorting Compatibility (Filtered): {}/{} ({:.2%})".format( # noqa: UP032 + len(filtered_compatible_sorting), + len(data), + len(filtered_compatible_sorting) / len(data), + ) ) print( - f"Projects with No Compatible Versions: {len(only_invalid_versions)}/" - f"{len(data)} ({len(only_invalid_versions) / len(data):.2%})" + "Projects with No Compatible Versions: {}/{} ({:.2%})".format( # noqa: UP032 + len(only_invalid_versions), + len(data), + len(only_invalid_versions) / len(data), + ) ) print( - f"Projects with Differing Latest Version: {len(differing_latest_versions)}/" - f"{len(data)} ({len(differing_latest_versions) / len(data):.2%})" + "Projects with Differing Latest Version: {}/{} ({:.2%})".format( # noqa: UP032 + len(differing_latest_versions), + len(data), + len(differing_latest_versions) / len(data), + ) ) diff --git a/tests/test_requirements.py b/tests/test_requirements.py index 4a9745bb..9b90e52b 100644 --- a/tests/test_requirements.py +++ b/tests/test_requirements.py @@ -118,7 +118,7 @@ def test_basic_valid_requirement_parsing( parts = [name] if extras: parts.append("[") - parts.append(f"{whitespace},{whitespace}".join(sorted(extras))) + parts.append("{ws},{ws}".format(ws=whitespace).join(sorted(extras))) # noqa: UP032 parts.append("]") if specifier: parts.append(specifier.format(ws=whitespace))