diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6271a02d66..bcd9c142c1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -58,7 +58,7 @@ repos: # auto format Python codes within docstrings - id: blacken-docs - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.7.4 + rev: v0.8.0 hooks: # lint & attempt to correct failures (e.g. pyupgrade) - id: ruff diff --git a/conda_build/_link.py b/conda_build/_link.py index e8984fcd37..bcb2e5e082 100644 --- a/conda_build/_link.py +++ b/conda_build/_link.py @@ -112,7 +112,8 @@ def create_script(fn): shutil.copy2(src, dst + "-script.py") FILES.append(f"Scripts/{fn}-script.py") shutil.copy2( - join(THIS_DIR, "cli-%d.exe" % (8 * tuple.__itemsize__)), dst + ".exe" + join(THIS_DIR, "cli-%d.exe" % (8 * tuple.__itemsize__)), # noqa: UP031 + dst + ".exe", ) FILES.append(f"Scripts/{fn}.exe") else: diff --git a/conda_build/api.py b/conda_build/api.py index 2b269bf9f9..4dc59d2735 100644 --- a/conda_build/api.py +++ b/conda_build/api.py @@ -428,14 +428,14 @@ def inspect_prefix_length(packages, min_prefix_length=_prefix_length): prefix_lengths = check_prefix_lengths(packages, config) if prefix_lengths: print( - "Packages with binary prefixes shorter than %d characters:" + "Packages with binary prefixes shorter than %d characters:" # noqa: UP031 % min_prefix_length ) for fn, length in prefix_lengths.items(): print(f"{fn} ({length} chars)") else: print( - "No packages found with binary prefixes shorter than %d characters." + "No packages found with binary prefixes shorter than %d characters." # noqa: UP031 % min_prefix_length ) return len(prefix_lengths) == 0 diff --git a/conda_build/os_utils/macho.py b/conda_build/os_utils/macho.py index 8e02c8ee86..fd3ed7cbbc 100644 --- a/conda_build/os_utils/macho.py +++ b/conda_build/os_utils/macho.py @@ -294,7 +294,7 @@ def add_rpath(path, rpath, build_prefix=None, verbose=False): else: print(stderr, file=sys.stderr) if code: - raise RuntimeError("install_name_tool failed with exit status %d" % code) + raise RuntimeError("install_name_tool failed with exit status %d" % code) # noqa: UP031 def delete_rpath(path, rpath, build_prefix=None, verbose=False): @@ -312,7 +312,7 @@ def delete_rpath(path, rpath, build_prefix=None, verbose=False): else: print(stderr, file=sys.stderr) if code: - raise RuntimeError("install_name_tool failed with exit status %d" % code) + raise RuntimeError("install_name_tool failed with exit status %d" % code) # noqa: UP031 def install_name_change(path, build_prefix, cb_func, dylibs, verbose=False): @@ -348,7 +348,7 @@ def install_name_change(path, build_prefix, cb_func, dylibs, verbose=False): print(stderr, file=sys.stderr) if code: raise RuntimeError( - "install_name_tool failed with exit status %d, stderr of:\n%s" + "install_name_tool failed with exit status %d, stderr of:\n%s" # noqa: UP031 % (code, stderr) ) return ret diff --git a/conda_build/os_utils/pyldd.py b/conda_build/os_utils/pyldd.py index ff48d5f891..4dabe78fce 100644 --- a/conda_build/os_utils/pyldd.py +++ b/conda_build/os_utils/pyldd.py @@ -188,7 +188,7 @@ def __init__(self, fileobj, start=0, size=maxint): self._pos = 0 def __repr__(self): - return "" % (self._start, self._end, self._fileobj) + return "" % (self._start, self._end, self._fileobj) # noqa: UP031 def tell(self): return self._pos @@ -196,7 +196,7 @@ def tell(self): def _checkwindow(self, seekto, op): if not (self._start <= seekto <= self._end): raise OSError( - "%s to offset %d is outside window [%d, %d]" + "%s to offset %d is outside window [%d, %d]" # noqa: UP031 % (op, seekto, self._start, self._end) ) diff --git a/conda_build/skeletons/pypi.py b/conda_build/skeletons/pypi.py index 6e33af5d89..f3285c4250 100644 --- a/conda_build/skeletons/pypi.py +++ b/conda_build/skeletons/pypi.py @@ -326,7 +326,7 @@ def skeletonize( if pypi_resp.status_code != 200: sys.exit( - "Request to fetch %s failed with status: %d" + "Request to fetch %s failed with status: %d" # noqa: UP031 % (package_pypi_url, pypi_resp.status_code) ) @@ -658,7 +658,7 @@ def get_download_data( if manual_url: for i, url in enumerate(urls): print( - "%d: %s (%s) %s" + "%d: %s (%s) %s" # noqa: UP031 % (i, url["url"], human_bytes(url["size"]), url["comment_text"]) ) n = int(input("which version should i use? ")) diff --git a/tests/cli/test_main_build.py b/tests/cli/test_main_build.py index 8388eb020a..79525f5547 100644 --- a/tests/cli/test_main_build.py +++ b/tests/cli/test_main_build.py @@ -80,7 +80,7 @@ def test_no_filename_hash(testing_workdir, testing_metadata, capfd): args = ["--output", testing_workdir, "--old-build-string"] main_render.execute(args) output, error = capfd.readouterr() - assert not re.search("h[0-9a-f]{%d}" % testing_metadata.config.hash_length, output) + assert not re.search("h[0-9a-f]{%d}" % testing_metadata.config.hash_length, output) # noqa: UP031 args = [ "--no-anaconda-upload", @@ -92,11 +92,11 @@ def test_no_filename_hash(testing_workdir, testing_metadata, capfd): main_build.execute(args) output, error = capfd.readouterr() assert not re.search( - "test_no_filename_hash.*h[0-9a-f]{%d}" % testing_metadata.config.hash_length, + "test_no_filename_hash.*h[0-9a-f]{%d}" % testing_metadata.config.hash_length, # noqa: UP031 output, ) assert not re.search( - "test_no_filename_hash.*h[0-9a-f]{%d}" % testing_metadata.config.hash_length, + "test_no_filename_hash.*h[0-9a-f]{%d}" % testing_metadata.config.hash_length, # noqa: UP031 error, ) diff --git a/tests/test_variants.py b/tests/test_variants.py index 572d6362bf..c609b0033a 100644 --- a/tests/test_variants.py +++ b/tests/test_variants.py @@ -473,7 +473,8 @@ def test_reduced_hashing_behavior(testing_config): "c_compiler" in metadata.get_hash_contents() ), "hash contents should contain c_compiler" assert re.search( - "h[0-9a-f]{%d}" % testing_config.hash_length, metadata.build_id() + "h[0-9a-f]{%d}" % testing_config.hash_length, # noqa: UP031 + metadata.build_id(), ), "hash should be present when compiler jinja2 function is used" # recipes that use some variable in conda_build_config.yaml to control what @@ -486,7 +487,7 @@ def test_reduced_hashing_behavior(testing_config): bypass_env_check=True, )[0][0] assert "zlib" in metadata.get_hash_contents() - assert re.search("h[0-9a-f]{%d}" % testing_config.hash_length, metadata.build_id()) + assert re.search("h[0-9a-f]{%d}" % testing_config.hash_length, metadata.build_id()) # noqa: UP031 # anything else does not get a hash metadata = api.render( @@ -496,7 +497,8 @@ def test_reduced_hashing_behavior(testing_config): )[0][0] assert not metadata.get_hash_contents() assert not re.search( - "h[0-9a-f]{%d}" % testing_config.hash_length, metadata.build_id() + "h[0-9a-f]{%d}" % testing_config.hash_length, # noqa: UP031 + metadata.build_id(), )