Skip to content

CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.

chore(dev): add pre-commit checks

xf gong5f55f9394e70
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..6d4410b
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,23 @@
+repos:
+ - repo: local
+ hooks:
+ - id: ruff-check
+ name: ruff check
+ entry: uv run ruff check cubepi/ tests/
+ language: system
+ pass_filenames: false
+ - id: ruff-format-check
+ name: ruff format --check
+ entry: uv run ruff format --check cubepi/ tests/
+ language: system
+ pass_filenames: false
+ - id: mypy
+ name: mypy cubepi
+ entry: uv run mypy cubepi
+ language: system
+ pass_filenames: false
+ - id: pytest
+ name: pytest tests
+ entry: uv run pytest tests/
+ language: system
+ pass_filenames: false
diff --git a/README.md b/README.md
index 65ffaa1..f6bb7a4 100644
--- a/README.md
+++ b/README.md
@@ -48,6 +48,13 @@ uv add cubepi
uv add cubepi[sqlite,postgres,mysql,mcp,tracing]
```
+For local Git hooks that mirror CI, install `pre-commit` and enable the repo
+config:
+
+```bash
+uvx pre-commit install
+```
+
## Quick Start
```python
diff --git a/tests/checkpointer/test_hitl_answer_ledger_unit.py b/tests/checkpointer/test_hitl_answer_ledger_unit.py
index fb92c75..2a8e298 100644
--- a/tests/checkpointer/test_hitl_answer_ledger_unit.py
+++ b/tests/checkpointer/test_hitl_answer_ledger_unit.py
@@ -113,9 +113,7 @@ async def test_postgres_hitl_answer_ledger_load_from_json_string() -> None:
conn = _PgConn(row={"answer": json.dumps({"decision": "deny"})})
cp._pool = _PgPool(conn)
- assert await cp.load_hitl_answer("t-1", "q-1", run_id="r-1") == {
- "decision": "deny"
- }
+ assert await cp.load_hitl_answer("t-1", "q-1", run_id="r-1") == {"decision": "deny"}
assert await cp.load_hitl_answer("t-1", "q-missing", run_id="r-1") == {
"decision": "deny"
}
@@ -155,9 +153,7 @@ async def test_mysql_hitl_answer_ledger_load_from_json_string() -> None:
conn = _MyConn(row=("{}".format(json.dumps({"decision": "deny"})),))
cp._pool = _MyPool(conn)
- assert await cp.load_hitl_answer("t-1", "q-1", run_id="r-1") == {
- "decision": "deny"
- }
+ assert await cp.load_hitl_answer("t-1", "q-1", run_id="r-1") == {"decision": "deny"}
@pytest.mark.asyncio
diff --git a/tests/hitl/test_checkpointer_pending_request.py b/tests/hitl/test_checkpointer_pending_request.py
index 3179abd..38574b0 100644
--- a/tests/hitl/test_checkpointer_pending_request.py
+++ b/tests/hitl/test_checkpointer_pending_request.py
@@ -119,6 +119,4 @@ async def test_sqlite_hitl_answer_ledger_crud(sqlite_cp):
async def test_sqlite_hitl_answer_ledger_clear_empty_iterable(sqlite_cp):
await sqlite_cp.save_hitl_answer("t-1", "q-1", {"decision": "approve"})
await sqlite_cp.clear_hitl_answers("t-1", [], run_id=None)
- assert await sqlite_cp.load_hitl_answer("t-1", "q-1") == {
- "decision": "approve"
- }
+ assert await sqlite_cp.load_hitl_answer("t-1", "q-1") == {"decision": "approve"}
diff --git a/tests/hitl/test_edge_cases.py b/tests/hitl/test_edge_cases.py
index af7ec07..71e8561 100644
--- a/tests/hitl/test_edge_cases.py
+++ b/tests/hitl/test_edge_cases.py
@@ -132,7 +132,9 @@ def test_respond_raises_when_checkpointer_lacks_hitl_answer_store():
"R1",
)
- agent = _agent(channel=InMemoryChannel(), checkpointer=_PartialCP(), thread_id="t-1")
+ agent = _agent(
+ channel=InMemoryChannel(), checkpointer=_PartialCP(), thread_id="t-1"
+ )
with pytest.raises(HitlError, match="save_hitl_answer"):
asyncio.get_event_loop().run_until_complete(
agent.respond(answer=ApproveAnswer(decision="approve"))