From: kaliko Date: Tue, 22 Dec 2020 10:30:26 +0000 (+0100) Subject: Cleanup linter warnings X-Git-Tag: 0.16.1~3 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=4ea8f2fe3f29fe09e7a3ab60ac781d54841db5bb;p=mpd-sima.git Cleanup linter warnings --- diff --git a/sima/lib/meta.py b/sima/lib/meta.py index b196584..7cfb54f 100644 --- a/sima/lib/meta.py +++ b/sima/lib/meta.py @@ -46,7 +46,7 @@ def is_uuid4(uuid): class MetaException(Exception): """Generic Meta Exception""" - pass + def mbidfilter(func): def wrapper(*args, **kwargs): @@ -91,7 +91,7 @@ class Meta: self.log = logging.getLogger(__name__) if 'name' not in kwargs or not kwargs.get('name'): raise MetaException('Need a "name" argument (str type)') - elif not isinstance(kwargs.get('name'), str): + if not isinstance(kwargs.get('name'), str): raise MetaException('"name" argument not a string') else: self.__name = kwargs.pop('name') @@ -118,9 +118,9 @@ class Meta: #if hasattr(other, 'mbid'): # better isinstance? if isinstance(other, Meta) and self.mbid and other.mbid: return self.mbid == other.mbid - elif isinstance(other, Meta): + if isinstance(other, Meta): return bool(self.names & other.names) - elif getattr(other, '__str__', None): + if getattr(other, '__str__', None): # is other.__str__() in self.__name or self.__aliases return other.__str__() in self.names return False diff --git a/sima/lib/plugin.py b/sima/lib/plugin.py index 37ce214..58a0e57 100644 --- a/sima/lib/plugin.py +++ b/sima/lib/plugin.py @@ -82,50 +82,42 @@ class Plugin: Called when the daemon().run() is called and right after the player has connected successfully. """ - pass def callback_player(self): """ Called on player changes, stopped, paused, skipped """ - pass def callback_player_database(self): """ Called on player music library changes """ - pass def callback_playlist(self): """ Called on playlist changes Not returning data """ - pass def callback_next_song(self): """ Could be use to scrobble, maintain an history… Not returning data, """ - pass def callback_need_track(self): """ Returns a list of Track objects to add """ - pass def callback_need_track_fb(self): """ Called when callback_need_track failled to find tracks to queue Returns a list of Track objects to add """ - pass def shutdown(self): """Called on application shutdown""" - pass class AdvancedPlugin(Plugin): @@ -169,8 +161,7 @@ class AdvancedPlugin(Plugin): not_queued_artist = alist - queued_artist duration = self.main_conf.getint('sima', 'history_duration') hist = [] - for art in self.sdb.get_artists_history(alist, - duration=duration): + for art in self.sdb.get_artists_history(alist, duration=duration): if art not in hist: if art not in queued_artist: hist.insert(0, art) diff --git a/sima/lib/simadb.py b/sima/lib/simadb.py index a3e5570..5e22f02 100644 --- a/sima/lib/simadb.py +++ b/sima/lib/simadb.py @@ -42,20 +42,17 @@ class SimaDBError(Exception): """ Exceptions. """ - pass class SimaDBAccessError(SimaDBError): """Error on accessing DB file""" - pass class SimaDBNoFile(SimaDBError): """No DB file present""" - pass -class SimaDB(object): +class SimaDB: "SQLite management" def __init__(self, db_path=None): diff --git a/sima/lib/track.py b/sima/lib/track.py index 0fd65e8..38f0cab 100644 --- a/sima/lib/track.py +++ b/sima/lib/track.py @@ -95,8 +95,7 @@ class Track: def __hash__(self): if self.file: return hash(self.file) - else: - return id(self) + return id(self) def __eq__(self, other): return hash(self) == hash(other) diff --git a/sima/plugins/internal/random.py b/sima/plugins/internal/random.py index bb92396..0dfb005 100644 --- a/sima/plugins/internal/random.py +++ b/sima/plugins/internal/random.py @@ -50,8 +50,8 @@ class Random(Plugin): """ duration = self.main_conf.getint('sima', 'history_duration') tracks_from_db = self.sdb.get_history(duration=duration) - artists = [tr[0] for tr in tracks_from_db] - return set(artists) + artists = {tr[0] for tr in tracks_from_db} + return artists def filtered_artist(self, artist): """Filters artists: diff --git a/sima/plugins/internal/tags.py b/sima/plugins/internal/tags.py index 76a2b7b..ef95606 100644 --- a/sima/plugins/internal/tags.py +++ b/sima/plugins/internal/tags.py @@ -22,7 +22,6 @@ Add titles based on tags """ # standard library import -import random # third parties components from musicpd import CommandError diff --git a/sima/utils/filelock.py b/sima/utils/filelock.py index 2cb33a7..128815a 100644 --- a/sima/utils/filelock.py +++ b/sima/utils/filelock.py @@ -31,9 +31,10 @@ import errno import os import time + class FileLockException(Exception): """FileLock Exception""" - pass + class FileLock: """ A plain file lock whit context-manager""" diff --git a/sima/utils/testtags.py b/sima/utils/testtags.py index a779dc3..7a7fd39 100644 --- a/sima/utils/testtags.py +++ b/sima/utils/testtags.py @@ -34,8 +34,7 @@ from ..plugins.internal.tags import forge_filter def is_valid_file(parser, arg): if not os.path.exists(arg) or not os.path.isfile(arg): parser.error('The file "%s" does not exist!' % arg) - else: - return arg + return arg def main(): diff --git a/sima/utils/utils.py b/sima/utils/utils.py index 187d6da..8e07e7a 100644 --- a/sima/utils/utils.py +++ b/sima/utils/utils.py @@ -110,7 +110,6 @@ class FileAction(Action): def checks(self): """control method """ - pass class Wfile(FileAction):