#3531: Type inference on factory classmethod [resolved]
#3531 - latest update on 2008/10/01, created on 2007/02/09 by Sylvain Thenault
| priority | normal |
| type | bug |
| load | 1.000 |
| load left | 0.000 |
Maarten ter Huurne posted
class Super(object):
@classmethod
def instance(cls):
return cls()
class Sub(Super):
def method(self):
print 'method called'
Sub.instance().method()
It prints:
E1101: 10: Instance of 'Super' has no 'method' member
The return type of "Sub.instance()" is "Sub", not "Super", so the method call
is valid, as you can see when you run this program.
So it seems that ASTNG infers the wrong type: "cls" is the class on which the
class method is called, which is not necessarily the class in which it is
defined.
|
| |
Comments
(add comment)huum, remember astng inference is dumb. I guess it should at least see that it may be wrong and return a YES object as well so that pylint don't issue a false positive.