Skip to content

Commit 5045cb4

Browse files
committed
add validation matrix for type-checking
1 parent 1a354e0 commit 5045cb4

4 files changed

Lines changed: 46 additions & 21 deletions

File tree

CONTRIBUTING.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ First off, thank you for considering contributing to this project!
1212

1313
2. **Install dependencies using `uv`:**
1414
```bash
15-
uv venv
16-
source .venv/bin/activate
17-
uv pip install -e ".[dev]"
15+
uv sync --extra dev --extra docs
16+
```
17+
18+
`pip` fallback:
19+
```bash
20+
pip install -e ".[dev,docs]"
1821
```
1922

2023
3. **Install pre-commit hooks:**
@@ -26,12 +29,14 @@ First off, thank you for considering contributing to this project!
2629

2730
We use a `Makefile` to simplify common tasks:
2831

29-
- `make format`: Formats code using `ruff`.
30-
- `make check`: Runs linters (`ruff check`) and type checkers (`basedpyright`, `ty`).
31-
- `make tests`: Runs the test suite using `pytest`.
32-
- `make all`: Runs formatting and checking consecutively.
32+
- `make format`: Formats code using `uv run ruff format`.
33+
- `make check`: Runs the repo-default validation pass with `uv`.
34+
- `make check-matrix`: Runs `ruff`, `ty`, and `basedpyright` under Python `3.11`, `3.12`, and `3.13`.
35+
- `make tests`: Runs the test suite using `uv run pytest`.
36+
- `make all`: Runs `make format` then `make check`.
37+
- `make prod`: Runs `make tests`, `make format`, and `make check-matrix`.
3338

34-
Before submitting a Pull Request, please ensure `make all` and `make tests` run without any errors.
39+
Before submitting a Pull Request, ensure `make prod` runs without errors.
3540

3641
## Pull Requests
3742

Makefile

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
BLUE := \033[1;34m
22
GREEN := \033[1;32m
33
RESET := \033[0m
4+
PYTHON_VERSIONS := 3.11 3.12 3.13
45

5-
.PHONY: tests format check all prod rename
6+
.PHONY: tests format check check-matrix all prod rename
67

78
# Hack to allow passing arguments to make commands (e.g. make rename my_project)
89
ifeq (rename,$(firstword $(MAKECMDGOALS)))
@@ -23,23 +24,32 @@ rename:
2324

2425
format:
2526
@printf "$(BLUE)==>$(RESET) Formatting code with ruff...\n"
26-
@ruff format
27+
@uv run ruff format
2728
@printf "$(GREEN)✔ Formatting complete.$(RESET)\n"
2829

2930
check:
30-
@printf "$(BLUE)==>$(RESET) Running ruff checks and fixing issues...\n"
31-
@ruff check --fix --unsafe-fixes
31+
@printf "$(BLUE)==>$(RESET) Running ruff checks...\n"
32+
@uv run ruff check
3233
@printf "$(BLUE)==>$(RESET) Type checking with ty...\n"
33-
@ty check
34+
@uv run ty check
3435
@printf "$(BLUE)==>$(RESET) Type checking with basedpyright...\n"
35-
@basedpyright
36+
@uv run basedpyright
3637
@printf "$(GREEN)✔ Checking complete.$(RESET)\n"
3738

39+
check-matrix:
40+
@for version in $(PYTHON_VERSIONS); do \
41+
printf "$(BLUE)==>$(RESET) Running validation matrix for Python $$version...\n"; \
42+
uv run --python $$version ruff check src/vcode tests || exit $$?; \
43+
uv run --python $$version ty check --python-version $$version || exit $$?; \
44+
uv run --python $$version basedpyright --pythonversion $$version || exit $$?; \
45+
done
46+
@printf "$(GREEN)✔ Matrix checking complete.$(RESET)\n"
47+
3848
tests:
3949
@printf "$(BLUE)==>$(RESET) Running tests with pytest...\n"
40-
@pytest
50+
@uv run pytest
4151
@printf "$(GREEN)✔ Tests complete.$(RESET)\n"
4252

4353
all: format check
4454

45-
prod: tests format check
55+
prod: tests format check-matrix

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ uv run basedpyright
5959
python3.11 -m pytest
6060
```
6161

62+
Current `Makefile` shortcuts:
63+
64+
```bash
65+
make format
66+
make check
67+
make check-matrix
68+
make tests
69+
make prod
70+
```
71+
6272
## Documentation
6373

6474
The detailed docs live under `docs/`.

tests/fakes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ async def _test_model_response(
5151
del agent_info
5252
latest_message = messages[-1] if messages else None
5353
if isinstance(latest_message, ModelRequest):
54-
tool_returns = [
55-
part
56-
for part in latest_message.parts
57-
if getattr(part, "part_kind", None) == "tool-return"
58-
]
54+
request_message = latest_message
55+
tool_returns = []
56+
for part in request_message.parts:
57+
if getattr(part, "part_kind", None) == "tool-return":
58+
tool_returns.append(part)
5959
if tool_returns:
6060
content = "\n".join(f"{part.tool_name}: {part.content}" for part in tool_returns)
6161
return ModelResponse(parts=[TextPart(content=content)], model_name="test:demo")

0 commit comments

Comments
 (0)