@@ -56,15 +56,15 @@ if you don't.
56
56
57
57
For more details, see < https://docs.astral.sh/ruff/ > .
58
58
59
- ## Type-checking
59
+ ## Type-checking and Testing
60
60
61
- To validate that the annotations are correct, we use two type-checkers :
62
- [ basedpyright] and [ mypy ] . Both are included as development
63
- dependency, and therefore automatically installed with ` uv sync ` .
61
+ To validate that the annotations are correct and run tests , we use several tools :
62
+ [ basedpyright] , [ mypy ] , and [ pytest ] . All are included as development
63
+ dependency-group, so that ` uv sync ` will install them by default .
64
64
65
65
### basedpyright
66
66
67
- You can run basedpyright on the entire project using
67
+ You can run basedpyright on the entire project using:
68
68
69
69
``` bash
70
70
$ uv run basedpyright
@@ -78,21 +78,38 @@ See <https://docs.basedpyright.com/> for IDE integration and other info.
78
78
79
79
### mypy
80
80
81
- Mypy requires a bit more effort to run, since it doesn't play well with
82
- editable dependencies, and it doesn't seem to recognize NumType's ` numpy-stubs `
83
- if ` numpy ` is also installed. You can get around that by running:
81
+ Mypy is used for type-checking the codebase and the type-tests. It takes more effort to run it on the codebase than ` basedpyright ` .
82
+ This is primarily a consequence of mypy's inconsequent prioritization of the stubs bundled
83
+ with NumPy over the ` numpy-stubs ` within a local development environment.
84
+ To get around this, you can delete all ` *.pyi ` from your ** local** ` numpy ` installation directory by running ` uv tool/unstub.py ` .
85
+
86
+ ** General Type Checking**
87
+
88
+ To run mypy generally (excluding the main numpy dependency group):
84
89
85
90
``` shell
86
91
uv run --no-editable --no-group=numpy mypy .
87
92
```
88
93
89
- In rare cases, the cache can get corrupted, which can lead to incorrect
90
- results. So in case the CI output of mypy differs from your local output, you
91
- should delete the ` .mypy_cache ` directory in the ` numtype ` root.
94
+ ** Cache Issues**
95
+
96
+ In rare cases, the cache (` .mypy_cache ` in the ` numtype ` root) can get corrupted,
97
+ leading to incorrect results. If CI output differs from your local output, delete
98
+ this directory.
92
99
93
100
The documentation can be found at < https://mypy.readthedocs.io/ > , and issues can
94
101
be reported at < https://github.com/python/mypy > .
95
102
103
+ ### pytest
104
+
105
+ Pytest runs runtime tests located in ` src/*/@test ` . It works out-of-the-box:
106
+
107
+ ``` bash
108
+ uv run pytest [OPTIONS]
109
+ ```
110
+
111
+ For available options, see the [ pytest documentation] ( https://docs.pytest.org/en/stable/how-to/usage.html#args-from-file ) .
112
+
96
113
## Lefthook
97
114
98
115
[ Lefthook] is a modern Git hooks manager, which automatically lints and formats
@@ -175,10 +192,6 @@ about your local or global `pip` or `uv` environments.
175
192
176
193
See < https://tox.wiki/en/stable/ > for more information.
177
194
178
- ## Testing
179
-
180
- See the ` README.md ` in [ ` numtype/test ` ] [ test-docs ] .
181
-
182
195
## Documentation
183
196
184
197
The documentation lives in ` docs/ ` , the ` README.md ` , and ` CONTRIBUTING.md ` .
@@ -227,9 +240,9 @@ one of the development dependencies.
227
240
[ mkdocs ] : https://www.mkdocs.org/
228
241
[ mypy ] : https://github.com/python/mypy
229
242
[ numpy-commit-style ] : https://numpy.org/devdocs/dev/development_workflow.html#writing-the-commit-message
243
+ [ pytest ] : https://docs.pytest.org/en/latest/
230
244
[ ruff ] : https://docs.astral.sh/ruff/
231
245
[ stub-style ] : https://typing.python.org/en/latest/guides/writing_stubs.html#style-guide
232
- [ test-docs ] : https://github.com/numpy/numtype/tree/main/test
233
246
[ tool-docs ] : https://github.com/numpy/numtype/tree/main/tool
234
247
[ tox ] : https://github.com/tox-dev/tox
235
248
0 commit comments