@@ -56,15 +56,15 @@ if you don't.
5656
5757For more details, see < https://docs.astral.sh/ruff/ > .
5858
59- ## Type-checking
59+ ## Type-checking and Testing
6060
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 .
6464
6565### basedpyright
6666
67- You can run basedpyright on the entire project using
67+ You can run basedpyright on the entire project using:
6868
6969``` bash
7070$ uv run basedpyright
@@ -78,21 +78,36 @@ See <https://docs.basedpyright.com/> for IDE integration and other info.
7878
7979### mypy
8080
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):
8489
8590``` shell
8691uv run --no-editable --no-group=numpy mypy .
8792```
8893
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.
9299
93100The documentation can be found at < https://mypy.readthedocs.io/ > , and issues can
94101be reported at < https://github.com/python/mypy > .
95102
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+
96111## Lefthook
97112
98113[ Lefthook] is a modern Git hooks manager, which automatically lints and formats
@@ -175,10 +190,6 @@ about your local or global `pip` or `uv` environments.
175190
176191See < https://tox.wiki/en/stable/ > for more information.
177192
178- ## Testing
179-
180- See the ` README.md ` in [ ` numtype/test ` ] [ test-docs ] .
181-
182193## Documentation
183194
184195The documentation lives in ` docs/ ` , the ` README.md ` , and ` CONTRIBUTING.md ` .
@@ -227,9 +238,9 @@ one of the development dependencies.
227238[ mkdocs ] : https://www.mkdocs.org/
228239[ mypy ] : https://github.com/python/mypy
229240[ numpy-commit-style ] : https://numpy.org/devdocs/dev/development_workflow.html#writing-the-commit-message
241+ [ pytest ] : https://docs.pytest.org/en/latest/
230242[ ruff ] : https://docs.astral.sh/ruff/
231243[ 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
233244[ tool-docs ] : https://github.com/numpy/numtype/tree/main/tool
234245[ tox ] : https://github.com/tox-dev/tox
235246
0 commit comments