From b05933274a11fb097873ab0d1b246d37b06aa306 Mon Sep 17 00:00:00 2001 From: Flame442 <34169552+Flame442@users.noreply.github.com> Date: Wed, 12 Jan 2022 12:20:22 -0500 Subject: [PATCH] [Audio] Fix UnboundLocalError in edge case (#5394) * Fix UnboundLocalError in edge case * Fix typehint for fetch * Style --- redbot/cogs/audio/apis/playlist_wrapper.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/redbot/cogs/audio/apis/playlist_wrapper.py b/redbot/cogs/audio/apis/playlist_wrapper.py index f38b32cc1..0a884ef18 100644 --- a/redbot/cogs/audio/apis/playlist_wrapper.py +++ b/redbot/cogs/audio/apis/playlist_wrapper.py @@ -84,7 +84,9 @@ class PlaylistWrapper: table = 2 return table - async def fetch(self, scope: str, playlist_id: int, scope_id: int) -> PlaylistFetchResult: + async def fetch( + self, scope: str, playlist_id: int, scope_id: int + ) -> Optional[PlaylistFetchResult]: """Fetch a single playlist.""" scope_type = self.get_scope_type(scope) @@ -107,7 +109,8 @@ class PlaylistWrapper: try: row_result = future.result() except Exception as exc: - debug_exc_log(log, exc, "Failed to completed playlist fetch from database") + debug_exc_log(log, exc, "Failed to complete playlist fetch from database") + return None row = row_result.fetchone() if row: row = PlaylistFetchResult(*row) @@ -139,7 +142,7 @@ class PlaylistWrapper: try: row_result = future.result() except Exception as exc: - debug_exc_log(log, exc, "Failed to completed playlist fetch from database") + debug_exc_log(log, exc, "Failed to complete playlist fetch from database") return [] else: for future in concurrent.futures.as_completed( @@ -154,7 +157,7 @@ class PlaylistWrapper: try: row_result = future.result() except Exception as exc: - debug_exc_log(log, exc, "Failed to completed playlist fetch from database") + debug_exc_log(log, exc, "Failed to complete playlist fetch from database") return [] async for row in AsyncIter(row_result): output.append(PlaylistFetchResult(*row)) @@ -191,7 +194,8 @@ class PlaylistWrapper: try: row_result = future.result() except Exception as exc: - debug_exc_log(log, exc, "Failed to completed fetch from database") + debug_exc_log(log, exc, "Failed to complete fetch from database") + return [] async for row in AsyncIter(row_result): output.append(PlaylistFetchResult(*row))