You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add justfile and update CONTRIBUTING.md
* Address PR review comments
- Reorder bootstrap: run uv sync before pre-commit install
- Add ext-test to pre-mr-check dependencies
- Default test args to 'tests' so `just test path/to/file` overrides it
- Remove unnecessary -- separator in CONTRIBUTING.md examples
* PR feedback
* Smart test receipe
We use `mypy`, `pytest`, `ruff`, and `black` for quality control. `ruff` and `black` are executed using pre-commit when you make a commit.
57
-
To ensure there are not formatting or typing issues in the entire repository you can run:
65
+
Running `just` at the root of the repository lists all available recipes:
58
66
59
-
```bash
60
-
pre-commit run --all-files
67
+
```
68
+
$ just
69
+
Available recipes:
70
+
[dev]
71
+
bootstrap # Bootstrap dev environment: install pre-commit hooks and sync dependencies
72
+
lint # Run pre-commit hooks on all files
73
+
pre-mr-check # Run all checks before submitting a PR
74
+
clean # Remove mypy cache
75
+
76
+
[typecheck]
77
+
mypy # Run mypy on plugin, ext, scripts, stubs and tests
78
+
pyright # Run pyright on test cases
79
+
pyrefly # Run pyrefly on test cases
80
+
ty # Run ty on test cases
81
+
82
+
[test]
83
+
test +args # Run pytest on specific files or with custom args (no xdist)
84
+
all-test # Run full pytest test suite with parallel workers
85
+
stubtest *args # Run stubtest to check stubs match runtime
86
+
ext-test # Run django-stubs-ext tests
87
+
88
+
[build]
89
+
build # Build all packages
90
+
lock-check # Check that uv.lock is up to date
61
91
```
62
92
63
-
NOTE: This command will not only lint but also modify files - so make sure to commit whatever changes you've made before hand.
64
-
You can also run pre-commit per file or for a specific path, simply replace "--all-files" with a target (see [this guide](https://codeburst.io/tool-your-django-project-pre-commit-hooks-e1799d84551f) for more info).
93
+
Before submitting a PR, run all checks at once:
65
94
66
-
To execute the unit tests, simply run:
95
+
```bash
96
+
just pre-mr-check
97
+
```
98
+
99
+
Or run individual checks:
67
100
68
101
```bash
69
-
pytest -n auto
102
+
just lint # pre-commit hooks (ruff, codespell, ...)
103
+
just mypy # mypy on plugin, ext, scripts, stubs and tests
104
+
just test tests/test_xyz.yml # run specific tests (no xdist)
105
+
just all-test # full pytest suite (parallel)
106
+
just stubtest # stubtest: check stubs match runtime
107
+
just pyright # pyright on test cases
108
+
just ty # ty on test cases
109
+
just pyrefly # pyrefly on test cases
70
110
```
71
111
72
-
If you get some unexpected results or want to be sure that tests run is not affected by previous one, remove `mypy` cache:
112
+
Extra arguments can be passed to `test` and `stubtest`:
73
113
74
114
```bash
75
-
rm -r .mypy_cache
115
+
just test tests -k test_name
116
+
just stubtest --allowlist extra.txt
76
117
```
77
118
119
+
If you get unexpected results, clear the mypy cache with `just clean`.
120
+
78
121
### Testing stubs with `stubtest`
79
122
80
-
Run [`./scripts/stubtest.sh`](scripts/stubtest.sh) to test that stubs and sources are in-line.
123
+
Run `just stubtest` (or [`./scripts/stubtest.sh`](scripts/stubtest.sh) directly) to test that stubs and sources are in-line.
0 commit comments