You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
astroid currently does not account for numpy.append as mentioned in #664. An example of the problem is the following file:
import numpy as np
a = np.append([0], 0)
a = -a
which produces the following errors in pylint:
/tmp/test.py:3:4: E1130: bad operand type for unary -: tuple (invalid-unary-operand-type)
/tmp/test.py:3:4: E1130: bad operand type for unary -: list (invalid-unary-operand-type)
These errors are generated for pylint=1.7.2, astroid=1.5.3 and numpy=1.16.2. The errors are not generated for numpy=1.15.4.
The text was updated successfully, but these errors were encountered:
Thanks for the bug report @willsALMANJ.
The problems comes from the fact that the append function is not correctly inferred as a numpy.ndarray.
I'll try to add a brain for this function ASAP.
@willsALMANJ just a few words to explain why your issue is not yet solved.
There is no need to add the function append into a numpy brain as this function is defined inside a standard python module inside numpy. The problem arises when astroid tries to infer the result of the call to append. By analyzing the source, astroid is aware that the result of append comes from the call to numpy's concatenate function. This function is defined inside the brain_numpy_core_multiarrayastroid module and so should be correctly inferred.
I'am still investigating.
…current node is an astroid.Name instance
The problem was that astroid could not infer the result of a call to `numpy.append`
because this function calls the `concatenate` function.
This last function is inferred thanks to the `brain_numpy_core_multiarray` module
but only when the corresponding node is an `astroid.Attribute` (for example numpy.concatenate).
It turns out that in the source of the append function the node that realises the call to concatenate is a `astroid.Name`. Thus the correction proposed here is to register
the concatenate inference tip function in order to apply it, also, to `astroid.Name`.
Close#666
Steps to reproduce
astroid currently does not account for
numpy.append
as mentioned in #664. An example of the problem is the following file:which produces the following errors in pylint:
These errors are generated for pylint=1.7.2, astroid=1.5.3 and numpy=1.16.2. The errors are not generated for numpy=1.15.4.
The text was updated successfully, but these errors were encountered: