def in_loop(node):
 parent = node.parent
 while (parent is not None):
  if isinstance(parent, (astroid.For, astroid.ListComp, astroid.SetComp, astroid.DictComp, astroid.GenExpr)):
   return True
  parent = parent.parent
 return False

def in_loop ( node ) : parent = node . parent while ( parent is not None ) : if isinstance ( parent , ( astroid . For , astroid . ListComp , astroid . SetComp , astroid . DictComp , astroid . GenExpr ) ) : return True parent = parent . parent return False
return true if the node is inside a kind of for loop .