Remove some wildcards from mypy configs (#56645)

Summary:
See https://github.com/pytorch/pytorch/pull/56523#issuecomment-823562134 for context. Basically the idea is that people (including myself) keep assuming that the single-asterisk `*` wildcard means "match in this directory and in its subdirectories", which is _not_ true. Removing the wildcards thus reduces confusion.

Ideally I would like to remove _all_ of these wildcards and then add a lint to disallow them in the future (and also greatly simplify the pattern-matching logic in `tools/mypy_wrapper.py`; see https://github.com/pytorch/pytorch/issues/55702 for context), but currently this one can't be removed:

```
tools/autograd/*.py,
```

That is because there is a file called `tools/autograd/templates/annotated_fn_args.py` (added in https://github.com/pytorch/pytorch/issues/41575) which is not a valid Python file and thus cannot be checked by `mypy`. ezyang would it be possible to rename that file to use a suffix other than `.py`?

Pull Request resolved: https://github.com/pytorch/pytorch/pull/56645

Test Plan:
```
$ mypy
Success: no issues found in 1317 source files
$ mypy --config=mypy-strict.ini
Success: no issues found in 72 source files
```
The numbers of source files should be the same before and after this PR.

Reviewed By: ezyang

Differential Revision: D27925207

Pulled By: samestep

fbshipit-source-id: c17faf73665a75393d3109346a1138c2af023abb
This commit is contained in:
Sam Estep
2021-04-22 07:48:21 -07:00
committed by Facebook GitHub Bot
parent 1f0223d6bb
commit bdb421895a
2 changed files with 4 additions and 4 deletions

View File

@ -44,8 +44,8 @@ files =
tools/extract_scripts.py,
tools/mypy_wrapper.py,
tools/print_test_stats.py,
tools/pyi/*.py,
tools/stats_utils/*.py,
tools/pyi,
tools/stats_utils,
tools/test_history.py,
tools/test/test_extract_scripts.py,
tools/test/test_mypy_wrapper.py,
@ -59,7 +59,7 @@ files =
torch/testing/_internal/framework_utils.py,
torch/utils/benchmark/utils/common.py,
torch/utils/benchmark/utils/timer.py,
torch/utils/benchmark/utils/valgrind_wrapper/*.py,
torch/utils/benchmark/utils/valgrind_wrapper,
torch/utils/_pytree.py
# Specifically enable imports of benchmark utils. As more of `torch` becomes

View File

@ -36,7 +36,7 @@ files =
tools/clang_format_utils.py,
tools/clang_tidy.py,
tools/generate_torch_version.py,
tools/stats_utils/*.py
tools/stats_utils
#
# `exclude` is a regex, not a list of paths like `files` (sigh)