def _detect_global_scope(node, frame, defframe):
 def_scope = scope = None
 if (frame and frame.parent):
  scope = frame.parent.scope()
 if (defframe and defframe.parent):
  def_scope = defframe.parent.scope()
 if isinstance(frame, astroid.Function):
  if (not isinstance(node.parent, (astroid.Function, astroid.Arguments))):
   return False
 elif any(((not isinstance(f, (astroid.Class, astroid.Module))) for f in (frame, defframe))):
  return False
 break_scopes = []
 for s in (scope, def_scope):
  parent_scope = s
  while parent_scope:
   if (not isinstance(parent_scope, (astroid.Class, astroid.Module))):
    break_scopes.append(parent_scope)
    break
   if parent_scope.parent:
    parent_scope = parent_scope.parent.scope()
   else:
    break
 if (break_scopes and (len(set(break_scopes)) != 1)):
  return False
 return (frame.lineno < defframe.lineno)

def _detect_global_scope ( node , frame , defframe ) : def_scope = scope = None if ( frame and frame . parent ) : scope = frame . parent . scope ( ) if ( defframe and defframe . parent ) : def_scope = defframe . parent . scope ( ) if isinstance ( frame , astroid . Function ) : if ( not isinstance ( node . parent , ( astroid . Function , astroid . Arguments ) ) ) : return False elif any ( ( ( not isinstance ( f , ( astroid . Class , astroid . Module ) ) ) for f in ( frame , defframe ) ) ) : return False break_scopes = [ ] for s in ( scope , def_scope ) : parent_scope = s while parent_scope : if ( not isinstance ( parent_scope , ( astroid . Class , astroid . Module ) ) ) : break_scopes . append ( parent_scope ) break if parent_scope . parent : parent_scope = parent_scope . parent . scope ( ) else : break if ( break_scopes and ( len ( set ( break_scopes ) ) != 1 ) ) : return False return ( frame . lineno < defframe . lineno )
detect that the given frames shares a global scope .