Skip to content

Commit b69ec51

Browse files
authored
instructions for Python checks, now with more checks enabled (#109)
* add make-targets and instructions for Python checks; fix GH-action warning * formatting * removing file as per 6/11 meeting, resolves #104 * this script seems to be obsolete since #73 moved the constant into a JSON file * format/lint changes * enable lint and type checking for Python
1 parent 23222c3 commit b69ec51

File tree

6 files changed

+68
-222
lines changed

6 files changed

+68
-222
lines changed

.github/workflows/pr-check.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: astral-sh/setup-uv@v5
1919
with:
2020
enable-cache: true
21-
cache-dependency-glob: "uv.lock"
21+
cache-dependency-glob: "backend/uv.lock"
2222
# Install a specific version of uv.
2323
version: "0.7.12"
2424

@@ -31,6 +31,12 @@ jobs:
3131
- name: Run formatter checks
3232
run: uv run ruff format --check
3333

34+
- name: Run lint checks
35+
run: uv run ruff check
36+
37+
- name: Run type checks
38+
run: uv run ty check
39+
3440
- name: Run tests
3541
env:
3642
OPENAI_API_KEY: XXXX

README.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,50 @@ Live at https://tenantfirstaid.com/
2323
1. Go to http://localhost:5173
2424
1. Start chatting
2525

26-
### Run backend tests
26+
### Backend Development & Checks
2727

28-
In the `backend/` directory, run `uv run pytest`
28+
1. change to the `backend/` directory
29+
```sh
30+
% cd backend
31+
```
32+
- run individual checks
33+
1. *format* Python code with `ruff`
34+
```sh
35+
% uv run ruff format
36+
```
37+
or
38+
```sh
39+
% make fmt
40+
```
41+
1. *lint* Python code with `ruff`
42+
```sh
43+
% uv run ruff check
44+
```
45+
or
46+
```sh
47+
% make lint
48+
```
49+
1. *typecheck* Python code with `ty`
50+
```sh
51+
% uv run ty check
52+
```
53+
or
54+
```sh
55+
% make typecheck
56+
```
57+
1. *test* Python code with `pytest`
58+
```sh
59+
% uv run pytest
60+
```
61+
or
62+
```sh
63+
% make test
64+
```
65+
- or run the above checks in one-shot
66+
```sh
67+
% make --keep-going check
68+
```
69+
`--keep-going` will continue to run checks, even if previous `make` rule fail. Omit if you want to stop after the first `make` rule fails.
2970

3071
## Contributing
3172

backend/Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,26 @@ PIP := $(PYTHON) pip
55

66
all: check
77

8+
uv.lock: pyproject.toml
9+
$(PYTHON) sync
10+
811
install:
912
$(PIP) install .
1013

11-
test:
12-
uv run pytest -v -s
14+
fmt: uv.lock
15+
$(PYTHON) run ruff format
16+
17+
lint: uv.lock
18+
$(PYTHON) run ruff check $(LINT_OPTIONS)
19+
20+
typecheck: uv.lock
21+
$(PYTHON) run ty check $(TYPECHECK_OPTIONS)
22+
23+
test: uv.lock
24+
uv run pytest -v -s $(TEST_OPTIONS)
1325

1426
clean:
1527
find . -type d -name '__pycache__' -exec rm -r {} +
1628
rm -rf dist build *.egg-info
1729

18-
check: clean install test
30+
check: clean install fmt lint typecheck test

backend/scripts/eval.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import textwrap, pathlib, json
1+
import textwrap
2+
import pathlib
3+
import json
24

35
# Build the two eval samples as Python dicts
46
samples = [

backend/scripts/extract_sections.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

backend/tenantfirstaid/prepare_training.py

Lines changed: 0 additions & 170 deletions
This file was deleted.

0 commit comments

Comments
 (0)