From 95cc8fde9261abfda3365b572527c4b5cf112112 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Fri, 30 Apr 2021 16:05:59 +0200 Subject: [PATCH] Handle some pylint and bandit warnings --- picard/cluster.py | 2 +- picard/coverart/__init__.py | 2 +- picard/coverart/image.py | 5 +++-- resources/makeqrc.py | 12 +++++------- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/picard/cluster.py b/picard/cluster.py index f811ff9e8..5aacd13ae 100644 --- a/picard/cluster.py +++ b/picard/cluster.py @@ -475,7 +475,7 @@ class ClusterDict(object): index, count = self.words[word] if index == -1: token = self.tokenize(word) - if token == '': + if token == '': # nosec return -1 index = self.id self.ids[index] = (word, token) diff --git a/picard/coverart/__init__.py b/picard/coverart/__init__.py index d1a406d78..323849c09 100644 --- a/picard/coverart/__init__.py +++ b/picard/coverart/__init__.py @@ -158,7 +158,7 @@ class CoverArt: finally: if ret != CoverArtProvider.WAIT: self.next_in_queue() - return + return except StopIteration: # nothing more to do self.album._finalize_loading(None) diff --git a/picard/coverart/image.py b/picard/coverart/image.py index cc05fe18f..91d6f4c4d 100644 --- a/picard/coverart/image.py +++ b/picard/coverart/image.py @@ -64,7 +64,7 @@ class DataHash: self._filename = None _datafile_mutex.lock() try: - m = md5() + m = md5() # nosec m.update(data) self._hash = m.hexdigest() if self._hash not in _datafiles: @@ -337,7 +337,8 @@ class CoverArtImage: except OSError as e: raise CoverArtImageIOError(e) - def _next_filename(self, filename, counters): + @staticmethod + def _next_filename(filename, counters): if counters[filename]: new_filename = "%s (%d)" % (decode_filename(filename), counters[filename]) else: diff --git a/resources/makeqrc.py b/resources/makeqrc.py index 730624cd8..f3072cabd 100755 --- a/resources/makeqrc.py +++ b/resources/makeqrc.py @@ -23,6 +23,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +"""Build a Qt resources file with all png images found under images/ +It will update qrc file only if images newer than it are found +""" from distutils import log from distutils.dep_util import newer @@ -31,20 +34,15 @@ import os import re -"""Build a Qt resources file with all png images found under images/ -It will update qrc file only if images newer than it are found -""" - - def tryint(s): try: return int(s) - except: + except BaseException: return s def natsort_key(s): - return [ tryint(c) for c in re.split(r'(\d+)', s) ] + return [tryint(c) for c in re.split(r'(\d+)', s)] def find_files(topdir, directory, patterns):