DeprecationWarning in test_reactive_logic_unary_ops
Closed this issue · 1 comments
s-t-e-v-e-n-k commented
In Param 2.0.2 with Python 3.12, the following test case fails with a DeprecationWarning, because all warnings are treated as errors:
[ 54s] ______________________ test_reactive_logic_unary_ops[inv] ______________________
[ 54s]
[ 54s] op = <built-in function inv>
[ 54s]
[ 54s] @pytest.mark.parametrize('op', LOGIC_UNARY_OPERATORS)
[ 54s] def test_reactive_logic_unary_ops(op):
[ 54s] > assert op(rx(True)).rx.value == op(True)
[ 54s]
[ 54s] tests/testreactive.py:103:
[ 54s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 54s] param/reactive.py:249: in value
[ 54s] return self._reactive._resolve()
[ 54s] param/reactive.py:701: in _resolve
[ 54s] raise e
[ 54s] param/reactive.py:698: in _resolve
[ 54s] obj = self._eval_operation(obj, operation)
[ 54s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 54s]
[ 54s] self = <param.reactive.rx object at 0x7f6d13256000>, obj = True
[ 54s] operation = {'args': (), 'fn': <built-in function inv>, 'kwargs': {}, 'reverse': False}
[ 54s]
[ 54s] def _eval_operation(self, obj, operation):
[ 54s] fn, args, kwargs = operation['fn'], operation['args'], operation['kwargs']
[ 54s] resolved_args = []
[ 54s] for arg in args:
[ 54s] resolved_args.append(resolve_value(arg))
[ 54s] resolved_kwargs = {}
[ 54s] for k, arg in kwargs.items():
[ 54s] resolved_kwargs[k] = resolve_value(arg)
[ 54s] if isinstance(fn, str):
[ 54s] obj = getattr(obj, fn)(*resolved_args, **resolved_kwargs)
[ 54s] elif operation.get('reverse'):
[ 54s] obj = fn(resolved_args[0], obj, *resolved_args[1:], **resolved_kwargs)
[ 54s] else:
[ 54s] > obj = fn(obj, *resolved_args, **resolved_kwargs)
[ 54s] E DeprecationWarning: Bitwise inversion '~' on bool is deprecated. This returns the bitwise inversion of the underlying int object and is usually not what you expect from negating a bool. Use the 'not' operator for boolean negation or ~int(x) if you really want the bitwise inversion of the underlying int.
[ 54s]
[ 54s] param/reactive.py:991: DeprecationWarning
- I may be interested in making a pull request to address this
philippjfr commented
Thanks, the test should probably just use an int
then.