summaryrefslogtreecommitdiff
path: root/mypy-strict.ini
diff options
context:
space:
mode:
authorEdward Yang <ezyang@fb.com>2020-08-05 12:25:10 -0700
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>2020-08-05 12:28:15 -0700
commit7c33225c72855dbf2d11cf3bd8164167292856b8 (patch)
tree859a58b4f7599eef3169da33e75f0cabf5e7dee9 /mypy-strict.ini
parent5c5d7a9dca20f1bd578d1cb933fae9acef535202 (diff)
downloadpytorch-7c33225c72855dbf2d11cf3bd8164167292856b8.tar.gz
pytorch-7c33225c72855dbf2d11cf3bd8164167292856b8.tar.bz2
pytorch-7c33225c72855dbf2d11cf3bd8164167292856b8.zip
Add strict mypy type checking and update code_template.py (#42322)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/42322 Our current type checking rules are rather lax, and for example don't force users to make sure they annotate all functions with types. For code generation code, it would be better to force 100% typing. This PR introduces a new mypy configuration mypy-strict.ini which applies rules from --strict. We extend test_type_hints.py to test for this case. It only covers code_template.py, which I have made strict clean in this PR. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Test Plan: Imported from OSS Reviewed By: mruberry Differential Revision: D22846120 Pulled By: ezyang fbshipit-source-id: 8d253829223bfa0d811b6add53b7bc2d3a4356b0
Diffstat (limited to 'mypy-strict.ini')
-rw-r--r--mypy-strict.ini33
1 files changed, 33 insertions, 0 deletions
diff --git a/mypy-strict.ini b/mypy-strict.ini
new file mode 100644
index 0000000000..21563d4be9
--- /dev/null
+++ b/mypy-strict.ini
@@ -0,0 +1,33 @@
+# This is a MyPy config file but 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 is covered this way
+
+[mypy]
+python_version = 3.6
+
+strict_optional = 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 =
+ aten/src/ATen/code_template.py