diff options
author | Sam Estep <sestep@fb.com> | 2021-05-05 15:18:48 -0700 |
---|---|---|
committer | Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> | 2021-05-05 15:19:59 -0700 |
commit | e5179e960efca17272ae670771688eb369d70757 (patch) | |
tree | 9c508770498e098fe66632c0710d27726585b7a1 /mypy-strict.ini | |
parent | 65fad0ebd27a35375076f5fe2f887429f207fa7c (diff) | |
download | pytorch-e5179e960efca17272ae670771688eb369d70757.tar.gz pytorch-e5179e960efca17272ae670771688eb369d70757.tar.bz2 pytorch-e5179e960efca17272ae670771688eb369d70757.zip |
Share VS Code settings/extensions nicely (#57671)
Summary:
This is a second attempt at https://github.com/pytorch/pytorch/issues/51214. It should achieve the same goals with (as far as I can tell) no disadvantages, but the advantages are a bit less pronounced than in the more dictatorial approach that https://github.com/pytorch/pytorch/issues/51214 took:
- Unfortunately, I was unable to figure out how to include [the `mypy` configuration given in the docstring of `tools.mypy_wrapper.main`](https://github.com/pytorch/pytorch/blob/7115a4b8707115b81417481fb6240617ae934806/tools/mypy_wrapper.py#L81-L89), because as walterddr pointed out, `"${env:HOME}/miniconda3/envs/pytorch/bin/python"` is not guaranteed to be correct on everyone's machine:
```json
{
"python.linting.enabled": true,
"python.linting.mypyEnabled": true,
"python.linting.mypyPath": "${env:HOME}/miniconda3/envs/pytorch/bin/python",
"python.linting.mypyArgs": [
"${workspaceFolder}/tools/mypy_wrapper.py"
]
}
```
Importantly, this does not work:
```json
"python.linting.mypyPath": "${workspaceFolder}/tools/mypy_wrapper.py"
```
This is because VS Code does not run the given `mypy` command inside of the user's specified virtual environment, so for instance, on my system, setting the `mypy` command to directly call `tools/mypy_wrapper.py` results in using `mypy 0.782` instead of the correct `mypy 0.812`.
Sadly, [this](https://code.visualstudio.com/docs/editor/variables-reference#_configuration-variables) does not work either, although I'm not sure why:
```json
{
"python.linting.mypyPath": "${config:python.pythonPath}",
"python.linting.mypyArgs": [
"${workspaceFolder}/tools/mypy_wrapper.py"
]
}
```
- As a result, `git clean -fdx; tools/vscode_settings.py` still results in some loss of useful configuration.
One other thing to note: as `.vscode/settings_recommended.json` shows, there are some configuration sections that only take effect within the context of a `"[language]"`, so currently, if a dev already has one of those settings, it would be entirely overwritten by `tools/vscode_settings.py` rather than a graceful merge. This could probably be fixed by using a deep merge instead of the current shallow merge strategy.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/57671
Test Plan:
If you want, you can typecheck the small script added by this PR (no output is expected):
```sh
tools/mypy_wrapper.py $PWD/tools/vscode_settings.py
```
You can also try running it to update your own VS Code workspace settings:
```sh
tools/vscode_settings.py
```
This should have minimal impact on your existing `tools/settings.json` file other than enabling the few explicitly recommended settings (e.g. it should not reorder or remove any of your existing settings).
Reviewed By: malfet
Differential Revision: D28230390
Pulled By: samestep
fbshipit-source-id: 53a7907229e5807c77531cae4f9ab9d469fd7684
Diffstat (limited to 'mypy-strict.ini')
-rw-r--r-- | mypy-strict.ini | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/mypy-strict.ini b/mypy-strict.ini index e8bc2c2554..f3c5c136bc 100644 --- a/mypy-strict.ini +++ b/mypy-strict.ini @@ -38,6 +38,7 @@ strict_equality = True files = .github/scripts/generate_binary_build_matrix.py, benchmarks/instruction_counts, + tools/actions_local_runner.py, tools/autograd/*.py, tools/clang_tidy.py, tools/codegen, @@ -47,20 +48,20 @@ files = tools/pyi, tools/stats_utils, tools/test_history.py, + tools/test/test_actions_local_runner.py, tools/test/test_extract_scripts.py, tools/test/test_mypy_wrapper.py, tools/test/test_test_history.py, tools/test/test_trailing_newlines.py, - tools/test/test_actions_local_runner.py, tools/test/test_translate_annotations.py, tools/trailing_newlines.py, tools/translate_annotations.py, - tools/actions_local_runner.py, + tools/vscode_settings.py, torch/testing/_internal/framework_utils.py, + torch/utils/_pytree.py, torch/utils/benchmark/utils/common.py, torch/utils/benchmark/utils/timer.py, - torch/utils/benchmark/utils/valgrind_wrapper, - torch/utils/_pytree.py + torch/utils/benchmark/utils/valgrind_wrapper # Specifically enable imports of benchmark utils. As more of `torch` becomes # strict compliant, those modules can be enabled as well. |