From ce03f586f7094a891fcf3980e61f4b7d7ce33706 Mon Sep 17 00:00:00 2001 From: jovnc <95868357+jovnc@users.noreply.github.com> Date: Sun, 8 Feb 2026 11:40:01 +0800 Subject: [PATCH 1/2] [tooling] Add pre-commit hooks --- lefthook.yml | 16 ++++++++++++++++ requirements.txt | 1 + setup.sh | 4 ++++ 3 files changed, 21 insertions(+) create mode 100644 lefthook.yml diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 00000000..b0603b4e --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,16 @@ +pre-commit: + parallel: true + commands: + ruff-lint: + glob: "*.py" + run: ruff check --fix {staged_files} + stage_fixed: true + + ruff-format: + glob: "*.py" + run: ruff format {staged_files} + stage_fixed: true + + mypy: + glob: "*.py" + run: mypy {staged_files} diff --git a/requirements.txt b/requirements.txt index df25221b..e9778199 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,7 @@ pytest repo-smith # Developer tooling dependencies +lefthook ruff mypy PyGithub diff --git a/setup.sh b/setup.sh index fd50d7dc..2335f869 100755 --- a/setup.sh +++ b/setup.sh @@ -7,3 +7,7 @@ fi source venv/bin/activate pip install -r requirements.txt -U --no-cache-dir + +if ! command -v lefthook &>/dev/null; then + lefthook install +fi From d6a3e84edd831fc9de59431a0e35e5470102b3f9 Mon Sep 17 00:00:00 2001 From: jovnc <95868357+jovnc@users.noreply.github.com> Date: Sun, 1 Mar 2026 15:36:30 +0800 Subject: [PATCH 2/2] [tooling] Address copilot comments for LeftHook --- lefthook.yml | 4 ++-- setup.sh | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lefthook.yml b/lefthook.yml index b0603b4e..3f9723a0 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -1,5 +1,5 @@ pre-commit: - parallel: true + parallel: false commands: ruff-lint: glob: "*.py" @@ -13,4 +13,4 @@ pre-commit: mypy: glob: "*.py" - run: mypy {staged_files} + run: mypy . diff --git a/setup.sh b/setup.sh index 2335f869..0b86e374 100755 --- a/setup.sh +++ b/setup.sh @@ -8,6 +8,8 @@ source venv/bin/activate pip install -r requirements.txt -U --no-cache-dir -if ! command -v lefthook &>/dev/null; then +if command -v lefthook >/dev/null 2>&1; then lefthook install +else + echo "LeftHook not installed, failed to set up LeftHook for Git Hooks." fi