return Scope.make_string(scope) if all values in scope are Scope objects

This commit is contained in:
dieser-niko 2024-10-13 22:31:28 +02:00
parent 77b2bd90bc
commit d140d1a4b6

View File

@ -1,5 +1,7 @@
from __future__ import annotations from __future__ import annotations
from spotipy import Scope
""" Shows a user's playlists. This needs to be authenticated via OAuth. """ """ Shows a user's playlists. This needs to be authenticated via OAuth. """
__all__ = ["CLIENT_CREDS_ENV_VARS", "get_host_port", "normalize_scope", "Retry"] __all__ = ["CLIENT_CREDS_ENV_VARS", "get_host_port", "normalize_scope", "Retry"]
@ -51,6 +53,8 @@ def normalize_scope(scope):
scopes = scope.split(',') scopes = scope.split(',')
elif isinstance(scope, Iterable): elif isinstance(scope, Iterable):
if all(isinstance(s, Scope) for s in scope):
return Scope.make_string(scope)
scopes = scope scopes = scope
else: else:
raise Exception( raise Exception(