def assert_hasattr(attr: str, msg: str, tp: BaseException = SpotifyException) -> Callable:
def decorator(func: Callable) -> Callable:<EOL><INDENT>@functools.wraps(func)<EOL>def decorated(self, *args, **kwargs):<EOL><INDENT>if not hasattr(self, attr):<EOL><INDENT>raise tp(msg)<EOL><DEDENT>return func(self, *args, **kwargs)<EOL><DEDENT>if inspect.iscoroutinefunction(func):<EOL><INDENT>@functools.wraps(func)<EOL>async def decorated(*args, **kwargs):<EOL><INDENT>return await decorated(*args, **kwargs)<EOL><DEDENT><DEDENT>return decorated<EOL><DEDENT>return decorator<EOL>
decorator to assert an object has an attribute when run.