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