def _is_metaclass(klass, seen=None):
 if (klass.name == 'type'):
  return True
 if (seen is None):
  seen = set()
 for base in klass.bases:
  try:
   for baseobj in base.infer():
    if (baseobj in seen):
     continue
    else:
     seen.add(baseobj)
    if isinstance(baseobj, Instance):
     return False
    if (baseobj is YES):
     continue
    if (baseobj is klass):
     continue
    if (not isinstance(baseobj, Class)):
     continue
    if (baseobj._type == 'metaclass'):
     return True
    if _is_metaclass(baseobj, seen):
     return True
  except InferenceError:
   continue
 return False

def _is_metaclass ( klass , seen = None ) : if ( klass . name == 'type' ) : return True if ( seen is None ) : seen = set ( ) for base in klass . bases : try : for baseobj in base . infer ( ) : if ( baseobj in seen ) : continue else : seen . add ( baseobj ) if isinstance ( baseobj , Instance ) : return False if ( baseobj is YES ) : continue if ( baseobj is klass ) : continue if ( not isinstance ( baseobj , Class ) ) : continue if ( baseobj . _type == 'metaclass' ) : return True if _is_metaclass ( baseobj , seen ) : return True except InferenceError : continue return False
return if the given class can be used as a metaclass .