rope
rope copied to clipboard
Rope does not comply with the MRO
When looking for the definition of a method invoked with super,
Rope seem to perform a depth-first search in the inheritance graph of the class,
while Python actually does a breadth-first search (the so called MRO).
The code below demonstrate the problem:
# diamond inheritance
#
# A
# / \
# B C
# \ /
# D
class A(object):
def method(self):
return "I'm an A"
class B(A):
# do not override method
pass
class C(A):
def method(self):
return "I'm a C"
class D(B, C):
def method(self):
return super(D, self).method() + " and a D"
# the super method above is C.method,
# but rope will send me to A.method
# when I ask to go to the definition
print D().method()
# will display "I'm a C and a D"
@aligrudi any idea about this? Can we somehow visualize the AST tree we get?
Matěj Cepl [email protected] wrote:
@aligrudi any idea about this? Can we somehow visualize the AST tree we get?
I think it is possible to support MRO; one can start by modifying PyClass._create_concluded_attributes() in pyobjectsdef.py. However, the additional overhead may be very large.
Ali