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

numpy.empty is inferred as list, results in no-member #2021

Closed
bersbersbers opened this issue Apr 17, 2018 · 1 comment · Fixed by pylint-dev/astroid#664
Closed

numpy.empty is inferred as list, results in no-member #2021

bersbersbers opened this issue Apr 17, 2018 · 1 comment · Fixed by pylint-dev/astroid#664
Assignees
Labels
Bug 🪲 Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade)

Comments

@bersbersbers
Copy link

Steps to reproduce

  1. pylint pylint_bug.py

pylint_bug.py.txt

Current behavior

C:  5, 0: Constant name "MyArray" doesn't conform to UPPER_CASE naming style (invalid-name)
E:  6,22: Instance of 'list' has no 'take' member (no-member)
C:  7, 0: Constant name "MyArray" doesn't conform to UPPER_CASE naming style (invalid-name)

Expected behavior

No error (and probably, no warning).

pylint --version output

pylint 1.8.4,
astroid 1.6.3
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)]

I suspect that pylint incorrectly thinks that MyArray is a constant; then assumes from the second assignment that it is a tuple; thus concludes it is a constant tuple. Under this assumption, the error message makes sense, but the assumption is incorrect.

The same errors appear in #1981; I have no idea whether this is related.

@PCManticore PCManticore changed the title Incorrectly detected constant raises incorrect error E1101 numpy.empty is inferred as list, results in no-member Apr 24, 2018
@PCManticore
Copy link
Contributor

Thanks for the report!
The problem with constants is that pylint expects all the variables found at the global scope to respect a certain regular expression that conforms to a "constant", it expects all the variables to be upper case. That doesn't mean that the said variable needs to be a constant, it's just a matter of a convention that pylint uses.
The actual problem is the fact that we emit no-member for numpy.empty. We probably infer this as a list, while it seems it is in fact a special objects which certain attributes.

@PCManticore PCManticore added Bug 🪲 Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) labels Apr 24, 2018
@hippo91 hippo91 self-assigned this Apr 7, 2019
@hippo91 hippo91 pinned this issue Apr 7, 2019
@hippo91 hippo91 unpinned this issue Apr 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants