-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
"Module 'numpy' has no ... member" error even with extension-pkg-whitelist=numpy set in pylint.rc #779
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
Comments
Can you post an example for which you get the error? |
import numpy as np Pylint says: It does this for every other numpy dtype that has a byte number following the dtype name or np.str_ |
I'm also getting the same issue with pylint versions |
I didn't have time to look into this just yet, but I presume that astroid.brain can't find the place where float64 is created (https://github.com/PyCQA/astroid/blob/master/astroid/brain/brain_numpy.py). What could move this forward would be to see where exactly np.float64 is defined and what's different about in in brain_numpy.py. With this information, we might modify brain_numpy accordingly. |
I have this issue for all numpy functions as if 'extension-pkg-whitelist=numpy' would have no influence. pylint version, astroid 1.4.4 |
I'm not sure if all of them are like that, but there are some of them which are generated dynamically somewhere around in this file https://github.com/numpy/numpy/blob/master/numpy/core/numerictypes.py. extension-pkg-whitelist does not help in this case, but providing some hints would lead to a better result. |
Also affects pylint 1.6.5, even with import numpy
numpy.float64 the output (incorrectly) is:
|
me too
and in vim with |
@PCManticore is this anything that will be prioritized? Do you have any idea what can be done to fix this issue? I'm thinking especially getting |
|
As a workaround, I have created a small PyLint plugin, which will silence such warnings: from astroid import MANAGER
from astroid import scoped_nodes
import numpy
def register(linter):
pass
def transform(modu):
if modu.name == 'numpy':
for f in numpy.__dict__.keys():
modu.locals[f] = [scoped_nodes.Class(f, None)]
MANAGER.register_transform(scoped_nodes.Module, transform) |
still present with
|
@PCManticore it's still not working with:
|
The same happens with
causes an error:
Pylint:
|
We use a generated .pylintrc. Important notices: * Linting members of numpy and twisted.internet.reactor is disabled due to a bug in pylint. See pylint-dev/pylint#779 * We ignore minilight since it's a forked third-party codebase * For the configuration ease we enabled `unsafe-load-any-extension`. This makes it trivial to lint C modules. Alternatively, we could simply whitelist them with `extension-pkg-whitelist` but this would be tedious. * Only changed files will be linted in CircleCI.
We use a generated .pylintrc. Important notices: * Linting members of numpy and twisted.internet.reactor is disabled due to a bug in pylint. See pylint-dev/pylint#779 * We ignore minilight since it's a forked third-party codebase * For the configuration ease we enabled `unsafe-load-any-extension`. This makes it trivial to lint C modules. Alternatively, we could simply whitelist them with `extension-pkg-whitelist` but this would be tedious. * Only changed files will be linted in CircleCI.
We use a generated .pylintrc. Important notices: * Linting members of numpy and twisted.internet.reactor is disabled due to a bug in pylint. See pylint-dev/pylint#779 * We ignore minilight since it's a forked third-party codebase * For the configuration ease we enabled `unsafe-load-any-extension`. This makes it trivial to lint C modules. Alternatively, we could simply whitelist them with `extension-pkg-whitelist` but this would be tedious. * Only changed files will be linted in CircleCI. * The list of disabled checks is intented to be small. We will disable the check we find useless/inappropriate/overzealous as we encounter them in the code.
We use a generated .pylintrc. Important notices: * Linting members of numpy and twisted.internet.reactor is disabled due to a bug in pylint. See pylint-dev/pylint#779 * We ignore minilight since it's a forked third-party codebase * For the configuration ease we enabled `unsafe-load-any-extension`. This makes it trivial to lint C modules. Alternatively, we could simply whitelist them with `extension-pkg-whitelist` but this would be tedious. * Only changed files will be linted in CircleCI. * The list of disabled checks is intented to be small. We will disable the check we find useless/inappropriate/overzealous as we encounter them in the code.
We use a generated .pylintrc. Important notices: * Linting members of numpy and twisted.internet.reactor is disabled due to a bug in pylint. See pylint-dev/pylint#779 * We ignore minilight since it's a forked third-party codebase * For the configuration ease we enabled `unsafe-load-any-extension`. This makes it trivial to lint C modules. Alternatively, we could simply whitelist them with `extension-pkg-whitelist` but this would be tedious. * Only changed files will be linted in CircleCI. * The list of disabled checks is intented to be small. We will disable the check we find useless/inappropriate/overzealous as we encounter them in the code.
We use a generated .pylintrc. Important notices: * Linting members of numpy and twisted.internet.reactor is disabled due to a bug in pylint. See pylint-dev/pylint#779 * We ignore minilight since it's a forked third-party codebase * For the configuration ease we enabled `unsafe-load-any-extension`. This makes it trivial to lint C modules. Alternatively, we could simply whitelist them with `extension-pkg-whitelist` but this would be tedious. * Only changed files will be linted in CircleCI. * The list of disabled checks is intented to be small. We will disable the check we find useless/inappropriate/overzealous as we encounter them in the code.
We use a generated .pylintrc. Important notices: * Linting members of numpy and twisted.internet.reactor is disabled due to a bug in pylint. See pylint-dev/pylint#779 * We ignore minilight since it's a forked third-party codebase * For the configuration ease we enabled `unsafe-load-any-extension`. This makes it trivial to lint C modules. Alternatively, we could simply whitelist them with `extension-pkg-whitelist` but this would be tedious. * Only changed files will be linted in CircleCI. * The list of disabled checks is intented to be small. We will disable the check we find useless/inappropriate/overzealous as we encounter them in the code.
We use a generated .pylintrc. Important notices: * Linting members of numpy and twisted.internet.reactor is disabled due to a bug in pylint. See pylint-dev/pylint#779 * We ignore minilight since it's a forked third-party codebase * For the configuration ease we enabled `unsafe-load-any-extension`. This makes it trivial to lint C modules. Alternatively, we could simply whitelist them with `extension-pkg-whitelist` but this would be tedious. * Only changed files will be linted in CircleCI. * The list of disabled checks is intented to be small. We will disable the check we find useless/inappropriate/overzealous as we encounter them in the code.
We use a generated .pylintrc. Important notices: * Linting members of numpy and twisted.internet.reactor is disabled due to a bug in pylint. See pylint-dev/pylint#779 * We ignore minilight since it's a forked third-party codebase * For the configuration ease we enabled `unsafe-load-any-extension`. This makes it trivial to lint C modules. Alternatively, we could simply whitelist them with `extension-pkg-whitelist` but this would be tedious. * Only changed files will be linted in CircleCI. * The list of disabled checks is intented to be small. We will disable the check we find useless/inappropriate/overzealous as we encounter them in the code.
We use a generated .pylintrc. Important notices: * Linting members of numpy and twisted.internet.reactor is disabled due to a bug in pylint. See pylint-dev/pylint#779 * We ignore minilight since it's a forked third-party codebase * For the configuration ease we enabled `unsafe-load-any-extension`. This makes it trivial to lint C modules. Alternatively, we could simply whitelist them with `extension-pkg-whitelist` but this would be tedious. * Only changed files will be linted in CircleCI. * The list of disabled checks is intented to be small. We will disable the check we find useless/inappropriate/overzealous as we encounter them in the code.
We use a generated .pylintrc. Important notices: * Linting members of numpy and twisted.internet.reactor is disabled due to a bug in pylint. See pylint-dev/pylint#779 * We ignore minilight since it's a forked third-party codebase * For the configuration ease we enabled `unsafe-load-any-extension`. This makes it trivial to lint C modules. Alternatively, we could simply whitelist them with `extension-pkg-whitelist` but this would be tedious. * Only changed files will be linted in CircleCI. * The list of disabled checks is intented to be small. We will disable the check we find useless/inappropriate/overzealous as we encounter them in the code.
We use a generated .pylintrc. Important notices: * Linting members of numpy and twisted.internet.reactor is disabled due to a bug in pylint. See pylint-dev/pylint#779 * We ignore minilight since it's a forked third-party codebase * For the configuration ease we enabled `unsafe-load-any-extension`. This makes it trivial to lint C modules. Alternatively, we could simply whitelist them with `extension-pkg-whitelist` but this would be tedious. * Only changed files will be linted in CircleCI. * The list of disabled checks is intented to be small. We will disable the check we find useless/inappropriate/overzealous as we encounter them in the code.
astroid (1.6.1) |
@hippo91 I don't think the fix is in 1.6.1; it's on 1.6.x but by my reading of pylint-dev/astroid#486 we're not going to see it until 1.6.2 which hasn't been released by @PCManticore yet? |
Yes, 1.6.2 is not yet released, I'll do it today. Also folks please take some time to appreciate the tremendous work that @hippo91 is doing with this issue, this one wasn't easy and as a result of his work, numpy's support is getting top notch. |
astroid (1.6.1) |
I just tested these latest versions with the example I gave above and on my python projects. No more need to declare numpy in the Many thanks @hippo91 for the great work! Tested with versions:
|
@dinio31 thank you for your reply! |
I still see
and
should I open a new issue? |
@sam-s yes, please. |
The numpy support has nothing to do with cv2. Please open a separate issue. |
@PCManticore Sorry, it was mentioned here once by @akorp, that's why I brought it up again. |
Same issues here with cv2 pylint 1.9.2, |
Still broken with OpenCV v4: |
@PaulStubbs thanks for the report. |
@PaulStubbs |
If you don't want to add more config, please add this code to your config file, instead of 'whitelist'. {
"python.linting.pylintArgs": ["--generate-members"],
} relevent question: how-do-i-get-pylint-to-recognize-numpy-member |
I am facing the same problem with updated pylint (2.148.0) for |
I see
(despite Should I open a new issue? |
@sam-s, if i remember correctly, |
That pylint option is incorrect and actually makes pylint silently fail, thus making it look as though there are no errors, ever. The correct snippet is: {
"python.linting.pylintArgs": ["--generated-members=numpy.*"],
} However, this still does not work in VSCode. I am getting
Should I open a new issue pertaining to this particular case of |
Done, it works for me Note: Make sure you choose "Preferences: Open Settings (JSON)", not "Preferences: Open Default Settings (JSON)" Setting File would look like { |
@Alamnoor I can assure you that it's not working. Try making a deliberate error and run pylint with that option. You will find out that you still get zero errors. The reason is that the option you added is not a real pylint option and it will cause pylint to fail silently when run through vscode. You can verify this by running pylint manually from the command line with that option and you will see the suppressed error. See my comment above for an explanation. |
.pylintrc
PyLint
Versions
|
I'm always receiving "Module 'numpy' has no member" error when I run pylint on my code, even though I have set
extension-pkg-whitelist=numpy
in my pylint.rc file
Numpy version = 1.5.2
Astroid version = 1.4.3
The text was updated successfully, but these errors were encountered: