From efabfa78be34461af7c8439ff86151b976a87ae6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 14 Jul 2026 09:23:16 +0100 Subject: [PATCH 1/6] [pre-commit.ci] pre-commit autoupdate (#175) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-clang-format: v22.1.5 → v22.1.8](https://github.com/pre-commit/mirrors-clang-format/compare/v22.1.5...v22.1.8) - [github.com/astral-sh/ruff-pre-commit: v0.15.20 → v0.15.21](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.20...v0.15.21) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8472f9a..e5a1c7d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,14 +17,14 @@ repos: args: ['--py312-plus'] - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v22.1.5 + rev: v22.1.8 hooks: - id: clang-format args: [--style=file] exclude_types: [javascript,json] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.20 + rev: v0.15.21 hooks: - id: ruff-check args: [--fix] From 41877926cb7f6313cba4ed0da34aef443e74c78d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 21 Jul 2026 09:00:55 +0100 Subject: [PATCH 2/6] [pre-commit.ci] pre-commit autoupdate (#176) 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.21 → v0.15.22](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.21...v0.15.22) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .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 e5a1c7d..0e324dd 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.21 + rev: v0.15.22 hooks: - id: ruff-check args: [--fix] From 039d66c7ec9744dd546324f8c40b6492391497da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Jul 2026 09:01:34 +0100 Subject: [PATCH 3/6] Bump actions/setup-python from 6 to 7 in the actions group (#177) Bumps the actions group with 1 update: [actions/setup-python](https://github.com/actions/setup-python). Updates `actions/setup-python` from 6 to 7 - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v6...v7) --- updated-dependencies: - dependency-name: actions/setup-python dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/deploy-wasm.yml | 2 +- .github/workflows/test-wasm.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-wasm.yml b/.github/workflows/deploy-wasm.yml index f75e82a..acff1ac 100644 --- a/.github/workflows/deploy-wasm.yml +++ b/.github/workflows/deploy-wasm.yml @@ -19,7 +19,7 @@ jobs: uses: actions/checkout@v7 - name: Setup Python - uses: actions/setup-python@v6 + uses: actions/setup-python@v7 with: python-version: '3.14' diff --git a/.github/workflows/test-wasm.yml b/.github/workflows/test-wasm.yml index 5bbddc1..59f2230 100644 --- a/.github/workflows/test-wasm.yml +++ b/.github/workflows/test-wasm.yml @@ -17,7 +17,7 @@ jobs: uses: actions/checkout@v7 - name: Setup Python - uses: actions/setup-python@v6 + uses: actions/setup-python@v7 with: python-version: '3.14' From be905197ca65e732299f208a04c1a51d8de6a744 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 28 Jul 2026 10:00:32 +0100 Subject: [PATCH 4/6] [pre-commit.ci] pre-commit autoupdate (#178) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate 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.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fixes * Fix --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ian Thomas --- .pre-commit-config.yaml | 2 +- docs/conf.py | 4 ++-- docs/create_markdown.py | 2 +- pyproject.toml | 6 ++++++ test/conftest.py | 2 +- test/conftest_wasm.py | 15 +++++++-------- test/test_clone.py | 6 ++++-- test/test_fixtures.py | 1 + test/test_git.py | 4 +++- test/test_init.py | 8 ++++---- test/test_log.py | 2 +- test/test_remote.py | 4 ++-- wasm/recipe/modify-recipe.py | 9 +++++---- 13 files changed, 38 insertions(+), 27 deletions(-) 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] 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/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/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.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..b2bb204 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,14 +95,13 @@ 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): # 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(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) @@ -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..bf4fe31 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" @@ -77,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_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/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 9f85be1..7cddcfc 100644 --- a/wasm/recipe/modify-recipe.py +++ b/wasm/recipe/modify-recipe.py @@ -2,10 +2,11 @@ # This can be called repeatedly and will produce the same output. import argparse -from pathlib import Path import shutil -import yaml +import sys +from pathlib import Path +import yaml parser = argparse.ArgumentParser() parser.add_argument("input_directory", type=Path) @@ -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 a5200fe9c74ff540de6a2da71c8cf006df57d37b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Aug 2026 08:56:34 +0100 Subject: [PATCH 5/6] [pre-commit.ci] pre-commit autoupdate (#179) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.16.0 → v0.16.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.16.0...v0.16.1) * Fix tests --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ian Thomas --- .pre-commit-config.yaml | 2 +- test/test_git.py | 2 +- test/test_init.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2f2c6bd..95f0e37 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.16.0 + rev: v0.16.1 hooks: - id: ruff-check args: [--fix] diff --git a/test/test_git.py b/test/test_git.py index 2c803e7..244b5ee 100644 --- a/test/test_git.py +++ b/test/test_git.py @@ -21,7 +21,7 @@ def test_error_on_unknown_option(git2cpp_path): p = subprocess.run(cmd, capture_output=True) assert p.returncode == 109 assert p.stdout == b"" - assert p.stderr.startswith(b"The following argument was not expected: --unknown") + assert b"The following argument was not expected: --unknown" in p.stderr @pytest.mark.skipif(not GIT2CPP_TEST_WASM, reason="Only test in WebAssembly") diff --git a/test/test_init.py b/test/test_init.py index 9183780..f1e5088 100644 --- a/test/test_init.py +++ b/test/test_init.py @@ -97,7 +97,7 @@ def test_error_on_unknown_option(git2cpp_path): p = subprocess.run(cmd, capture_output=True) assert p.returncode == 109 assert p.stdout == b"" - assert p.stderr.startswith(b"The following argument was not expected: --unknown") + assert b"The following argument was not expected: --unknown" in p.stderr def test_error_on_repeated_directory(git2cpp_path): @@ -105,7 +105,7 @@ def test_error_on_repeated_directory(git2cpp_path): p = subprocess.run(cmd, capture_output=True) assert p.returncode == 109 assert p.stdout == b"" - assert p.stderr.startswith(b"The following argument was not expected: def") + assert b"The following argument was not expected: def" in p.stderr def test_init_creates_missing_parent_directories(git2cpp_path, tmp_path): From 580c7e2a2976cc3e1085bf8de633b408da868c28 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 11 Aug 2026 11:24:03 +0100 Subject: [PATCH 6/6] [pre-commit.ci] pre-commit autoupdate (#180) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.16.1 → v0.16.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.16.1...v0.16.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .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 95f0e37..817582e 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.16.1 + rev: v0.16.2 hooks: - id: ruff-check args: [--fix]