def METHOD_NAME(self, X=None, y=None):
    klass = type(self).__name__
    if not self._is_fitted and self.needs_fitting:
        raise ComponentNotYetFittedError(
            f"This {klass} is not fitted yet. You must fit {klass} before calling {method.__name__}.",
        )
    else:
        return method(self, X, y)