pylint icon indicating copy to clipboard operation
pylint copied to clipboard

Wrong report "instance of * has not * member" (E1101)

Open ttoommxx opened this issue 1 year ago • 0 comments

Bug description

I have created two classes, one which is a list node (Node), and another one whose attribute is the head of the node (Source). I have set up Source via "setattr" and "getattr" so that, when I called for a member called "index" via "source.index" (where source is an instance of Source), it will got fetch index from the head of node (instance of Node). This is permitted by Python, though it might not be a good practice. However PyLint cannot find "index" and reports problem E1101. I understand that PyLint is not able to analyse the code at runtime, however I think it'd be better to address the problem differently. For example it should say that it is not good practise to use "setattr" at all.

Configuration

No response

Command used

VScode Microsoft official extension

Pylint output

Instance of 'Source' has no 'index' member Pylint(E1011:no-member)

Expected behavior

I am not sure of what the right behaviour should be, just doubt reporting missing variable is the right approach when Pyling detects that "setattr" and "getattr" are used within the class.

Pylint version

pylint 3.0.3
python 3.12.1

OS / Environment

Fedora 39 Workstation

Additional dependencies

No response

ttoommxx avatar Jan 17 '24 11:01 ttoommxx