Link to mypy wiki page from CONTRIBUTING.md (#50540)
Summary:
Addresses one of the documentation points in https://github.com/pytorch/pytorch/issues/50513 by making it easier to find our `mypy` wiki page. Also updates the `CONTRIBUTING.md` table of contents and removes some trailing whitespace.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/50540
Reviewed By: janeyx99
Differential Revision: D25912366
Pulled By: samestep
fbshipit-source-id: b305f974700a9d9ebedc0c2cb75c92e72d84882a
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c55240d..98e53c3 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,10 +2,12 @@
- [Contributing to PyTorch](#contributing-to-pytorch)
- [Developing PyTorch](#developing-pytorch)
- - [Nightly Checkout & Pull](#nightly-checkout--pull)
+ - [Tips and Debugging](#tips-and-debugging)
+- [Nightly Checkout & Pull](#nightly-checkout--pull)
- [Codebase structure](#codebase-structure)
- [Unit testing](#unit-testing)
- [Better local unit tests with pytest](#better-local-unit-tests-with-pytest)
+ - [Running `mypy`](#running-mypy)
- [Writing documentation](#writing-documentation)
- [Building documentation](#building-documentation)
- [Tips](#tips)
@@ -291,6 +293,17 @@
The above is an example of testing a change to Loss functions: this command runs tests such as
`TestNN.test_BCELoss` and `TestNN.test_MSELoss` and can be useful to save keystrokes.
+### Running `mypy`
+
+One of the test suites runs `mypy` on the codebase:
+```bash
+python test/test_type_hints.py
+```
+See [Guide for adding type annotations to
+PyTorch](https://github.com/pytorch/pytorch/wiki/Guide-for-adding-type-annotations-to-PyTorch)
+for more information on how to set up `mypy` and tackle type annotation
+tasks, as well as other ways to run `mypy` besides running that test suite.
+
## Writing documentation
PyTorch uses [Google style](http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html)
@@ -903,14 +916,14 @@
[Lint as you type](https://github.com/pytorch/pytorch/wiki/Lint-as-you-type)
for documentation on how to do this.
-If you haven't set up the pre-commit hook and have already committed files and
+If you haven't set up the pre-commit hook and have already committed files and
CI reports `flake8` errors, you can run the check locally in your PR branch with:
```bash
flake8 $(git diff --name-only $(git merge-base --fork-point master))
```
-fix the code so that no errors are reported when you re-run the above check again,
+fix the code so that no errors are reported when you re-run the above check again,
and then commit the fix.
## Building PyTorch with ASAN