Files
pytorch/mypy-strict.ini
Sam Estep bdb421895a 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
2021-04-22 07:51:01 -07:00

84 lines
2.4 KiB
INI

# This is the PyTorch mypy-strict.ini file (note: don't change this line! -
# test_run_mypy in test/test_type_hints.py uses this string)
# Unlike mypy.ini, it enforces very strict typing rules. The intention is for
# this config file to be used to ENFORCE that people are using mypy on codegen
# files.
# For now, only code_template.py and benchmark utils Timer are covered this way
[mypy]
python_version = 3.6
plugins = mypy_plugins/check_mypy_version.py
cache_dir = .mypy_cache/strict
strict_optional = True
show_error_codes = True
show_column_numbers = True
warn_no_return = True
disallow_any_unimported = True
# Across versions of mypy, the flags toggled by --strict vary. To ensure
# we have reproducible type check, we instead manually specify the flags
warn_unused_configs = True
disallow_any_generics = True
disallow_subclassing_any = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
disallow_untyped_decorators = True
no_implicit_optional = True
warn_redundant_casts = True
warn_unused_ignores = True
warn_return_any = True
implicit_reexport = False
strict_equality = True
files =
.github/scripts/generate_binary_build_matrix.py,
benchmarks/instruction_counts,
tools/autograd/*.py,
tools/clang_tidy.py,
tools/codegen,
tools/extract_scripts.py,
tools/mypy_wrapper.py,
tools/print_test_stats.py,
tools/pyi,
tools/stats_utils,
tools/test_history.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,
torch/testing/_internal/framework_utils.py,
torch/utils/benchmark/utils/common.py,
torch/utils/benchmark/utils/timer.py,
torch/utils/benchmark/utils/valgrind_wrapper,
torch/utils/_pytree.py
# Specifically enable imports of benchmark utils. As more of `torch` becomes
# strict compliant, those modules can be enabled as well.
[mypy-torch.utils.benchmark.utils.*]
follow_imports = normal
# Don't follow imports as much of `torch` is not strict compliant.
[mypy-torch]
follow_imports = skip
[mypy-torch.*]
follow_imports = skip
# Missing stubs.
[mypy-numpy]
ignore_missing_imports = True
[mypy-mypy.*]
ignore_missing_imports = True