pylint-bot / test

0 stars 0 forks source link

Incorrect type inference with isinstance() #70

Open pylint-bot opened 9 years ago

pylint-bot commented 9 years ago

Originally reported by: Maarten ter Huurne (BitBucket: mthuurne, GitHub: @mthuurne?)


When I run pylint on the following code fragment:

#!python

class ClassA:
    attrib_a = 1

class ClassB:
    pass

def someFunc(obj):
    if isinstance(obj, ClassB):
        obj = ClassB()
    return isinstance(obj, ClassA) and obj.attrib_a == 0

it reports:

E: 10,39: Instance of 'ClassB' has no 'attrib_a' member (no-member)

I think there are two things wrong here:


pylint-bot commented 9 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore?):


Yeah, this is really useful for the flow control inference. I'll probably start working on flow control understanding after I release 1.5.