logilab-astng #3531 Type inference on factory classmethod [resolved]
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. | |
priority | normal |
---|---|
type | bug |
done in | 0.17.0 |
load | 1.000 |
load left | 0.000 |
closed by | <not specified> |
similar entities
- logilab-astng #3207 filter infered values according to if statement
- pylint #2463 W0631 false positive when we are sure to do at least one iteration
- pylint #4024 W0631 false positive if a "else" clause is defining the loop variable
- pylint #9188 Avoidable W0631
- logilab-astng #3291 failure of inference on overloaded operators
[see all]
Comments
-
2007/02/09 08:17, written by sthenault
add commenthuum, 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.