From af5bb88319e020729fccd42743a7aab5c1c6091a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 20:58:41 +0000 Subject: [PATCH 1/4] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.15.22 → v0.16.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.22...v0.16.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e324dd..2f2c6bd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: exclude_types: [javascript,json] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.22 + rev: v0.16.0 hooks: - id: ruff-check args: [--fix] From b63f21e973732d696275d6981ab56210442ca0ca Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 20:58:49 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/create_markdown.py | 2 +- test/conftest.py | 2 +- test/conftest_wasm.py | 13 ++++++------- test/test_clone.py | 4 +++- test/test_fixtures.py | 1 + test/test_git.py | 4 +++- wasm/recipe/modify-recipe.py | 4 ++-- 7 files changed, 17 insertions(+), 13 deletions(-) diff --git a/docs/create_markdown.py b/docs/create_markdown.py index 8bc3c87..344f7ae 100644 --- a/docs/create_markdown.py +++ b/docs/create_markdown.py @@ -1,7 +1,7 @@ import os -from pathlib import Path import re import subprocess +from pathlib import Path def get_filename(args): diff --git a/test/conftest.py b/test/conftest.py index d521b5d..10c2181 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -8,7 +8,7 @@ GIT2CPP_TEST_WASM = os.getenv("GIT2CPP_TEST_WASM") == "1" if GIT2CPP_TEST_WASM: - from .conftest_wasm import * # noqa: F403 + from .conftest_wasm import * # Fixture to run test in current tmp_path diff --git a/test/conftest_wasm.py b/test/conftest_wasm.py index d8763e0..d866f70 100644 --- a/test/conftest_wasm.py +++ b/test/conftest_wasm.py @@ -1,12 +1,13 @@ # Extra fixtures used for wasm testing, including some that override the default pytest fixtures. -from functools import partial import os import pathlib -from playwright.sync_api import Page -import pytest import re import subprocess import time +from functools import partial + +import pytest +from playwright.sync_api import Page # Only include particular test files when testing wasm. @@ -94,8 +95,7 @@ def read_bytes(self) -> bytes: def read_text(self) -> str: p = subprocess.run(["cat", str(self)], capture_output=True, text=True, check=True) text = p.stdout - if text.endswith("\n"): - text = text[:-1] + text = text.removesuffix("\n") return text def write_bytes(self, data: bytes): @@ -110,8 +110,7 @@ def write_text(self, data: str): # Note that in general it is not valid to direct output of a subprocess.run call to a file, # but we get away with it here as the command arguments are passed straight through to # cockle without being checked. - if data.endswith("\n"): - data = data[:-1] + data = data.removesuffix("\n") cmd = ["echo", data, ">", str(self)] subprocess.run(cmd, capture_output=True, text=True, check=True) return len(data) diff --git a/test/test_clone.py b/test/test_clone.py index 1f81f33..e172489 100644 --- a/test/test_clone.py +++ b/test/test_clone.py @@ -1,5 +1,7 @@ -import pytest import subprocess + +import pytest + from .conftest import GIT2CPP_TEST_WASM xtl_url = "https://github.com/xtensor-stack/xtl.git" diff --git a/test/test_fixtures.py b/test/test_fixtures.py index 14bd925..721694a 100644 --- a/test/test_fixtures.py +++ b/test/test_fixtures.py @@ -2,6 +2,7 @@ import re import subprocess + from .conftest import GIT2CPP_TEST_WASM diff --git a/test/test_git.py b/test/test_git.py index 212ae94..2c803e7 100644 --- a/test/test_git.py +++ b/test/test_git.py @@ -1,6 +1,8 @@ -import pytest import re import subprocess + +import pytest + from .conftest import GIT2CPP_TEST_WASM diff --git a/wasm/recipe/modify-recipe.py b/wasm/recipe/modify-recipe.py index 9f85be1..9e61a5d 100644 --- a/wasm/recipe/modify-recipe.py +++ b/wasm/recipe/modify-recipe.py @@ -2,10 +2,10 @@ # This can be called repeatedly and will produce the same output. import argparse -from pathlib import Path import shutil -import yaml +from pathlib import Path +import yaml parser = argparse.ArgumentParser() parser.add_argument("input_directory", type=Path) From 7b90fde7c0105ad4a517ad19916801f166ffa3ba Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Tue, 28 Jul 2026 08:15:44 +0100 Subject: [PATCH 3/4] Fixes --- docs/conf.py | 4 ++-- pyproject.toml | 6 ++++++ test/conftest_wasm.py | 2 +- test/test_clone.py | 2 +- test/test_init.py | 8 ++++---- test/test_log.py | 2 +- test/test_remote.py | 4 ++-- wasm/recipe/modify-recipe.py | 5 +++-- 8 files changed, 20 insertions(+), 13 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 9b2109b..34fcb46 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,8 +1,8 @@ -from datetime import date +from datetime import UTC, datetime project = "git2cpp" author = "QuantStack" -copyright = f"2025-{date.today().year}" +copyright = f"2025-{datetime.now(UTC).year}" extensions = [ "myst_parser", diff --git a/pyproject.toml b/pyproject.toml index 90d4005..e68881b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,5 +2,11 @@ [tool.ruff] line-length = 100 target-version = "py312" + [tool.ruff.format] line-ending = "lf" + +[tool.ruff.lint] +ignore = [ + "PLW1510" +] diff --git a/test/conftest_wasm.py b/test/conftest_wasm.py index d866f70..cc9c0eb 100644 --- a/test/conftest_wasm.py +++ b/test/conftest_wasm.py @@ -101,7 +101,7 @@ def read_text(self) -> str: def write_bytes(self, data: bytes): # Convert binary data to a string where each element is backslash-escaped so that we can # write to file in cockle using `echo -e `. - encoded_string = "".join(map(lambda d: f"\\x{d:02x}", data)) + encoded_string = "".join(lambda d: f"\\x{d:02x}", data) cmd = ["echo", "-e", encoded_string, ">", str(self)] subprocess.run(cmd, capture_output=True, text=True, check=True) return len(data) diff --git a/test/test_clone.py b/test/test_clone.py index e172489..bf4fe31 100644 --- a/test/test_clone.py +++ b/test/test_clone.py @@ -79,7 +79,7 @@ def test_clone_private_repo_fails_then_succeeds( # Fails with wrong credentials, then succeeds with correct ones. username = "xyz" # Can be any non-empty string. password = private_test_repo["token"] - input = "\n".join(["wrong1", "wrong2", username, password]) + "\n" + input = f"wrong1\nwrong2\n{username}\n{password}" repo_path = tmp_path / private_test_repo["repo_name"] clone_cmd = [git2cpp_path, "clone", private_test_repo["https_url"]] diff --git a/test/test_init.py b/test/test_init.py index 9a66188..9183780 100644 --- a/test/test_init.py +++ b/test/test_init.py @@ -12,7 +12,7 @@ def test_init_in_directory(git2cpp_path, tmp_path): assert p.stdout.startswith("Initialized empty Git repository in ") assert p.stdout.strip().endswith("/") - assert sorted(map(lambda path: path.name, tmp_path.iterdir())) == [ + assert sorted(path.name for path in tmp_path.iterdir()) == [ "HEAD", "config", "description", @@ -36,7 +36,7 @@ def test_init_in_cwd(git2cpp_path, tmp_path, run_in_tmp_path): assert p.stdout.startswith("Initialized empty Git repository in ") assert p.stdout.strip().endswith("/") - assert sorted(map(lambda path: path.name, tmp_path.iterdir())) == [ + assert sorted(path.name for path in tmp_path.iterdir()) == [ "HEAD", "config", "description", @@ -60,9 +60,9 @@ def test_init_not_bare(git2cpp_path, tmp_path): assert p.stdout.strip().endswith(".git/") # Directory contains just .git directory. - assert sorted(map(lambda path: path.name, tmp_path.iterdir())) == [".git"] + assert sorted(path.name for path in tmp_path.iterdir()) == [".git"] # .git directory is a valid repo. - assert sorted(map(lambda path: path.name, (tmp_path / ".git").iterdir())) == [ + assert sorted(path.name for path in (tmp_path / ".git").iterdir()) == [ "HEAD", "config", "description", diff --git a/test/test_log.py b/test/test_log.py index 87f81e7..2c3611e 100644 --- a/test/test_log.py +++ b/test/test_log.py @@ -256,7 +256,7 @@ def test_log_commit_without_references(commit_env_config, git2cpp_path, tmp_path # First commit line should have references lines = strip_ansi_colours(p_log.stdout).split("\n") - first_commit_line = [line for line in lines if line.startswith("commit")][0] + first_commit_line = next(line for line in lines if line.startswith("commit")) assert "(" in first_commit_line # Has references # Second commit (older one) should not have empty parentheses diff --git a/test/test_remote.py b/test/test_remote.py index b818676..1ed8597 100644 --- a/test/test_remote.py +++ b/test/test_remote.py @@ -297,7 +297,7 @@ def repo_with_remote(git2cpp_path, tmp_path, run_in_tmp_path): def test_fetch_from_remote(git2cpp_path, repo_with_remote): """Test fetching from a remote.""" - local_path, remote_path = repo_with_remote + local_path, _remote_path = repo_with_remote # Note: This is a bare repo with no refs, so fetch will fail gracefully # For now, just test that /stdofetch command runs (it will fail gracefully if no refs) @@ -309,7 +309,7 @@ def test_fetch_from_remote(git2cpp_path, repo_with_remote): def test_fetch_default_origin(git2cpp_path, repo_with_remote): """Test fetching with default origin.""" - local_path, remote_path = repo_with_remote + local_path, _remote_path = repo_with_remote cmd = [git2cpp_path, "fetch"] p = subprocess.run(cmd, capture_output=True, text=True, cwd=local_path) diff --git a/wasm/recipe/modify-recipe.py b/wasm/recipe/modify-recipe.py index 9e61a5d..7cddcfc 100644 --- a/wasm/recipe/modify-recipe.py +++ b/wasm/recipe/modify-recipe.py @@ -3,6 +3,7 @@ import argparse import shutil +import sys from pathlib import Path import yaml @@ -14,11 +15,11 @@ input_dir = args.input_directory if not input_dir.is_dir(): - quit(f"{input_dir} should exist and be a directory") + sys.exit(f"{input_dir} should exist and be a directory") input_filename = input_dir / "recipe.yaml" if not input_filename.is_file(): - quit(f"{input_filename} should exist and be a file") + sys.exit(f"{input_filename} should exist and be a file") # If backup does not exist create it. input_backup = input_dir / "recipe_original.yaml" From 820ee8899bffa211efcc56acc5e77bc1f5f58a27 Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Tue, 28 Jul 2026 09:46:16 +0100 Subject: [PATCH 4/4] Fix --- test/conftest_wasm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/conftest_wasm.py b/test/conftest_wasm.py index cc9c0eb..b2bb204 100644 --- a/test/conftest_wasm.py +++ b/test/conftest_wasm.py @@ -101,7 +101,7 @@ def read_text(self) -> str: def write_bytes(self, data: bytes): # Convert binary data to a string where each element is backslash-escaped so that we can # write to file in cockle using `echo -e `. - encoded_string = "".join(lambda d: f"\\x{d:02x}", data) + encoded_string = "".join(f"\\x{d:02x}" for d in data) cmd = ["echo", "-e", encoded_string, ">", str(self)] subprocess.run(cmd, capture_output=True, text=True, check=True) return len(data)