def new_func(*args, **kwargs): """Deprecation wrapper.""" # TODO(apassos) figure out a way to have reasonable performance with # deprecation warnings and eager mode. if is_in_graph_mode.IS_IN_GRAPH_MODE() and _PRINT_DEPRECATION_WARNINGS: invalid_args = [] named_args = tf_inspect.getcallargs(func, *args, **kwargs) for arg_name, spec in iter(deprecated_positions.items()): if (spec.position < len(args) and not (spec.has_ok_value and _same_value(named_args[arg_name], spec.ok_value))): invalid_args.append(arg_name) 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.varkw) for arg_name in deprecated_arg_names: if (arg_name in kwargs and not (deprecated_positions[arg_name].has_ok_value and _same_value(named_args[arg_name], deprecated_positions[arg_name].ok_value))): invalid_args.append(arg_name) for arg_name in invalid_args: if (func, arg_name) not in _PRINTED_WARNING: if warn_once: _PRINTED_WARNING[(func, arg_name)] = True logging.warning( 'From %s: calling %s (from %s) with %s is deprecated and will ' 'be removed %s.\nInstructions for updating:\n%s', _call_location(), decorator_utils.get_qualified_name(func), func.__module__, arg_name, 'in a future version' if date is None else ('after %s' % date), instructions) return func(*args, **kwargs)
def new_func(*args, **kwargs): logging.warning( '%s (from %s) is deprecated and will be removed after %s.\n' 'Instructions for updating:\n%s', decorator_utils.get_qualified_name(func), func.__module__, date, instructions) return func(*args, **kwargs)
def new_func(*args, **kwargs): """Deprecation wrapper.""" invalid_args = [] named_args = tf_inspect.getcallargs(func, *args, **kwargs) for arg_name, spec in iter(deprecated_positions.items()): if (spec.position < len(args) and not (spec.has_ok_value and _same_value(named_args[arg_name], spec.ok_value))): invalid_args.append(arg_name) 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) for arg_name in deprecated_arg_names: if (arg_name in kwargs and not (deprecated_positions[arg_name].has_ok_value and _same_value(named_args[arg_name], deprecated_positions[arg_name].ok_value))): invalid_args.append(arg_name) for arg_name in invalid_args: logging.warning( 'From %s: calling %s (from %s) with %s is deprecated and will ' 'be removed %s.\nInstructions for updating:\n%s', _call_location(), decorator_utils.get_qualified_name(func), func.__module__, arg_name, 'in a future version' if date is None else ('after %s' % date), instructions) return func(*args, **kwargs)
def new_func(*args, **kwargs): """Deprecation wrapper.""" invalid_args = [] named_args = inspect.getcallargs(func, *args, **kwargs) for arg_name, spec in iter(deprecated_positions.items()): if spec.position < len(args) and not (spec.has_ok_value and named_args[arg_name] == spec.ok_value): invalid_args.append(arg_name) 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) for arg_name in deprecated_arg_names: if arg_name in kwargs and not ( deprecated_positions[arg_name].has_ok_value and (named_args[arg_name] == deprecated_positions[arg_name].ok_value) ): invalid_args.append(arg_name) for arg_name in invalid_args: logging.warning( "From %s: calling %s (from %s) with %s is deprecated and will " "be removed after %s.\nInstructions for updating:\n%s", _call_location(), decorator_utils.get_qualified_name(func), func.__module__, arg_name, date, instructions, ) return func(*args, **kwargs)
def new_func(*args, **kwargs): logging.warning( 'From %s: %s (from %s) is deprecated and will be removed %s.\n' 'Instructions for updating:\n%s', _call_location(), decorator_utils.get_qualified_name(func), func.__module__, 'in a future version' if date is None else ('after %s' % date), instructions) return func(*args, **kwargs)
def new_func(*args, **kwargs): """Deprecation wrapper.""" named_args = inspect.getcallargs(func, *args, **kwargs) for arg_name, arg_value in deprecated_kwargs.items(): if arg_name in named_args and named_args[arg_name] == arg_value: logging.warning( 'From %s: calling %s (from %s) with %s=%s is deprecated and will ' 'be removed after %s.\nInstructions for updating:\n%s', _call_location(), decorator_utils.get_qualified_name(func), func.__module__, arg_name, arg_value, date, instructions) return func(*args, **kwargs)
def new_func(*args, **kwargs): logging.warning( "From %s: %s (from %s) is deprecated and will be removed " "after %s.\n" "Instructions for updating:\n%s", _call_location(), decorator_utils.get_qualified_name(func), func.__module__, date, instructions, ) return func(*args, **kwargs)
def new_func(*args, **kwargs): # pylint: disable=missing-docstring if _PRINT_DEPRECATION_WARNINGS: if func not in _PRINTED_WARNING: if warn_once: _PRINTED_WARNING[func] = True logging.warning( 'From %s: %s (from %s) is deprecated and will be removed %s.\n' 'Instructions for updating:\n%s', _call_location(), decorator_utils.get_qualified_name(func), func.__module__, 'in a future version' if date is None else ('after %s' % date), instructions) return func(*args, **kwargs)
def new_func(*args, **kwargs): """Deprecation wrapper.""" if _PRINT_DEPRECATION_WARNINGS: named_args = tf_inspect.getcallargs(func, *args, **kwargs) for arg_name, arg_value in deprecated_kwargs.items(): if arg_name in named_args and named_args[arg_name] == arg_value: if (func, arg_name) not in _PRINTED_WARNING: if warn_once: _PRINTED_WARNING[(func, arg_name)] = True logging.warning( 'From %s: calling %s (from %s) with %s=%s is deprecated and ' 'will be removed %s.\nInstructions for updating:\n%s', _call_location(), decorator_utils.get_qualified_name(func), func.__module__, arg_name, arg_value, 'in a future version' if date is None else ('after %s' % date), instructions) return func(*args, **kwargs)
def new_func(*args, **kwargs): """Deprecation wrapper.""" invalid_args = [] for (i, arg_name) in deprecated_positions: if i < len(args): invalid_args.append(arg_name) 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) for arg_name in deprecated_arg_names: if arg_name in kwargs: invalid_args.append(arg_name) for arg_name in invalid_args: logging.warning( 'From %s: calling %s (from %s) with %s is deprecated and will ' 'be removed after %s.\nInstructions for updating:\n%s', _call_location(), decorator_utils.get_qualified_name(func), func.__module__, arg_name, date, instructions) return func(*args, **kwargs)
def new_func(*args, **kwargs): """Deprecation wrapper.""" invalid_args = [] for (i, arg_name) in deprecated_positions: if i < len(args): invalid_args.append(arg_name) 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) for arg_name in deprecated_arg_names: if arg_name in kwargs: invalid_args.append(arg_name) for arg_name in invalid_args: logging.warning( 'Calling %s (from %s) with %s is deprecated and will be removed ' 'after %s.\nInstructions for updating:\n%s', decorator_utils.get_qualified_name(func), func.__module__, arg_name, date, instructions) return func(*args, **kwargs)
def deprecated_wrapper(wrapped, instance, args, kwargs): _validate_deprecation_args(date, instructions) if _PRINT_DEPRECATION_WARNINGS: class_or_func_name = decorator_utils.get_qualified_name(wrapped) if class_or_func_name not in _PRINTED_WARNING: if warn_once: _PRINTED_WARNING[class_or_func_name] = True logging.warning( 'From %s: %s (from %s) is deprecated and will be removed %s.\n' 'Instructions for updating: %s\n' % ( _call_location(), class_or_func_name, wrapped.__module__, 'in a future version' if date is None else ('after %s' % date), instructions ) ) return wrapped(*args, **kwargs)
def new_func(*args, **kwargs): """Deprecation wrapper.""" # TODO(apassos) figure out a way to have reasonable performance with # deprecation warnings and eager mode. if is_in_graph_mode.IS_IN_GRAPH_MODE( ) and _PRINT_DEPRECATION_WARNINGS: invalid_args = [] named_args = tf_inspect.getcallargs(func, *args, **kwargs) for arg_name, spec in iter(deprecated_positions.items()): if (spec.position < len(args) and not (spec.has_ok_value and _same_value( named_args[arg_name], spec.ok_value))): invalid_args.append(arg_name) 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.varkw) for arg_name in deprecated_arg_names: if (arg_name in kwargs and not ( deprecated_positions[arg_name].has_ok_value and _same_value( named_args[arg_name], deprecated_positions[arg_name].ok_value))): invalid_args.append(arg_name) for arg_name in invalid_args: if (func, arg_name) not in _PRINTED_WARNING: if warn_once: _PRINTED_WARNING[(func, arg_name)] = True logging.warning( 'From %s: calling %s (from %s) with %s is deprecated and will ' 'be removed %s.\nInstructions for updating:\n%s', _call_location(), decorator_utils.get_qualified_name(func), func.__module__, arg_name, 'in a future version' if date is None else ('after %s' % date), instructions) return func(*args, **kwargs)
def deprecated_wrapper(wrapped, instance, args, kwargs): _validate_deprecation_args(date, instructions) if _PRINT_DEPRECATION_WARNINGS: class_or_func_name = decorator_utils.get_qualified_name(wrapped) if class_or_func_name not in _PRINTED_WARNING: if warn_once: _PRINTED_WARNING[class_or_func_name] = True from tensorlayer import logging logging.warning( '%s: `%s.%s` (in file: %s) is deprecated and will be removed %s.\n' 'Instructions for updating: %s\n' % ( "Class" if inspect.isclass(wrapped) else "Function", wrapped.__module__, class_or_func_name, wrapped.__code__.co_filename, 'in a future version' if date is None else ('after %s' % date), instructions ) ) return wrapped(*args, **kwargs)
def test_method(self): self.assertEqual( "GetQualifiedNameTest.test_method", decorator_utils.get_qualified_name(GetQualifiedNameTest.test_method))
def test_function(self): self.assertEqual("_test_function", decorator_utils.get_qualified_name(_test_function))
def test_method(self): self.assertEqual( "GetQualifiedNameTest.test_method", decorator_utils.get_qualified_name( GetQualifiedNameTest.test_method))
def new_func(*args, **kwargs): logging.warning( '%s (from %s) is experimental and may change or be removed at ' 'any time, and without warning.', decorator_utils.get_qualified_name(func), func.__module__) return func(*args, **kwargs)
def test_function(self): self.assertEqual( "_test_function", decorator_utils.get_qualified_name(_test_function))