diff --git a/plexapi/alert.py b/plexapi/alert.py index bf6e5394f..9e0310fd5 100644 --- a/plexapi/alert.py +++ b/plexapi/alert.py @@ -84,4 +84,4 @@ def _onError(self, *args): # pragma: no cover This is to support compatibility with current and previous releases of websocket-client. """ err = args[-1] - log.error('AlertListener Error: %s' % err) + log.error('AlertListener Error: %s', err) diff --git a/plexapi/base.py b/plexapi/base.py index 9c3446be3..96dbad604 100644 --- a/plexapi/base.py +++ b/plexapi/base.py @@ -397,7 +397,7 @@ def __getattribute__(self, attr): clsname = self.__class__.__name__ title = self.__dict__.get('title', self.__dict__.get('name')) objname = "%s '%s'" % (clsname, title) if title else clsname - log.debug("Reloading %s for attr '%s'" % (objname, attr)) + log.debug("Reloading %s for attr '%s'", objname, attr) # Reload and return the value self.reload() return super(PlexPartialObject, self).__getattribute__(attr) @@ -501,7 +501,7 @@ def delete(self): return self._server.query(self.key, method=self._server._session.delete) except BadRequest: # pragma: no cover log.error('Failed to delete %s. This could be because you ' - 'havnt allowed items to be deleted' % self.key) + 'have not allowed items to be deleted', self.key) raise def history(self, maxresults=9999999, mindate=None): diff --git a/plexapi/library.py b/plexapi/library.py index 85e4a1441..206eb118f 100644 --- a/plexapi/library.py +++ b/plexapi/library.py @@ -723,7 +723,7 @@ def _cleanSearchFilter(self, category, value, libtype=None): result = set() choices = self.listChoices(category, libtype) lookup = {c.title.lower(): unquote(unquote(c.key)) for c in choices} - allowed = set(c.key for c in choices) + allowed = {c.key for c in choices} for item in value: item = str((item.id or item.tag) if isinstance(item, media.MediaTag) else item).lower() # find most logical choice(s) to use in url diff --git a/plexapi/settings.py b/plexapi/settings.py index 8416f8718..734cc1198 100644 --- a/plexapi/settings.py +++ b/plexapi/settings.py @@ -44,7 +44,7 @@ def _loadData(self, data): def all(self): """ Returns a list of all :class:`~plexapi.settings.Setting` objects available. """ - return list(v for id, v in sorted(self._settings.items())) + return [v for id, v in sorted(self._settings.items())] def get(self, id): """ Return the :class:`~plexapi.settings.Setting` object with the specified id. """ @@ -102,7 +102,7 @@ class Setting(PlexObject): group (str): Group name this setting is categorized as. enumValues (list,dict): List or dictionary of valis values for this setting. """ - _bool_cast = lambda x: True if x == 'true' or x == '1' else False + _bool_cast = lambda x: bool(x == 'true' or x == '1') _bool_str = lambda x: str(x).lower() TYPES = { 'bool': {'type': bool, 'cast': _bool_cast, 'tostr': _bool_str}, diff --git a/plexapi/utils.py b/plexapi/utils.py index e4225941c..be07672ee 100644 --- a/plexapi/utils.py +++ b/plexapi/utils.py @@ -176,7 +176,7 @@ def threaded(callback, listargs): threads[-1].setDaemon(True) threads[-1].start() while not job_is_done_event.is_set(): - if all([not t.is_alive() for t in threads]): + if all(not t.is_alive() for t in threads): break time.sleep(0.05) diff --git a/tests/test_history.py b/tests/test_history.py index af5c65fef..bc23eb1bb 100644 --- a/tests/test_history.py +++ b/tests/test_history.py @@ -1,10 +1,4 @@ # -*- coding: utf-8 -*- -from datetime import datetime - -import pytest -from plexapi.exceptions import BadRequest, NotFound - -from . import conftest as utils def test_history_Movie(movie): diff --git a/tests/test_video.py b/tests/test_video.py index 4eba01b0d..a2e617019 100644 --- a/tests/test_video.py +++ b/tests/test_video.py @@ -134,7 +134,7 @@ def test_video_Movie_upload_select_remove_subtitle(movie, subtitle): assert subname in subtitles subtitleSelection = movie.subtitleStreams()[0] - parts = [part for part in movie.iterParts()] + parts = list(movie.iterParts()) parts[0].setDefaultSubtitleStream(subtitleSelection) movie.reload() diff --git a/tools/plex-backupwatched.py b/tools/plex-backupwatched.py index 5307e3125..4cacd1160 100755 --- a/tools/plex-backupwatched.py +++ b/tools/plex-backupwatched.py @@ -51,7 +51,7 @@ def _iter_items(section): def backup_watched(plex, opts): """ Backup watched status to the specified filepath. """ - data = defaultdict(lambda: dict()) + data = defaultdict(lambda: {}) for section in _iter_sections(plex, opts): print('Fetching watched status for %s..' % section.title) skey = section.title.lower() @@ -70,7 +70,7 @@ def restore_watched(plex, opts): with open(opts.filepath, 'r') as handle: source = json.load(handle) # Find the differences - differences = defaultdict(lambda: dict()) + differences = defaultdict(lambda: {}) for section in _iter_sections(plex, opts): print('Finding differences in %s..' % section.title) skey = section.title.lower()