import functools


def _callback(callback, *args, **kwargs):
    """
    Helper that marks a method to call another method on the
    same class when complete.

    :param callback:  The method name to call when the marked method is complete
    :param args:  Saved and passed to the callback method.
    :param kwargs:  Saved and passed to the callback method.

    :raises TypeError:  If the callback is not found or is not callable.

    """
    def decorator(fn):

        @functools.wraps(fn)
        def decorated(self, *_args, **_kwargs):
            _callback = getattr(self, callback, None)
            if not _callback or not callable(_callback):
                raise TypeError(f'Invalid callback: {callback}')
            fn(self, *_args, **_kwargs)
            return _callback(*args, **kwargs)

        return decorated

    return decorator