From 7151e14479488f6b4b3e349e020a4995ed69bcdc Mon Sep 17 00:00:00 2001 From: Dan Moldovan Date: Mon, 6 Jul 2020 17:20:13 -0700 Subject: [PATCH] Additional overrides for Generic and its metaclass. PiperOrigin-RevId: 319887689 Change-Id: I5db9d18649f69dabcc234ab0b00ad452537a828f --- tensorflow/tools/api/lib/python_object_to_proto_visitor.py | 7 +++++++ tensorflow/tools/common/public_api.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tensorflow/tools/api/lib/python_object_to_proto_visitor.py b/tensorflow/tools/api/lib/python_object_to_proto_visitor.py index 921fc32a5ed..77882d50bae 100644 --- a/tensorflow/tools/api/lib/python_object_to_proto_visitor.py +++ b/tensorflow/tools/api/lib/python_object_to_proto_visitor.py @@ -95,6 +95,13 @@ else: return False +# Differences created by Generic typing. +_NORMALIZE_TYPE[( + 'tensorflow.python.framework.ops.Tensor')] = ( + "") +_NORMALIZE_TYPE['typing.Generic'] = "" + + if sys.version_info.major == 3 and sys.version_info.minor >= 8: _NORMALIZE_TYPE[""] = "" diff --git a/tensorflow/tools/common/public_api.py b/tensorflow/tools/common/public_api.py index 0838ab9debb..0761f97a2c7 100644 --- a/tensorflow/tools/common/public_api.py +++ b/tensorflow/tools/common/public_api.py @@ -112,7 +112,7 @@ class PublicAPIVisitor(object): return ((path in self._private_map and name in self._private_map[path]) or (six.ensure_str(name).startswith('_') and not re.match('__.*__$', six.ensure_str(name)) or - name in ['__base__', '__class__'])) + name in ['__base__', '__class__', '__next_in_mro__'])) def _do_not_descend(self, path, name): """Safely queries if a specific fully qualified name should be excluded."""