pytorch
f7aa88b4 - [caffe2] Explicitly define all DataTypes in python/core.py (#51768)

Commit
3 years ago
[caffe2] Explicitly define all DataTypes in python/core.py (#51768) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/51768 This updates python/core.py to explicitly define all of the `DataType` values rather than dynamically defining them at runtime from the `caffe2_pb2` values. This allows type checkers like Pyre and Mypy to see the members of the `DataType` class. Otherwise the type checkers report errors such as `"core.DataType" has no attribute "INT64"`. This code does keep a run-time check that all of the data types defined by `caffe2_pb2.proto` are defined correctly in this file. This way if someone does add a new type to `caffe2_pb2.proto` it should be very quickly apparent that this file needs to be updated and kept in sync. ghstack-source-id: 121936201 Test Plan: Confirmed that various caffe2/python tests still pass. Verified that this allows many `pyre-fixme` comments to be removed in downstream projects, and that Pyre is still clean for these projects. Reviewed By: jeffdunn Differential Revision: D26271725 Pulled By: simpkins fbshipit-source-id: f9e95795de60aba67d7d3872d0c141ed82ba8e39
Author
Parents
Loading