Pylint: "Module 'numpy' has no ... member" error with PyLint 1.8.3

Created on 29 Mar 2018  路  8Comments  路  Source: PyCQA/pylint

Steps to reproduce

  1. Use pylint from within Visual Studio Code (I'm using the Insiders build, 1.22.0-insider).

Current behavior

This example triggers E1101:Module 'numpy.random' has no 'RandomState' member, even though the IntelliSense help can perfectly find the class:

import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

sns.set(style="dark")
rs = np.random.RandomState(50)

# Set up the matplotlib figure
f, axes = plt.subplots(3, 3, figsize=(9, 9), sharex=True, sharey=True)

# Rotate the starting point around the cubehelix hue circle
for ax, s in zip(axes.flat, np.linspace(0, 3, 10)):

    # Create a cubehelix colormap to use with kdeplot
    cmap = sns.cubehelix_palette(start=s, light=1, as_cmap=True)

    # Generate and plot a random bivariate dataset
    x, y = rs.randn(2, 50)
    sns.kdeplot(x, y, cmap=cmap, shade=True, cut=5, ax=ax)
    ax.set(xlim=(-3, 3), ylim=(-3, 3))

f.tight_layout()
plt.show()

Expected behavior

No errors with the given example.

pylint --version output

No config file found, using default configuration
pylint 1.8.3,
astroid 1.6.2
Python 3.6.4 (default, Mar 22 2018, 14:11:17)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]

astroid brain bug

Most helpful comment

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

All 8 comments

Thanks for the report!

THis is fixed on master with the --extension-pkg-whitelist=numpy option.

That is with pylint==2.0 and astroid==2.0

E1101:Module 'numpy.random' has no 'RandomState' member

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

Though using @lai-bluejay solution there will be no error when importing a non-existing member of numpy.
For example

import numpy as np

np.non_existing()  # no error here

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

pylint: error: no such option: --generate-members

setting this in my pyproject.toml works for me:

 [tool.pylint.MASTER]
 load-plugins = "pylint_django"
+extension-pkg-whitelist = "numpy"
+

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hubro picture Hubro  路  3Comments

mrginglymus picture mrginglymus  路  3Comments

thanatos picture thanatos  路  3Comments

GergelyKalmar picture GergelyKalmar  路  3Comments

pylint-bot picture pylint-bot  路  3Comments