diff options
author | Alexandre Passos <apassos@google.com> | 2018-08-02 10:54:44 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-08-02 11:02:41 -0700 |
commit | b42e59a82275a8a630c6f91621628a8c578f132d (patch) | |
tree | a73a283d38b9be8eb7911cc6f21f90bded0cb6ae /tensorflow/python/util | |
parent | 47db9739073e0c1aebfcdcbd3af17028d923a289 (diff) |
Do not panic on type annotations in python3 for layers / functions passed to TF.
inspect.getargspec raises errors if they are present but getfullargspec is
perfectly happy to let functions with type annotations pass.
PiperOrigin-RevId: 207127930
Diffstat (limited to 'tensorflow/python/util')
-rw-r--r-- | tensorflow/python/util/deprecation.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tensorflow/python/util/deprecation.py b/tensorflow/python/util/deprecation.py index 9e2202eaf8..74e1fb227f 100644 --- a/tensorflow/python/util/deprecation.py +++ b/tensorflow/python/util/deprecation.py @@ -388,7 +388,7 @@ def deprecated_args(date, instructions, *deprecated_arg_names_or_tuples, Args: names_to_ok_vals: dict from string arg_name to a list of values, possibly empty, which should not elicit a warning. - arg_spec: Output from tf_inspect.getargspec on the called function. + arg_spec: Output from tf_inspect.getfullargspec on the called function. Returns: Dictionary from arg_name to DeprecatedArgSpec. @@ -408,16 +408,16 @@ def deprecated_args(date, instructions, *deprecated_arg_names_or_tuples, decorator_utils.validate_callable(func, 'deprecated_args') deprecated_arg_names = _get_arg_names_to_ok_vals() - arg_spec = tf_inspect.getargspec(func) + arg_spec = tf_inspect.getfullargspec(func) deprecated_positions = _get_deprecated_positional_arguments( deprecated_arg_names, arg_spec) is_varargs_deprecated = arg_spec.varargs in deprecated_arg_names - is_kwargs_deprecated = arg_spec.keywords in deprecated_arg_names + is_kwargs_deprecated = arg_spec.varkw in deprecated_arg_names if (len(deprecated_positions) + is_varargs_deprecated + is_kwargs_deprecated != len(deprecated_arg_names_or_tuples)): - known_args = arg_spec.args + [arg_spec.varargs, arg_spec.keywords] + known_args = arg_spec.args + [arg_spec.varargs, arg_spec.varkw] missing_args = [arg_name for arg_name in deprecated_arg_names if arg_name not in known_args] raise ValueError('The following deprecated arguments are not present ' @@ -467,7 +467,7 @@ def deprecated_args(date, instructions, *deprecated_arg_names_or_tuples, if is_varargs_deprecated and len(args) > len(arg_spec.args): invalid_args.append(arg_spec.varargs) if is_kwargs_deprecated and kwargs: - invalid_args.append(arg_spec.keywords) + invalid_args.append(arg_spec.varkw) for arg_name in deprecated_arg_names: if (arg_name in kwargs and not (deprecated_positions[arg_name].has_ok_value and |