如果我们使用pandas类实例,pylint会抱怨

use*_*834 5 python pylint

pylint抱怨pandas类实例::

我有db实例,有data(熊猫Dataframe)作为实例.

如果我打电话给例如iloc或形状::

cols = db.data.shape
xxx = db.data.iloc[1:4, 0:9]
Run Code Online (Sandbox Code Playgroud)

pylint抱怨::

E: 36,18: Instance of 'TextFileReader' has no 'iloc' member (no-member)
E: 92,30: Instance of 'TextFileReader' has no 'shape' member (no-member)
E: 92,30: Instance of 'tuple' has no 'shape' member (no-member)
Run Code Online (Sandbox Code Playgroud)

我试过如何让PyLint识别numpy成员?禁用Pylint没有成员 - E1101错误的特定库没有成功.

Ray*_*out 2

这似乎是一个悬而未决的问题,因为pylint截至 2022 年 3 月 14 日,该问题已被标记为高度优先。

该问题源于底层 AST 引擎,该引擎pylint在运行时可以进行的推理数量受到限制,以提高性能。

为了防止上述链接失效,解决方法如下:

pylint some_file_to_lint.py --init-hook "import astroid; astroid.context.InferenceContext.max_inferred = 500"
Run Code Online (Sandbox Code Playgroud)

或者在.pylintrc

[MASTER]

init-hook = "import astroid; astroid.context.InferenceContext.max_inferred = 500"
Run Code Online (Sandbox Code Playgroud)