Skip to content

Commit 3c81ad7

Browse files
authored
Merge pull request #460 from guan404ming/move-test-to-contributing
🚚 move test `README.md` into the `CONTRIBUTING.md`
2 parents fc1f12f + d28d18e commit 3c81ad7

File tree

2 files changed

+29
-46
lines changed

2 files changed

+29
-46
lines changed

CONTRIBUTING.md

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ if you don't.
5656

5757
For 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,38 @@ 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
8691
uv 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

93100
The documentation can be found at <https://mypy.readthedocs.io/>, and issues can
94101
be 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+
111+
For available options, see the [pytest documentation](https://docs.pytest.org/en/stable/how-to/usage.html#args-from-file).
112+
96113
## Lefthook
97114

98115
[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.
175192

176193
See <https://tox.wiki/en/stable/> for more information.
177194

178-
## Testing
179-
180-
See the `README.md` in [`numtype/test`][test-docs].
181-
182195
## Documentation
183196

184197
The documentation lives in `docs/`, the `README.md`, and `CONTRIBUTING.md`.
@@ -227,9 +240,9 @@ one of the development dependencies.
227240
[mkdocs]: https://www.mkdocs.org/
228241
[mypy]: https://github.com/python/mypy
229242
[numpy-commit-style]: https://numpy.org/devdocs/dev/development_workflow.html#writing-the-commit-message
243+
[pytest]: https://docs.pytest.org/en/latest/
230244
[ruff]: https://docs.astral.sh/ruff/
231245
[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
233246
[tool-docs]: https://github.com/numpy/numtype/tree/main/tool
234247
[tox]: https://github.com/tox-dev/tox
235248

src/numpy-stubs/@test/README.md

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

0 commit comments

Comments
 (0)