pylint-bot / astroid-unofficial

UNOFFICIAL playground for astroid github migration
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Don't look in the parents of a class if the init constructor is redefined and super is not called #156

Open pylint-bot opened 9 years ago

pylint-bot commented 9 years ago

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: PCManticore)


The following code shows that if a member is not found in the current class, it will be looked into the parent, even though the __init__ was changed and the parent's init wasn't called.

#!python

from astroid.test_utils import extract_node
n = extract_node('''
class A(object):
   def __init__(self):
      self.value = 42
   def __add__(self, other):
      return other.value + self.value / 2
class B(A):
   def __init__(self):
      self.value1 = 24
   def __radd__(self, other):
      return NotImplemented
A() + B()
B().value
''')
print(repr(n))
inferred = next(n.infer())
print(next(inferred.igetattr('value')).value)