From 0b7771e6bc46b8905d8b6c02d8f825bbf9623cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Wed, 8 May 2024 13:43:47 +0300 Subject: [PATCH] Updated pre-commit modules and applied ruff fixes Closes #615. --- .pre-commit-config.yaml | 4 ++-- src/wheel/bdist_wheel.py | 7 +++---- src/wheel/cli/__init__.py | 2 +- src/wheel/cli/convert.py | 4 ++-- src/wheel/metadata.py | 2 +- tests/test_bdist_wheel.py | 2 +- tests/test_tagopt.py | 2 +- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ce76788a..84c68b37 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ exclude: ^src/wheel/vendored repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -18,7 +18,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.5 + rev: v0.4.3 hooks: - id: ruff args: [--fix, --show-fixes] diff --git a/src/wheel/bdist_wheel.py b/src/wheel/bdist_wheel.py index dbcc6985..3cc7165e 100644 --- a/src/wheel/bdist_wheel.py +++ b/src/wheel/bdist_wheel.py @@ -179,7 +179,7 @@ class bdist_wheel(Command): "plat-name=", "p", "platform name to embed in generated filenames " - "(default: %s)" % get_platform(None), + f"(default: {get_platform(None)})", ), ( "keep-temp", @@ -215,8 +215,7 @@ class bdist_wheel(Command): ( "python-tag=", None, - "Python implementation compatibility tag" - " (default: '%s')" % (python_tag()), + f"Python implementation compatibility tag (default: '{python_tag()}')", ), ( "build-number=", @@ -282,7 +281,7 @@ def finalize_options(self): if self.py_limited_api and not re.match( PY_LIMITED_API_PATTERN, self.py_limited_api ): - raise ValueError("py-limited-api must match '%s'" % PY_LIMITED_API_PATTERN) + raise ValueError(f"py-limited-api must match '{PY_LIMITED_API_PATTERN}'") # Support legacy [wheel] section for setting universal wheel = self.distribution.get_option_dict("wheel") diff --git a/src/wheel/cli/__init__.py b/src/wheel/cli/__init__.py index a828caad..6ba1217f 100644 --- a/src/wheel/cli/__init__.py +++ b/src/wheel/cli/__init__.py @@ -54,7 +54,7 @@ def tags_f(args: argparse.Namespace) -> None: def version_f(args: argparse.Namespace) -> None: from .. import __version__ - print("wheel %s" % __version__) + print(f"wheel {__version__}") def parse_build_tag(build_tag: str) -> str: diff --git a/src/wheel/cli/convert.py b/src/wheel/cli/convert.py index 4c23560d..46fdf1eb 100644 --- a/src/wheel/cli/convert.py +++ b/src/wheel/cli/convert.py @@ -189,7 +189,7 @@ def wininst2wheel(path: str, dest_dir: str) -> None: paths = {"platlib": ""} dist_info = "{name}-{ver}".format(**info) - datadir = "%s.data/" % dist_info + datadir = f"{dist_info}.data/" # rewrite paths to trick ZipFile into extracting an egg # XXX grab wininst .ini - between .exe, padding, and first zip file. @@ -246,7 +246,7 @@ def wininst2wheel(path: str, dest_dir: str) -> None: bw.full_tag_supplied = True bw.full_tag = (pyver, abi, arch) - dist_info_dir = os.path.join(dir, "%s.dist-info" % dist_info) + dist_info_dir = os.path.join(dir, f"{dist_info}.dist-info") bw.egg2dist(os.path.join(dir, egginfo_name), dist_info_dir) bw.write_wheelfile(dist_info_dir, generator="wininst2wheel") diff --git a/src/wheel/metadata.py b/src/wheel/metadata.py index 01c4dab5..b8098fa8 100644 --- a/src/wheel/metadata.py +++ b/src/wheel/metadata.py @@ -133,7 +133,7 @@ def generate_requirements( yield "Provides-Extra", extra if condition: condition = "(" + condition + ") and " - condition += "extra == '%s'" % extra + condition += f"extra == '{extra}'" if condition: condition = " ; " + condition diff --git a/tests/test_bdist_wheel.py b/tests/test_bdist_wheel.py index 53aa418b..84ead451 100644 --- a/tests/test_bdist_wheel.py +++ b/tests/test_bdist_wheel.py @@ -427,7 +427,7 @@ def test_platform_linux32(reported, expected, monkeypatch): def test_no_ctypes(monkeypatch) -> None: def _fake_import(name: str, *args, **kwargs): if name == "ctypes": - raise ModuleNotFoundError("No module named %s" % name) + raise ModuleNotFoundError(f"No module named {name}") return importlib.__import__(name, *args, **kwargs) diff --git a/tests/test_tagopt.py b/tests/test_tagopt.py index 677f7044..5335af44 100644 --- a/tests/test_tagopt.py +++ b/tests/test_tagopt.py @@ -33,7 +33,7 @@ def temp_pkg(request, tmp_path): if ext[0]: # if ext[1] is not '', it will write a bad header and fail to compile tmp_path.joinpath("test.c").write_text( - "#include " % ext[1], encoding="utf-8" + f"#include ", encoding="utf-8" ) setup_py = SETUP_PY.format(ext_modules=EXT_MODULES) else: