Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn if mypy version doesn't match CI (pytorch#51799)
Summary: This PR adds a local [`mypy` plugin](https://mypy.readthedocs.io/en/stable/extending_mypy.html#extending-mypy-using-plugins) that warns if you accidentally run `mypy` using a version that doesn't match [the version we install for CI](https://github.com/pytorch/pytorch/blob/6045663f391e9bebac31e006a98c1dd381792936/.circleci/docker/common/install_conda.sh#L117), since this trips people up sometimes when `mypy` gives errors in some versions (see pytorch#51513) but not others. Pull Request resolved: pytorch#51799 Test Plan: To check that this doesn't break our `mypy` test(s) when you have the correct version installed: ``` python test/test_type_hints.py ``` To check that this does indeed warn when you have an incorrect `mypy` version installed, switch to a different version (e.g. 0.782), and run the above command or either of these: ``` mypy mypy --config-file=mypy-strict.ini ``` You should get the following message on stderr: ``` You are using mypy version 0.782, which is not supported in the PyTorch repo. Please switch to mypy version 0.770. For example, if you installed mypy via pip, run this: pip install mypy==0.770 Or if you installed mypy via conda, run this: conda install -c conda-forge mypy=0.770 ``` Reviewed By: janeyx99 Differential Revision: D26282010 Pulled By: samestep fbshipit-source-id: 7b423020d0529700dea8972b27afa2d7068e1b12
- Loading branch information