]> kaliko git repositories - mpd-sima.git/commitdiff
Cleanup linter warnings
authorkaliko <kaliko@azylum.org>
Tue, 22 Dec 2020 10:30:26 +0000 (11:30 +0100)
committerkaliko <kaliko@azylum.org>
Tue, 22 Dec 2020 10:30:26 +0000 (11:30 +0100)
sima/lib/meta.py
sima/lib/plugin.py
sima/lib/simadb.py
sima/lib/track.py
sima/plugins/internal/random.py
sima/plugins/internal/tags.py
sima/utils/filelock.py
sima/utils/testtags.py
sima/utils/utils.py

index b19658441725ef84467bf9c04d968d286eaf57d8..7cfb54fa56a63545c50f2b651bea8109ba2dfba7 100644 (file)
@@ -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
index 37ce214aa24be30bffc7ea259e57040eb05d447b..58a0e57b783cd0bc10f2d3c983cf2d1b614f9feb 100644 (file)
@@ -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)
index a3e55703641b480d1c237ac39b5137f70d2e46dd..5e22f021635bc77b0eda39d81ca5b905cbe2c534 100644 (file)
@@ -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):
index 0fd65e8152b08377f34d0b80444e85421733cf57..38f0cab3ec2841ef93c9fb7f1454b91bccdbc8c8 100644 (file)
@@ -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)
index bb9239669e38a9827e75739b0e7c59de66a62b8c..0dfb005c9c81b92cc3c6881a6f92d65914389025 100644 (file)
@@ -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:
index 76a2b7bf695364605ef6ca93a1434c003aaf8829..ef95606a43e2b7d0a9e5ebd5bf6bc5ae4300ab89 100644 (file)
@@ -22,7 +22,6 @@ Add titles based on tags
 """
 
 # standard library import
-import random
 
 # third parties components
 from musicpd import CommandError
index 2cb33a706991767f3d3438023f2ac086c9cf09bb..128815a8fb179ff478fbce89472f114631416331 100644 (file)
@@ -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"""
index a779dc370ed2c03b4cde55cd50c9d23d994e8e4f..7a7fd398b3d60f5f8cca5dee953a0158cf302412 100644 (file)
@@ -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():
index 187d6dad96c25e2f01435da02a10202eac8c087d..8e07e7ae965e5f7342b5425a3094a46f61730bc3 100644 (file)
@@ -110,7 +110,6 @@ class FileAction(Action):
     def checks(self):
         """control method
         """
-        pass
 
 
 class Wfile(FileAction):