diff --git a/pyproject.toml b/pyproject.toml index 95ad20a6..93c814c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,6 @@ ignore = [ "B028", "B904", "N818", - "UP032", # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules "W191", "E111", diff --git a/src/packaging/markers.py b/src/packaging/markers.py index 2d60bdf2..93cbf90f 100644 --- a/src/packaging/markers.py +++ b/src/packaging/markers.py @@ -232,7 +232,7 @@ def _evaluate_markers(markers: MarkerList, environment: dict[str, str]) -> bool: def format_full_version(info: sys._version_info) -> str: - version = "{0.major}.{0.minor}.{0.micro}".format(info) + version = f"{info.major}.{info.minor}.{info.micro}" kind = info.releaselevel if kind != "final": version += kind[0] + str(info.serial) diff --git a/src/packaging/tags.py b/src/packaging/tags.py index 6667d299..d1e12d29 100644 --- a/src/packaging/tags.py +++ b/src/packaging/tags.py @@ -235,9 +235,8 @@ def cpython_tags( if use_abi3: for minor_version in range(python_version[1] - 1, 1, -1): for platform_ in platforms: - interpreter = "cp{version}".format( - version=_version_nodot((python_version[0], minor_version)) - ) + version = _version_nodot((python_version[0], minor_version)) + interpreter = f"cp{version}" yield Tag(interpreter, "abi3", platform_) @@ -439,9 +438,7 @@ def mac_platforms( compat_version = 10, minor_version binary_formats = _mac_binary_formats(compat_version, arch) for binary_format in binary_formats: - yield "macosx_{major}_{minor}_{binary_format}".format( - major=10, minor=minor_version, binary_format=binary_format - ) + yield f"macosx_10_{minor_version}_{binary_format}" if version >= (11, 0): # Starting with Mac OS 11, each yearly release bumps the major version @@ -450,9 +447,7 @@ def mac_platforms( compat_version = major_version, 0 binary_formats = _mac_binary_formats(compat_version, arch) for binary_format in binary_formats: - yield "macosx_{major}_{minor}_{binary_format}".format( - major=major_version, minor=0, binary_format=binary_format - ) + yield f"macosx_{major_version}_0_{binary_format}" if version >= (11, 0): # Mac OS 11 on x86_64 is compatible with binaries from previous releases. @@ -467,20 +462,15 @@ def mac_platforms( compat_version = 10, minor_version binary_formats = _mac_binary_formats(compat_version, arch) for binary_format in binary_formats: - yield "macosx_{major}_{minor}_{binary_format}".format( - major=compat_version[0], - minor=compat_version[1], - binary_format=binary_format, + yield ( + f"macosx_{compat_version[0]}_{compat_version[1]}" + f"_{binary_format}" ) else: for minor_version in range(16, 3, -1): compat_version = 10, minor_version binary_format = "universal2" - yield "macosx_{major}_{minor}_{binary_format}".format( - major=compat_version[0], - minor=compat_version[1], - binary_format=binary_format, - ) + yield f"macosx_{compat_version[0]}_{compat_version[1]}_{binary_format}" def _linux_platforms(is_32bit: bool = _32_BIT_INTERPRETER) -> Iterator[str]: diff --git a/tests/test_markers.py b/tests/test_markers.py index e4e8288c..86b41173 100644 --- a/tests/test_markers.py +++ b/tests/test_markers.py @@ -104,7 +104,8 @@ def test_matches_expected(self): iver = "{0.major}.{0.minor}.{0.micro}".format(sys.implementation.version) if sys.implementation.version.releaselevel != "final": iver = ( - f"{iver}{sys.implementation.version.releaselevel[0]}{sys.implementation.version.serial}" + f"{iver}{sys.implementation.version.releaselevel[0]}" + f"{sys.implementation.version.serial}" ) assert environment == { diff --git a/tests/test_requirements.py b/tests/test_requirements.py index 9907b9c9..e64ab4f2 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("{ws},{ws}".format(ws=whitespace).join(sorted(extras))) + parts.append("{whitespace},{whitespace}".join(sorted(extras))) parts.append("]") if specifier: parts.append(specifier.format(ws=whitespace)) diff --git a/tests/test_tags.py b/tests/test_tags.py index 9821fc25..e37de63c 100644 --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -80,9 +80,7 @@ def test_str(self, example_tag): assert str(example_tag) == "py3-none-any" def test_repr(self, example_tag): - assert repr(example_tag) == "".format( - tag_id=id(example_tag) - ) + assert repr(example_tag) == f"" def test_attribute_access(self, example_tag): assert example_tag.interpreter == "py3"