Disabling Pylint no member- E1101 error for specif

2019-02-04 05:59发布

问题:

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)

回答1:

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

E.g. for pandas:

generated-members=pandas.*


回答2:

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.*


标签: pandas pylint