def is_import_error(handler):
 names = None
 if isinstance(handler.type, astroid.Tuple):
  names = [name for name in handler.type.elts if isinstance(name, astroid.Name)]
 elif isinstance(handler.type, astroid.Name):
  names = [handler.type]
 else:
  return
 for name in names:
  try:
   for infered in name.infer():
    if (isinstance(infered, astroid.Class) and inherit_from_std_ex(infered) and (infered.name == 'ImportError')):
     return True
  except astroid.InferenceError:
   continue

def is_import_error ( handler ) : names = None if isinstance ( handler . type , astroid . Tuple ) : names = [ name for name in handler . type . elts if isinstance ( name , astroid . Name ) ] elif isinstance ( handler . type , astroid . Name ) : names = [ handler . type ] else : return for name in names : try : for infered in name . infer ( ) : if ( isinstance ( infered , astroid . Class ) and inherit_from_std_ex ( infered ) and ( infered . name == 'ImportError' ) ) : return True except astroid . InferenceError : continue
check if the given exception handler catches importerror .