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