pylint
pylint copied to clipboard
Tensorflow: bad operand type for unary - false positive
Bug description
The pylint on the code
import tensorflow as tf
a = - tf.math.log(1.)
causes following warning
test:2:4: E1130: bad operand type for unary -: object (invalid-unary-operand-type)
I guess I can simply disable it. However, I find this strange, whereas a = - tf.math.exp(1.) doesn't cause this warning
Configuration
No response
Command used
printf "import tensorflow as tf\na = - tf.math.log(1.)\n" | pylint --from-stdin test
Pylint output
************* Module debiased_ml.test
test:1:0: C0114: Missing module docstring (missing-module-docstring)
test:2:4: E1130: bad operand type for unary -: object (invalid-unary-operand-type)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)
Expected behavior
No test:2:4: E1130: bad operand type for unary -: object (invalid-unary-operand-type) warning
Pylint version
pylint 2.14.2
astroid 2.11.6
Python 3.9.5 (default, Jun 4 2021, 12:28:51)
[GCC 7.5.0]
OS / Environment
No response
Additional dependencies
tensorflow==2.8.0
I also get some irrelevant mistakes with this code (unexpected-keyword-arg,no-value-for-parameter)
import tensorflow as tf
tf.concat([tf.constant([1, 2]), tf.constant([1, 2])], axis=0)
************* Module debiased_ml.test
test:1:0: C0114: Missing module docstring (missing-module-docstring)
test:2:0: E1123: Unexpected keyword argument 'axis' in function call (unexpected-keyword-arg)
test:2:0: E1120: No value for argument 'values' in function call (no-value-for-parameter)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)