mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-05 18:58:53 -05:00
[Audio] Fix UnboundLocalError in edge case (#5394)
* Fix UnboundLocalError in edge case * Fix typehint for fetch * Style
This commit is contained in:
parent
05cd11b657
commit
b05933274a
@ -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))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user