37
votes

Is there anyway to hide E1101 errors for objects that are created from a specific library? Our large repository is littered with #pylint: disable=E1101 around various objects created by pandas.

For example, pylint will throw a no member error on the following code:

import pandas.io.data
import pandas as pd
spy = pandas.io.data.DataReader("SPY", "yahoo")
spy.to_csv("test.csv")
spy = pd.read_csv("test.csv")
close_px = spy.ix["2012":]

Will have the following errors:

E:  6,11: Instance of 'tuple' has no 'ix' member (no-member)
E:  6,11: Instance of 'TextFileReader' has no 'ix' member (no-member)
3
Would it be correct to assume that you do not wish to globally disable this error check? - shuttle87
I don't want to globally disable it. I want to disable it for anything created by pandas. - Michael WS
The discussion around this answer might convince you that you probably can't, but you can tell pylint to ignore errors on individual lines: stackoverflow.com/a/26668602/270001 - Peter Groves
Would it be helpful to you to have a hierarchy of config files such that the setting is allowed globally by default, but you have more restrictive configs in folders specific to these modules? Ref: stackoverflow.com/a/19308989/3182836 - binarysubstrate
honestly, it wouldn't. So many modules we use rely on various pandas functionality. - Michael WS

3 Answers

33
votes

You can mark their attributes as dynamically generated using generated-members option.

E.g. for pandas:

generated-members=pandas.*
10
votes

This failed for me trying to ignore errors in numpy, until I tried

generated-members=np.*

since, like most everybody, I do

import numpy as np

Since generated-members takes a list, one might do:

generated-members=numpy.*,np.*
4
votes

Additional information, on top of the answer from carabas:

You will find generated-members in the TYPECHECK section of .pylintrc.
Here is the default one:

[TYPECHECK]
…
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E0201 when accessed.
generated-members=REQUEST,acl_users,aq_parent

Note that the comment about suppressing E0201 is incomplete.
So you have to update this to:

# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E0201 or E1101 when accessed.
generated-members=REQUEST,acl_users,aq_parent,pandas.*