'Filter the output of `dir(mock)` to only useful members.'

def __dir__(self):

    extras = (self._mock_methods or [])
    from_type = dir(type(self))
    from_dict = list(self.__dict__)
    if FILTER_DIR:
        from_type = [e for e in from_type if (not e.startswith('_'))]
        from_dict = [e for e in from_dict if ((not e.startswith('_')) or _is_magic(e))]
    return sorted(set((((extras + from_type) + from_dict) + list(self._mock_children))))
