mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 05:54:25 +08:00
Better debugging output for is_sub_class_of
This commit is contained in:
@@ -84,17 +84,17 @@ def increase_indent(func):
|
||||
|
||||
|
||||
@contextmanager
|
||||
def increase_indent_cm(title=None):
|
||||
def increase_indent_cm(title=None, color='MAGENTA'):
|
||||
global _debug_indent
|
||||
if title:
|
||||
dbg('Start: ' + title, color='MAGENTA')
|
||||
dbg('Start: ' + title, color=color)
|
||||
_debug_indent += 1
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
_debug_indent -= 1
|
||||
if title:
|
||||
dbg('End: ' + title, color='MAGENTA')
|
||||
dbg('End: ' + title, color=color)
|
||||
|
||||
|
||||
def dbg(message, *args, **kwargs):
|
||||
|
||||
@@ -114,10 +114,14 @@ class HelperValueMixin(object):
|
||||
return self.py__iter__(contextualized_node)
|
||||
|
||||
def is_sub_class_of(self, class_value):
|
||||
for cls in self.py__mro__():
|
||||
if cls.is_same_class(class_value):
|
||||
return True
|
||||
return False
|
||||
with debug.increase_indent_cm('subclass matching of %s <=> %s' % (self, class_value),
|
||||
color='BLUE'):
|
||||
for cls in self.py__mro__():
|
||||
if cls.is_same_class(class_value):
|
||||
debug.dbg('matched subclass True', color='BLUE')
|
||||
return True
|
||||
debug.dbg('matched subclass False', color='BLUE')
|
||||
return False
|
||||
|
||||
def is_same_class(self, class2):
|
||||
# Class matching should prefer comparisons that are not this function.
|
||||
|
||||
Reference in New Issue
Block a user