summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Honz <exislow+github@gmail.com>2024-01-12 11:20:10 +0100
committerRobert Honz <exislow+github@gmail.com>2024-01-12 11:20:10 +0100
commit677bca872e31e295aeba0a14fde5b4ec81983358 (patch)
tree05f4eded45a5ba3609af0c22f2120b217190b6c2
parent87091fb060ec263c1e9cfa71c086c995c85e65cc (diff)
downloadtidal-dl-ng-677bca872e31e295aeba0a14fde5b4ec81983358.tar.gz
🛠️ Ruff errors refactored.
-rw-r--r--tidal_dl_ng/api.py4
-rw-r--r--tidal_dl_ng/download.py4
-rw-r--r--tidal_dl_ng/gui.py4
-rw-r--r--tidal_dl_ng/helper/decorator.py5
-rw-r--r--tidal_dl_ng/helper/path.py12
5 files changed, 19 insertions, 10 deletions
diff --git a/tidal_dl_ng/api.py b/tidal_dl_ng/api.py
index e601a6d..0679c80 100644
--- a/tidal_dl_ng/api.py
+++ b/tidal_dl_ng/api.py
@@ -102,5 +102,7 @@ try:
if respond.status_code == 200:
content = respond.json()["files"]["tidal-api-key.json"]["content"]
__API_KEYS__ = json.loads(content)
-except:
+except Exception as e:
+ # TODO: Implement proper logging.
+ print(e)
pass
diff --git a/tidal_dl_ng/download.py b/tidal_dl_ng/download.py
index 4804147..a84996f 100644
--- a/tidal_dl_ng/download.py
+++ b/tidal_dl_ng/download.py
@@ -29,7 +29,9 @@ from tidal_dl_ng.model.gui_data import ProgressBars
# TODO: Set appropriate client string and use it for video download.
# https://github.com/globocom/m3u8#using-different-http-clients
class RequestsClient:
- def download(self, uri: str, timeout: int = None, headers: dict | None = None, verify_ssl: bool = True):
+ def download(
+ self, uri: str, timeout: int = REQUESTS_TIMEOUT_SEC, headers: dict | None = None, verify_ssl: bool = True
+ ):
if not headers:
headers = {}
diff --git a/tidal_dl_ng/gui.py b/tidal_dl_ng/gui.py
index 064826b..5c5061f 100644
--- a/tidal_dl_ng/gui.py
+++ b/tidal_dl_ng/gui.py
@@ -409,7 +409,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
)
progress: Progress = Progress()
- if isinstance(media, (Track, Video)):
+ if isinstance(media, Track | Video):
if isinstance(media, Track):
file_template: str = self.settings.data.format_track
elif isinstance(media, Video):
@@ -428,7 +428,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
logger_gui.info(f"Download successful: {download_path_file}")
else:
logger_gui.info(f"Download skipped (file exists): {download_path_file}")
- elif isinstance(media, (Album, Playlist, Mix)):
+ elif isinstance(media, Album | Playlist | Mix):
file_template: str | bool = False
if isinstance(media, Album):
diff --git a/tidal_dl_ng/helper/decorator.py b/tidal_dl_ng/helper/decorator.py
index 545f73b..ba0f417 100644
--- a/tidal_dl_ng/helper/decorator.py
+++ b/tidal_dl_ng/helper/decorator.py
@@ -1,3 +1,6 @@
+from typing import ClassVar
+
+
class SingletonMeta(type):
"""
The Singleton class can be implemented in different ways in Python. Some
@@ -5,7 +8,7 @@ class SingletonMeta(type):
metaclass because it is best suited for this purpose.
"""
- _instances = {}
+ _instances: ClassVar[dict] = {}
def __call__(cls, *args, **kwargs):
"""
diff --git a/tidal_dl_ng/helper/path.py b/tidal_dl_ng/helper/path.py
index 31e9a88..3061160 100644
--- a/tidal_dl_ng/helper/path.py
+++ b/tidal_dl_ng/helper/path.py
@@ -111,7 +111,7 @@ def get_fn_format(media: Track | Album | Playlist | UserPlaylist | Video | Mix)
result = format_str_track
elif isinstance(media, Album):
result = format_str_album
- elif isinstance(media, (Playlist, UserPlaylist)):
+ elif isinstance(media, Playlist | UserPlaylist):
result = format_str_playlist
elif isinstance(media, Mix):
result = format_str_mix
@@ -128,8 +128,9 @@ def length_max_name_file() -> int:
try:
if system in ["Darwin", "Linux"]:
result: int = os.pathconf("/", "PC_NAME_MAX")
- except Exception:
- pass
+ except Exception as e:
+ # TODO: Implement propper logging.
+ print(e)
return result
@@ -141,8 +142,9 @@ def length_max_name_path() -> int:
try:
if system in ["Darwin", "Linux"]:
result: int = os.pathconf("/", "PC_PATH_MAX")
- except Exception:
- pass
+ except Exception as e:
+ # TODO: Implement propper logging.
+ print(e)
return result