#NEWLINE# def has_parent( basepath , obj ) : #NEWLINE# #INDENT# '\n    Checks if `basepath` is somewhere in `obj`s parent tree.\n\n    Args:\n        basepath (str): Python dotpath to compare against obj path.\n        obj (any): Object whose path is to be checked.\n\n    Returns:\n        has_parent (bool): If the check was successful or not.\n\n    ' #NEWLINE# try : #NEWLINE# #INDENT# return any ( ( cls for cls in obj . __class__ . mro ( ) if ( basepath == ( '%s.%s' % ( cls . __module__ , cls . __name__ ) ) ) ) ) #NEWLINE# #UNINDENT# except ( TypeError , AttributeError ) : #NEWLINE# #INDENT# return False