Skip to content

False positive invalid-unary-operand-type for return value of np.diff() #2954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
eniemela3 opened this issue Jun 11, 2019 · 1 comment
Closed

Comments

@eniemela3
Copy link

Steps to reproduce

  1. Create a file, say file.py with the following contents:
import numpy as np

var = -np.diff(np.array([1, 2.5, 5]))
print(type(var))
  1. Run pylint file.py

Current behavior

Pylint output contains file.py:3:6: E1130: bad operand type for unary -: generator (invalid-unary-operand-type).

Expected behavior

The type of the return value from np.diff should be recognized correctly as a ndarray, not a generator, and the error should not be reported.

pylint --version output

pylint 2.3.1
astroid 2.2.5
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)]
@hippo91
Copy link
Contributor

hippo91 commented Jun 12, 2019

@eniemela3 thank you for the report.
It should have been corrected through pylint-dev/astroid#664.
Can you confirm please? Thanks again.

@hippo91 hippo91 closed this as completed Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants