Skip to content

Commit

Permalink
Auto-fix with Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende committed Mar 26, 2024
1 parent 75e3da7 commit 0e3752b
Show file tree
Hide file tree
Showing 30 changed files with 13 additions and 48 deletions.
1 change: 0 additions & 1 deletion cozy/application.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import os
import platform
import sys
import threading
Expand Down
3 changes: 1 addition & 2 deletions cozy/architecture/event_sender.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import List, Callable
from typing import Callable

import gi
from gi.repository import GLib


Expand Down
2 changes: 1 addition & 1 deletion cozy/control/artwork_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions cozy/control/db_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")):
Expand Down
2 changes: 0 additions & 2 deletions cozy/control/filesystem_monitor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
from typing import List

import cozy.ext.inject as inject
from gi.repository import Gio
Expand Down Expand Up @@ -59,7 +58,6 @@ def close(self):
Free all references.
"""
# self.volume_monitor.unref()
pass

def get_book_online(self, book: Book):
try:
Expand Down
1 change: 0 additions & 1 deletion cozy/control/offline_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion cozy/ext/inject/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion cozy/media/files.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
import os
import urllib
from pathlib import Path

from gi.repository import Gio
Expand Down
3 changes: 1 addition & 2 deletions cozy/media/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cozy/media/media_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion cozy/media/media_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import List

from cozy.media.chapter import Chapter

Expand Down
2 changes: 1 addition & 1 deletion cozy/media/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion cozy/media/tag_reader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from typing import List
from urllib.parse import unquote, urlparse

import mutagen
Expand Down
2 changes: 0 additions & 2 deletions cozy/model/book.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion cozy/model/database_importer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
from typing import List, Set

from peewee import fn, SqliteDatabase

Expand Down
2 changes: 1 addition & 1 deletion cozy/model/library.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import List, Set, Optional
from typing import Optional

from peewee import SqliteDatabase

Expand Down
3 changes: 1 addition & 2 deletions cozy/ui/book_detail_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion cozy/ui/chapter_element.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion cozy/ui/db_migration_failed_view.py
Original file line number Diff line number Diff line change
@@ -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.\
Expand Down
4 changes: 0 additions & 4 deletions cozy/ui/headerbar.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import logging

import gi

from cozy.ext import inject
from cozy.ui.widgets.progress_popover import ProgressPopover
from cozy.view_model.headerbar_view_model import HeaderbarViewModel, HeaderBarState

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")

Expand Down
1 change: 0 additions & 1 deletion cozy/ui/library_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import functools
from typing import Optional

from gi.repository import Adw, Gtk
Expand Down
4 changes: 0 additions & 4 deletions cozy/ui/main_view.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import logging
import os
from collections import defaultdict
from threading import Thread
from typing import Callable

Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion cozy/ui/media_controller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging

import gi

from cozy.control.artwork_cache import ArtworkCache
from cozy.db.book import Book
Expand Down
2 changes: 1 addition & 1 deletion cozy/ui/widgets/album_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion cozy/ui/widgets/error_reporting.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from gettext import gettext as _

import gi

from cozy.application_settings import ApplicationSettings
from cozy.ext import inject
Expand Down
2 changes: 0 additions & 2 deletions cozy/ui/widgets/filter_list_box.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion cozy/ui/widgets/first_import_button.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from gi.repository import Adw, Gtk, GObject
from gi.repository import Adw, Gtk

from .storages import ask_storage_location

Expand Down
1 change: 0 additions & 1 deletion cozy/view_model/headerbar_view_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
7 changes: 1 addition & 6 deletions cozy/view_model/library_view_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion cozy/view_model/settings_view_model.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 0e3752b

Please sign in to comment.