Make methods static that don't access instance
MODIFY
plex_trakt_sync/config.py
plex_trakt_sync/config.py
@@ -64,7 +64,8 @@ def save(self):
else:
txt.write("{}=\n".format(key))
- def load_json(self, path):
+ @staticmethod
+ def load_json(path):
with open(path, "r") as fp:
try:
config = json.load(fp)

MODIFY
plex_trakt_sync/plex_api.py
plex_trakt_sync/plex_api.py
@@ -323,7 +323,8 @@ def season_number(self):
def episode_number(self):
return self.item.index
- def date_value(self, date):
+ @staticmethod
+ def date_value(date):
if not date:
raise ValueError("Value can't be None")

MODIFY
plex_trakt_sync/trakt_api.py
plex_trakt_sync/trakt_api.py
@@ -60,7 +60,8 @@ def __init__(self, batch_size=None):
trakt.core.session = factory.session()
load_config()
- def device_auth(self, client_id: str, client_secret: str):
+ @staticmethod
+ def device_auth(client_id: str, client_secret: str):
trakt.core.AUTH_METHOD = trakt.core.DEVICE_AUTH
return trakt.init(client_id=client_id, client_secret=client_secret, store=True)
@@ -170,7 +171,8 @@ def rating(self, m):
def rate(self, m, rating):
m.rate(rating)
- def scrobbler(self, media: Union[Movie, TVEpisode]) -> ScrobblerProxy:
+ @staticmethod
+ def scrobbler(media: Union[Movie, TVEpisode]) -> ScrobblerProxy:
scrobbler = media.scrobble(0, None, None)
return ScrobblerProxy(scrobbler)
@@ -321,10 +323,12 @@ def add_to_collection(self, media_type: str, item):
self.collection[media_type].append(item)
self.flush()
- def trakt_sync_collection(self, media_object):
+ @staticmethod
+ def trakt_sync_collection(media_object):
return trakt.sync.add_to_collection(media_object)
- def remove_empty_values(self, result):
+ @staticmethod
+ def remove_empty_values(result):
"""
Update result to remove empty changes.
This makes diagnostic printing cleaner if we don't print "changed: 0"

Make methods static that don't access instance