def _class_defining_method(meth):  # pragma: no cover
    '''Gets the name of the class that defines meth.

    Adapted from
    http://stackoverflow.com/questions/3589311/get-defining-class-of-unbound-method-object-in-python-3/25959545#25959545.
    '''
    if inspect.ismethod(meth):
        for cls in inspect.getmro(meth.__self__.__class__):
            if cls.__dict__.get(meth.__name__) is meth:
                return '{}.{}'.format(cls.__module__, cls.__name__)
        meth = meth.__func__
    if inspect.isfunction(meth):
        module = meth.__qualname__.split('.<locals>', 1)[0]
        cls = getattr(inspect.getmodule(meth), module.rsplit('.', 1)[0])
        if isinstance(cls, type):
            return '{}.{}'.format(cls.__module__, cls.__name__)
def _class_defining_method ( meth ) : if inspect . ismethod ( meth ) : for cls in inspect . getmro ( meth . __self__ . __class__ ) : if cls . __dict__ . get ( meth . __name__ ) is meth : return '{}.{}' . format ( cls . __module__ , cls . __name__ ) meth = meth . __func__ if inspect . isfunction ( meth ) : module = meth . __qualname__ . split ( '.<locals>' , 1 ) [ 0 ] cls = getattr ( inspect . getmodule ( meth ) , module . rsplit ( '.' , 1 ) [ 0 ] ) if isinstance ( cls , type ) : return '{}.{}' . format ( cls . __module__ , cls . __name__ )
Gets the name of the class that defines meth.

    Adapted from
    http://stackoverflow.com/questions/3589311/get-defining-class-of-unbound-method-object-in-python-3/25959545#25959545.