Skip to content
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

False positive E1130 invalid-unary-operand-type from Numpy einsum #5821

Closed
robertsont opened this issue Feb 20, 2022 · 2 comments
Closed

False positive E1130 invalid-unary-operand-type from Numpy einsum #5821

robertsont opened this issue Feb 20, 2022 · 2 comments
Labels
Lib specific 💅 This affect the code from a particular library Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@robertsont
Copy link

robertsont commented Feb 20, 2022

Bug description

It seems this bug has appeared before, for example here but was fixed by #3974. Generally, return values from numpy functions are handled correctly but pylint seems to think that the return value from numpy.einsum is of NoneType rather than ndarray. Below is a code snippet to reproduce the error.

# unary_enisum.py
# pylint: disable=missing-docstring

import numpy as np


a = np.arange(25).reshape(5, 5)
b = np.einsum("ii", a)

c = -b

Apolgies if I've missed an already opened issue for this and thanks for maintaining a great package!

Configuration

No response

Command used

pylint unary_einsum.py

Pylint output

************* Module unary_einsum
unary_einsum.py:9:4: E1130: bad operand type for unary -: NoneType (invalid-unary-operand-type)

------------------------------------
Your code has been rated at -2.50/10

Expected behavior

Passing output, i.e.


Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

Pylint version

pylint 2.12.2
astroid 2.9.3
Python 3.9.1 (default, Jan  1 2021, 01:07:55)
[GCC 7.5.0]

OS / Environment

Ubuntu 18.04.6 LTS (Bionic Beaver)

Additional dependencies

numpy version 1.22.2

@robertsont robertsont added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Feb 20, 2022
mbyrnepr2 added a commit to mbyrnepr2/astroid that referenced this issue Jun 23, 2022
@Pierre-Sassoulas Pierre-Sassoulas added Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) Needs PR This issue is accepted, sufficiently specified and now needs an implementation Lib specific 💅 This affect the code from a particular library and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jun 23, 2022
@DanielNoord DanielNoord added this to the 2.15.0 milestone Jul 6, 2022
@DanielNoord
Copy link
Collaborator

Will be fixed with astroid 2.12 thanks to @mbyrnepr2 😄

@DanielNoord
Copy link
Collaborator

This has been fixed some time ago in astroid. I'm closing 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lib specific 💅 This affect the code from a particular library Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants