diff --git a/cozy/application.py b/cozy/application.py index 4c8dfab1..d4a72fce 100644 --- a/cozy/application.py +++ b/cozy/application.py @@ -1,5 +1,4 @@ import logging -import os import platform import sys import threading diff --git a/cozy/architecture/event_sender.py b/cozy/architecture/event_sender.py index 94982870..82b6a88e 100644 --- a/cozy/architecture/event_sender.py +++ b/cozy/architecture/event_sender.py @@ -1,6 +1,5 @@ -from typing import List, Callable +from typing import Callable -import gi from gi.repository import GLib diff --git a/cozy/control/artwork_cache.py b/cozy/control/artwork_cache.py index 85b1ac12..ba8eebf0 100644 --- a/cozy/control/artwork_cache.py +++ b/cozy/control/artwork_cache.py @@ -97,7 +97,7 @@ def get_album_art_path(self, book, size): if query.exists(): try: uuid = query.first().uuid - except Exception as e: + except Exception: reporter.error("artwork_cache", "load_pixbuf_from_cache: query exists but query.first().uuid crashed.") return None else: diff --git a/cozy/control/db_updater.py b/cozy/control/db_updater.py index 0ac6d8a7..c31e82c7 100644 --- a/cozy/control/db_updater.py +++ b/cozy/control/db_updater.py @@ -2,7 +2,6 @@ import os import shutil from datetime import datetime -from typing import List from peewee import IntegerField, BooleanField, FloatField, ForeignKeyField, fn from playhouse.migrate import SqliteMigrator, migrate @@ -240,7 +239,7 @@ def update_db(): # First test for version 1 try: next(c for c in db.get_columns("settings") if c.name == "version") - except Exception as e: + except Exception: if len(db.get_tables()) == 0: data_dir = get_data_dir() if os.path.exists(os.path.join(data_dir, "cozy.db")): diff --git a/cozy/control/filesystem_monitor.py b/cozy/control/filesystem_monitor.py index 5457f670..68f15c2e 100644 --- a/cozy/control/filesystem_monitor.py +++ b/cozy/control/filesystem_monitor.py @@ -1,5 +1,4 @@ import logging -from typing import List import cozy.ext.inject as inject from gi.repository import Gio @@ -59,7 +58,6 @@ def close(self): Free all references. """ # self.volume_monitor.unref() - pass def get_book_online(self, book: Book): try: diff --git a/cozy/control/offline_cache.py b/cozy/control/offline_cache.py index 2b378f31..145f1724 100644 --- a/cozy/control/offline_cache.py +++ b/cozy/control/offline_cache.py @@ -6,7 +6,6 @@ from cozy.architecture.event_sender import EventSender from cozy.control.application_directories import get_cache_dir import cozy.tools as tools -import cozy.ui from gi.repository import Gio diff --git a/cozy/ext/inject/__init__.py b/cozy/ext/inject/__init__.py index f3a77dab..18316e02 100644 --- a/cozy/ext/inject/__init__.py +++ b/cozy/ext/inject/__init__.py @@ -82,7 +82,6 @@ def my_config(binder): import logging import sys import threading -import types from functools import wraps from typing import (Any, Awaitable, Callable, Dict, Generic, Hashable, Optional, Type, TypeVar, Union, cast, get_type_hints, diff --git a/cozy/media/files.py b/cozy/media/files.py index c4d9092a..7ee3f39c 100644 --- a/cozy/media/files.py +++ b/cozy/media/files.py @@ -1,6 +1,5 @@ import logging import os -import urllib from pathlib import Path from gi.repository import Gio diff --git a/cozy/media/importer.py b/cozy/media/importer.py index 624dc4fb..93e56ecc 100644 --- a/cozy/media/importer.py +++ b/cozy/media/importer.py @@ -4,7 +4,6 @@ import time from enum import Enum, auto from multiprocessing.pool import Pool as Pool -from typing import List, Set from urllib.parse import urlparse, unquote from cozy.architecture.event_sender import EventSender @@ -38,7 +37,7 @@ def import_file(path: str): try: media_detector = MediaDetector(path) media_data = media_detector.get_media_data() - except NotAnAudioFile as e: + except NotAnAudioFile: return None except AudioFileCouldNotBeDiscovered as e: return unquote(urlparse(str(e)).path) diff --git a/cozy/media/media_detector.py b/cozy/media/media_detector.py index cfb1a6d4..5ed0306b 100644 --- a/cozy/media/media_detector.py +++ b/cozy/media/media_detector.py @@ -33,7 +33,7 @@ def get_media_data(self) -> MediaFile: try: discoverer_info: GstPbutils.DiscovererInfo = self.discoverer.discover_uri(self.uri) - except Exception as e: + except Exception: log.info("Skipping file because it couldn't be detected: %s", self.uri) raise AudioFileCouldNotBeDiscovered(self.uri) diff --git a/cozy/media/media_file.py b/cozy/media/media_file.py index fc9a6a21..978f3f48 100644 --- a/cozy/media/media_file.py +++ b/cozy/media/media_file.py @@ -1,4 +1,3 @@ -from typing import List from cozy.media.chapter import Chapter diff --git a/cozy/media/player.py b/cozy/media/player.py index 795ce382..40fe24bf 100644 --- a/cozy/media/player.py +++ b/cozy/media/player.py @@ -384,7 +384,7 @@ def _emit_tick(self): def _fadeout_playback(self): duration = self._app_settings.sleep_timer_fadeout_duration * 20 current_vol = self._gst_player.volume - for i in range(0, duration): + for i in range(duration): volume = max(current_vol - (i / duration), 0) self._gst_player.position = volume time.sleep(0.05) diff --git a/cozy/media/tag_reader.py b/cozy/media/tag_reader.py index 69d71fcf..ebb13e86 100644 --- a/cozy/media/tag_reader.py +++ b/cozy/media/tag_reader.py @@ -1,5 +1,4 @@ import os -from typing import List from urllib.parse import unquote, urlparse import mutagen diff --git a/cozy/model/book.py b/cozy/model/book.py index 422828aa..15e499af 100644 --- a/cozy/model/book.py +++ b/cozy/model/book.py @@ -1,12 +1,10 @@ import logging -from typing import List from peewee import SqliteDatabase, DoesNotExist from cozy.application_settings import ApplicationSettings from cozy.architecture.event_sender import EventSender from cozy.architecture.observable import Observable -from cozy.architecture.profiler import timing from cozy.db.collation import collate_natural from cozy.db.book import Book as BookModel from cozy.db.track import Track as TrackModel diff --git a/cozy/model/database_importer.py b/cozy/model/database_importer.py index 15fe7b61..1824e005 100644 --- a/cozy/model/database_importer.py +++ b/cozy/model/database_importer.py @@ -1,5 +1,4 @@ import logging -from typing import List, Set from peewee import fn, SqliteDatabase diff --git a/cozy/model/library.py b/cozy/model/library.py index 9c5d90ff..2abe83ec 100644 --- a/cozy/model/library.py +++ b/cozy/model/library.py @@ -1,5 +1,5 @@ import logging -from typing import List, Set, Optional +from typing import Optional from peewee import SqliteDatabase diff --git a/cozy/ui/book_detail_view.py b/cozy/ui/book_detail_view.py index 48c9a3df..a11c6baa 100644 --- a/cozy/ui/book_detail_view.py +++ b/cozy/ui/book_detail_view.py @@ -3,7 +3,6 @@ from threading import Event, Thread from typing import Optional, Callable -import gi from cozy.control.artwork_cache import ArtworkCache from cozy.ext import inject @@ -281,7 +280,7 @@ def _interrupt_chapters_jobs(self): try: self._chapters_thread.join(timeout=0.2) - except AttributeError as e: + except AttributeError: pass def _prepare_chapters_job(self): diff --git a/cozy/ui/chapter_element.py b/cozy/ui/chapter_element.py index ff75af4b..30f247ee 100644 --- a/cozy/ui/chapter_element.py +++ b/cozy/ui/chapter_element.py @@ -1,4 +1,4 @@ -from gi.repository import Gtk, Pango, GObject, Gdk +from gi.repository import Gtk, GObject, Gdk from cozy.control.string_representation import seconds_to_str from cozy.model.chapter import Chapter diff --git a/cozy/ui/db_migration_failed_view.py b/cozy/ui/db_migration_failed_view.py index 3b91bf53..16f502a0 100644 --- a/cozy/ui/db_migration_failed_view.py +++ b/cozy/ui/db_migration_failed_view.py @@ -1,6 +1,5 @@ import webbrowser -import gi from gi.repository import Adw EXPLANATION = _("During an update of the database an error occurred and Cozy will not be able to startup.\ diff --git a/cozy/ui/headerbar.py b/cozy/ui/headerbar.py index fbca9e70..cdb772dd 100644 --- a/cozy/ui/headerbar.py +++ b/cozy/ui/headerbar.py @@ -1,6 +1,5 @@ import logging -import gi from cozy.ext import inject from cozy.ui.widgets.progress_popover import ProgressPopover @@ -8,9 +7,6 @@ from gi.repository import Adw, Gtk, GObject -from cozy.ext import inject -from cozy.ui.widgets.progress_popover import ProgressPopover -from cozy.view_model.headerbar_view_model import HeaderBarState, HeaderbarViewModel log = logging.getLogger("Headerbar") diff --git a/cozy/ui/library_view.py b/cozy/ui/library_view.py index 59eb2eaf..5d6141bc 100644 --- a/cozy/ui/library_view.py +++ b/cozy/ui/library_view.py @@ -1,4 +1,3 @@ -import functools from typing import Optional from gi.repository import Adw, Gtk diff --git a/cozy/ui/main_view.py b/cozy/ui/main_view.py index c113e1b3..fc2263d9 100644 --- a/cozy/ui/main_view.py +++ b/cozy/ui/main_view.py @@ -1,6 +1,4 @@ import logging -import os -from collections import defaultdict from threading import Thread from typing import Callable @@ -17,9 +15,7 @@ from cozy.media.importer import Importer, ScanStatus from cozy.media.player import Player from cozy.model.settings import Settings as SettingsModel -from cozy.view_model.settings_view_model import SettingsViewModel from cozy.view_model.storages_view_model import StoragesViewModel -from cozy.open_view import OpenView from cozy.ui.library_view import LibraryView from cozy.ui.about_window import AboutWindow from cozy.ui.preferences_window import PreferencesWindow diff --git a/cozy/ui/media_controller.py b/cozy/ui/media_controller.py index 15100bce..a35163f8 100644 --- a/cozy/ui/media_controller.py +++ b/cozy/ui/media_controller.py @@ -1,6 +1,5 @@ import logging -import gi from cozy.control.artwork_cache import ArtworkCache from cozy.db.book import Book diff --git a/cozy/ui/widgets/album_element.py b/cozy/ui/widgets/album_element.py index 790d08d6..80ba95eb 100644 --- a/cozy/ui/widgets/album_element.py +++ b/cozy/ui/widgets/album_element.py @@ -7,7 +7,7 @@ from cozy.model.book import Book from cozy.ext import inject -from gi.repository import Gtk, GObject, Gdk +from gi.repository import Gtk, GObject ALBUM_ART_SIZE = 200 PLAY_BUTTON_ICON_SIZE = Gtk.IconSize.NORMAL diff --git a/cozy/ui/widgets/error_reporting.py b/cozy/ui/widgets/error_reporting.py index 42cd4ac5..ec2f8d7b 100644 --- a/cozy/ui/widgets/error_reporting.py +++ b/cozy/ui/widgets/error_reporting.py @@ -1,6 +1,5 @@ from gettext import gettext as _ -import gi from cozy.application_settings import ApplicationSettings from cozy.ext import inject diff --git a/cozy/ui/widgets/filter_list_box.py b/cozy/ui/widgets/filter_list_box.py index 96246766..269238db 100644 --- a/cozy/ui/widgets/filter_list_box.py +++ b/cozy/ui/widgets/filter_list_box.py @@ -1,9 +1,7 @@ -from typing import List from gi.repository import Gtk from cozy.ui.list_box_row_with_data import ListBoxRowWithData -from cozy.ui.list_box_separator_row import ListBoxSeparatorRow class FilterListBox(Gtk.ListBox): diff --git a/cozy/ui/widgets/first_import_button.py b/cozy/ui/widgets/first_import_button.py index f4271d3f..00615a7f 100644 --- a/cozy/ui/widgets/first_import_button.py +++ b/cozy/ui/widgets/first_import_button.py @@ -1,4 +1,4 @@ -from gi.repository import Adw, Gtk, GObject +from gi.repository import Adw, Gtk from .storages import ask_storage_location diff --git a/cozy/view_model/headerbar_view_model.py b/cozy/view_model/headerbar_view_model.py index d160220a..d40d3789 100644 --- a/cozy/view_model/headerbar_view_model.py +++ b/cozy/view_model/headerbar_view_model.py @@ -7,7 +7,6 @@ from cozy.media.files import Files from cozy.media.importer import Importer, ScanStatus from cozy.model.library import Library -from cozy.open_view import OpenView from cozy.view import View diff --git a/cozy/view_model/library_view_model.py b/cozy/view_model/library_view_model.py index 2639ca8e..43b5326f 100644 --- a/cozy/view_model/library_view_model.py +++ b/cozy/view_model/library_view_model.py @@ -13,7 +13,6 @@ from cozy.media.player import Player from cozy.model.book import Book from cozy.model.library import Library -from cozy.model.storage import Storage from cozy.open_view import OpenView from cozy.report import reporter from cozy.ui.widgets.book_element import BookElement @@ -159,11 +158,7 @@ def book_files_exist(self, book: Book) -> bool: return False def _on_fs_monitor_event(self, event, _): - if event == "storage-online": - self._notify("authors") - self._notify("readers") - self._notify("books-filter") - elif event == "storage-offline": + if event in {"storage-online", "storage-offline"}: self._notify("authors") self._notify("readers") self._notify("books-filter") diff --git a/cozy/view_model/settings_view_model.py b/cozy/view_model/settings_view_model.py index f5333529..a24e5147 100644 --- a/cozy/view_model/settings_view_model.py +++ b/cozy/view_model/settings_view_model.py @@ -1,6 +1,6 @@ import logging -from gi.repository import Adw, Gtk +from gi.repository import Adw from cozy.application_settings import ApplicationSettings from cozy.architecture.event_sender import EventSender