From 5c93045d14c83caaa7a590b3eb6b7e24fb892e31 Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Wed, 4 Apr 2018 11:48:00 -0700 Subject: [PATCH] make default `kwonlydefaults=None` for py3 --- tensorflow/python/util/tf_inspect.py | 2 +- tensorflow/tools/docs/parser.py | 2 +- tensorflow/tools/docs/parser_test.py | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tensorflow/python/util/tf_inspect.py b/tensorflow/python/util/tf_inspect.py index 5e74a97..2c48c52 100644 --- a/tensorflow/python/util/tf_inspect.py +++ b/tensorflow/python/util/tf_inspect.py @@ -79,7 +79,7 @@ def getfullargspec(obj): # pylint: disable=redefined-builtin varkw=argspecs.keywords, defaults=argspecs.defaults, kwonlyargs=[], - kwonlydefaults={}, + kwonlydefaults=None, annotations={}) return fullargspecs else: diff --git a/tensorflow/tools/docs/parser.py b/tensorflow/tools/docs/parser.py index bf1c3ed..cec23b1 100644 --- a/tensorflow/tools/docs/parser.py +++ b/tensorflow/tools/docs/parser.py @@ -661,7 +661,7 @@ def _get_arg_spec(func): varargs=argspec.varargs, varkw=argspec.varkw, defaults=tuple(argspec_defaults), - kwonlyargs=[], kwonlydefaults={}, + kwonlyargs=[], kwonlydefaults=None, annotations={}) else: # Regular function or method, getargspec will work fine. return tf_inspect.getfullargspec(func) diff --git a/tensorflow/tools/docs/parser_test.py b/tensorflow/tools/docs/parser_test.py index c6fbd2b..d7757d7 100644 --- a/tensorflow/tools/docs/parser_test.py +++ b/tensorflow/tools/docs/parser_test.py @@ -410,14 +410,14 @@ class ParserTest(googletest.TestCase): # Make sure everything works for regular functions. expected = tf_inspect.FullArgSpec(args=['arg1', 'arg2', 'kwarg1', 'kwarg2'], varargs=None, varkw=None, defaults=(1, 2), - kwonlyargs=[], kwonlydefaults={}, + kwonlyargs=[], kwonlydefaults=None, annotations={}) self.assertEqual(expected, parser._get_arg_spec(test_function_for_partial1)) # Make sure doing nothing works. expected = tf_inspect.FullArgSpec(args=['arg1', 'arg2', 'kwarg1', 'kwarg2'], varargs=None, varkw=None, defaults=(1, 2), - kwonlyargs=[], kwonlydefaults={}, + kwonlyargs=[], kwonlydefaults=None, annotations={}) partial = functools.partial(test_function_for_partial1) self.assertEqual(expected, parser._get_arg_spec(partial)) @@ -425,14 +425,14 @@ class ParserTest(googletest.TestCase): # Make sure setting args from the front works. expected = tf_inspect.FullArgSpec(args=['arg2', 'kwarg1', 'kwarg2'], varargs=None, varkw=None, defaults=(1, 2), - kwonlyargs=[], kwonlydefaults={}, + kwonlyargs=[], kwonlydefaults=None, annotations={}) partial = functools.partial(test_function_for_partial1, 1) self.assertEqual(expected, parser._get_arg_spec(partial)) expected = tf_inspect.FullArgSpec(args=['kwarg2'], varargs=None, varkw=None, defaults=(2,), - kwonlyargs=[], kwonlydefaults={}, + kwonlyargs=[], kwonlydefaults=None, annotations={}) partial = functools.partial(test_function_for_partial1, 1, 2, 3) self.assertEqual(expected, parser._get_arg_spec(partial)) @@ -440,21 +440,21 @@ class ParserTest(googletest.TestCase): # Make sure setting kwargs works. expected = tf_inspect.FullArgSpec(args=['arg1', 'arg2', 'kwarg2'], varargs=None, varkw=None, defaults=(2,), - kwonlyargs=[], kwonlydefaults={}, + kwonlyargs=[], kwonlydefaults=None, annotations={}) partial = functools.partial(test_function_for_partial1, kwarg1=0) self.assertEqual(expected, parser._get_arg_spec(partial)) expected = tf_inspect.FullArgSpec(args=['arg1', 'arg2', 'kwarg1'], varargs=None, varkw=None, defaults=(1,), - kwonlyargs=[], kwonlydefaults={}, + kwonlyargs=[], kwonlydefaults=None, annotations={}) partial = functools.partial(test_function_for_partial1, kwarg2=0) self.assertEqual(expected, parser._get_arg_spec(partial)) expected = tf_inspect.FullArgSpec(args=['arg1'], varargs=None, varkw=None, defaults=(), - kwonlyargs=[], kwonlydefaults={}, + kwonlyargs=[], kwonlydefaults=None, annotations={}) partial = functools.partial(test_function_for_partial1, arg2=0, kwarg1=0, kwarg2=0) @@ -464,7 +464,7 @@ class ParserTest(googletest.TestCase): expected = tf_inspect.FullArgSpec(args=[], varargs='my_args', varkw='my_kwargs', defaults=(), - kwonlyargs=[], kwonlydefaults={}, + kwonlyargs=[], kwonlydefaults=None, annotations={}) partial = functools.partial(test_function_for_partial2, 0, 1) self.assertEqual(expected, parser._get_arg_spec(partial)) -- 2.7.4