-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Improve the situation for no-name-in-module
for C extensions and modules using dynamic features
#1524
Comments
Please provide a minimal working example, I'm not sure I completely understand what is happening, especially since the error you posted indicate something more complex going on than the first import. |
You can easily reproduce it with the following procedure:
|
I see the same behaviour with another library. Any idea how to fix this? |
Same problem here. Any idea/reference to fix this issue? It is really annoying to have these false positives. |
Same problem here with gevent.ssl. Python 2.7.12. gevent 1.2.2
And another very common one also reported as non-existent, in this case as no-member,
Have to disable no-name-in-module for now. Maybe it's related error but I also get a warning on this, Incidentally I am not using virtualenv here. This is system wide python. |
It seems duplicated. #1138 |
@neocogent |
I'm running into a similar issue at my work with a pure python sub-package. |
I'm an year late, but still seeing the exact same behaviour with As I'm using vscode, this issue causes workspace errors to render in a misleading and incorrect way. To quickly reproduce, install Running $ pylint some.py
No config file found, using default configuration
************* Module some
C: 1, 0: Final newline missing (missing-final-newline)
C: 1, 0: Missing module docstring (missing-docstring)
E: 1, 0: No name 'python' in module 'tensorflow' (no-name-in-module)
W: 1, 0: Unused file_io imported from tensorflow.python.lib.io (unused-import)
-----------------------------------------------------------------------
Your code has been rated at -70.00/10 (previous run: -40.00/10, -30.00) For these specs $ pylint --version
No config file found, using default configuration
pylint 1.9.2,
astroid 1.6.5
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] @PCManticore I'd consider the above a minimal working example for this issue, can you review it to maybe consider reopening this one? |
|
Another datapoint here:
|
Folks, before commenting here, do make sure to do the following:
|
Tested I'll open an issue for mine but it's unfortunately not an open source project causing this issue so I won't be able to point to a specific project link. =( |
Is there any guidance on how to bypass the tensorflow.python issue mentioned by @jcezarms above? i'd like to avoid disabling the no-name-in-module error just to get past this false positive. |
E0611 will incorrectly flag tensorflow.python due to a pylint bug [0]. Thus, we need to add inline disabling for this import. [0] pylint-dev/pylint#1524 (comment)
E0611 will incorrectly flag tensorflow.python due to a pylint bug [0]. Thus, we need to add inline disabling for this import. [0] pylint-dev/pylint#1524 (comment)
In VSCode, I had to set
to get rid of the false positives. |
any updates? |
It happens with specific names of python modules, not sure why though. |
also happens with from win32api import GetShortPathName which throws
|
This error usually happens because the given module is either a C extension, so a static analysis tool can't read that source code to figure out the members, or the module tries to be too smart by using dynamic features such as
|
no-name-in-module
for C extensions and modules using dynamic features
A suggestion to others who encounter this: ensure that your LD_LIBRARY_PATH (or similar) contains paths to all the dependencies of the module you're trying to import. I had failures like the above when importing a C extension that depended on other extensions, and fixing LD_LIBRARY_PATH apparently made the problem go away. |
I'm running into this issue (and several others) but only on our build machine. Both use pylint Given... from pydantic import BaseModel Locally (MacOS Mojave 10.14.6) I see no errors. However, on our build machine (Ubuntu 18.04.1 LTS) I see:
|
The same thing happens here. Works on Windows, while fails on Ubuntu. What can we do about it? |
Same happens with AFAIK it is reproducible on every kind of system, but if you want a simple test scenario you could get one with this:
Installing
|
@djelekar same situation. If you discover a better solution than just putting |
This problem also occurs when using Python with Apache Spark via the To reproduce, just install the module as above and import any functions from |
This fails on OSX, as well. If you look at where pydantic is installed, you'll see that it precompiled itself, so you're actually importing Is there a way for pylint to detect the |
pylint still complains about a range(len()) instead of enumerate in a test, and also about the Dataset from netCDF4, but this seems to be a broad problem that I don't know how to handle (pylint-dev/pylint#2932, pylint-dev/pylint#1524). Maybe you can help with this, @marstaa?) The previous commits also refer to #6.
pylint still complains about a range(len()) instead of enumerate in a test, and also about the Dataset from netCDF4, but this seems to be a broad problem that I don't know how to handle (pylint-dev/pylint#2932, pylint-dev/pylint#1524). Maybe you can help with this, @marstaa?) The previous commits also refer to #6.
Adding my two cents here: From the
So it seems Note that, if you are using static type checking, you can still create Interestingly, when Although Rest assured, your extension modules are typed (if they have stubs! 😄), but just be sure to |
How do you get pylint to read a |
Support is pending in pylint 3.1, see pylint-dev/astroid#2375 |
Thanks @adam-grant-hendry for the write up! Closing as resolved. pyi support tracked separately. |
I have the ProxyTypes package installed and have a file
mymodule.py
that imports it like:However, pylint throws this false error for it:
Pylint should reference the
peak
package installed into my virtualenv, and not assume it's a local non-existent module.The text was updated successfully, but these errors were encountered: