From a0bb3c3843a0fc49add8b3d144fe77e1ac82541f Mon Sep 17 00:00:00 2001 From: Alpha Date: Sun, 24 Oct 2021 13:45:52 -0400 Subject: [PATCH] Fix typing hints --- src/podcast.py | 4 ++-- src/track.py | 4 ++-- src/utils.py | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/podcast.py b/src/podcast.py index 43dae318..eea36c1b 100644 --- a/src/podcast.py +++ b/src/podcast.py @@ -1,5 +1,5 @@ import os -from typing import Optional +from typing import Optional, Tuple from librespot.audio.decoders import VorbisOnlyAudioQuality from librespot.metadata import EpisodeId @@ -14,7 +14,7 @@ EPISODE_INFO_URL = 'https://api.spotify.com/v1/episodes' SHOWS_URL = 'https://api.spotify.com/v1/shows' -def get_episode_info(episode_id_str) -> tuple[Optional[str], Optional[str]]: +def get_episode_info(episode_id_str) -> Tuple[Optional[str], Optional[str]]: info = ZSpotify.invoke_url(f'{EPISODE_INFO_URL}/{episode_id_str}') if ERROR in info: return None, None diff --git a/src/track.py b/src/track.py index 3fb088f7..9a928eca 100644 --- a/src/track.py +++ b/src/track.py @@ -1,6 +1,6 @@ import os import time -from typing import Any +from typing import Any, Tuple, List from librespot.audio.decoders import AudioQuality from librespot.metadata import TrackId @@ -31,7 +31,7 @@ def get_saved_tracks() -> list: return songs -def get_song_info(song_id) -> tuple[list[str], str, str, Any, Any, Any, Any, Any, Any]: +def get_song_info(song_id) -> Tuple[List[str], str, str, Any, Any, Any, Any, Any, Any]: """ Retrieves metadata for downloaded songs """ info = ZSpotify.invoke_url(f'{TRACKS_URL}?ids={song_id}&market=from_token') diff --git a/src/utils.py b/src/utils.py index 3fd91612..b8188d95 100644 --- a/src/utils.py +++ b/src/utils.py @@ -3,6 +3,7 @@ import platform import re import time from enum import Enum +from typing import List, Tuple import music_tag import requests @@ -27,7 +28,7 @@ def wait(seconds: int = 3) -> None: time.sleep(1) -def split_input(selection) -> list[str]: +def split_input(selection) -> List[str]: """ Returns a list of inputted strings """ inputs = [] if '-' in selection: @@ -91,7 +92,7 @@ def set_music_thumbnail(filename, image_url) -> None: tags.save() -def regex_input_for_urls(search_input) -> tuple[str, str, str, str, str, str]: +def regex_input_for_urls(search_input) -> Tuple[str, str, str, str, str, str]: """ Since many kinds of search may be passed at the command line, process them all here. """ track_uri_search = re.search( r'^spotify:track:(?P[0-9a-zA-Z]{22})$', search_input)