diff --git a/src/importer/importer.py b/src/importer/importer.py index ca95a91..2a1e7b7 100644 --- a/src/importer/importer.py +++ b/src/importer/importer.py @@ -8,6 +8,7 @@ from src.utils.steamgriddb import SGDBAuthError, SGDBError, SGDBHelper from src.utils.task import Task +# pylint: disable=too-many-instance-attributes class Importer: """A class in charge of scanning sources for games""" @@ -87,9 +88,6 @@ class Importer: self.import_dialog.present() def update_progressbar(self): - logging.debug( - "Progressbar updated (%f)", self.progress - ) # TODO why progress not workie? self.progressbar.set_fraction(self.progress) def source_task_thread_func(self, _task, _obj, data, _cancellable): @@ -162,7 +160,7 @@ class Importer: except SGDBAuthError as error: cancellable.cancel() self.sgdb_error = error - except (HTTPError, SGDBError) as error: + except (HTTPError, SGDBError) as _error: # TODO handle other SGDB errors pass diff --git a/src/importer/source.py b/src/importer/source.py index 7a959ed..a2fca0c 100644 --- a/src/importer/source.py +++ b/src/importer/source.py @@ -28,7 +28,7 @@ class SourceIterator(Iterator, Sized): class Source(Iterable): """Source of games. E.g an installed app with a config file that lists game directories""" - win = None # TODO maybe not depend on that ? + win = None name: str variant: str diff --git a/src/importer/sources/lutris_source.py b/src/importer/sources/lutris_source.py index 25fe8aa..23c65b8 100644 --- a/src/importer/sources/lutris_source.py +++ b/src/importer/sources/lutris_source.py @@ -1,4 +1,4 @@ -from functools import cache +from functools import lru_cache from sqlite3 import connect from time import time @@ -48,7 +48,7 @@ class LutrisSourceIterator(SourceIterator): self.db_games_request, self.db_request_params ) - @cache + @lru_cache(maxsize=1) def __len__(self): cursor = self.db_connection.execute(self.db_len_request, self.db_request_params) return cursor.fetchone()[0] @@ -60,9 +60,9 @@ class LutrisSourceIterator(SourceIterator): row = None try: row = self.db_cursor.__next__() - except StopIteration as e: + except StopIteration as error: self.db_connection.close() - raise e + raise error # Create game values = { @@ -99,16 +99,13 @@ class LutrisSource(Source): @property def is_installed(self): + # pylint: disable=pointless-statement try: self.location self.cache_location except FileNotFoundError: return False - else: - return True - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) + return True def __iter__(self): return LutrisSourceIterator(source=self) diff --git a/src/utils/task.py b/src/utils/task.py index a698e8b..c6b7076 100644 --- a/src/utils/task.py +++ b/src/utils/task.py @@ -1,6 +1,7 @@ -from gi.repository import Gio from functools import wraps +from gi.repository import Gio + def create_task_thread_func_closure(func, data): """Wrap a Gio.TaskThreadFunc with the given data in a closure""" @@ -17,8 +18,7 @@ def decorate_set_task_data(task): def decorator(original_method): @wraps(original_method) def new_method(task_data): - task.__task_data = task_data - pass + task.task_data = task_data return new_method @@ -32,9 +32,7 @@ def decorate_run_in_thread(task): def decorator(original_method): @wraps(original_method) def new_method(task_thread_func): - closure = create_task_thread_func_closure( - task_thread_func, task.__task_data - ) + closure = create_task_thread_func_closure(task_thread_func, task.task_data) original_method(closure) return new_method @@ -42,6 +40,7 @@ def decorate_run_in_thread(task): return decorator +# pylint: disable=too-few-public-methods class Task: """Wrapper around Gio.Task to patch task data not being passed"""