From 4eb8eab5968a6967f2cf85ad8128a50c6b318600 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Fri, 24 Feb 2023 22:38:13 -0800 Subject: [PATCH] widgets: pylint tweaks, docstrings and use queued connections Signed-off-by: David Aguilar --- cola/widgets/browse.py | 1 + cola/widgets/commitmsg.py | 2 ++ cola/widgets/completion.py | 11 ++++++----- cola/widgets/switcher.py | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cola/widgets/browse.py b/cola/widgets/browse.py index 54d5c659..f62fa1a5 100644 --- a/cola/widgets/browse.py +++ b/cola/widgets/browse.py @@ -53,6 +53,7 @@ def save_path(context, path, model): class Browser(standard.Widget): + """A repository branch file browser. Browses files provided by GitRepoModel""" # Read-only mode property mode = property(lambda self: self.model.mode) diff --git a/cola/widgets/commitmsg.py b/cola/widgets/commitmsg.py index 3643f142..b8bf3482 100644 --- a/cola/widgets/commitmsg.py +++ b/cola/widgets/commitmsg.py @@ -557,7 +557,9 @@ class CommitMessageEditor(QtWidgets.QFrame): self.description.highlighter.enable(enabled) +# pylint: disable=too-many-ancestors class CommitSummaryLineEdit(SpellCheckLineEdit): + """Text input field for the commit summary""" down_pressed = Signal() accepted = Signal() diff --git a/cola/widgets/completion.py b/cola/widgets/completion.py index 168a9e27..50233ef0 100644 --- a/cola/widgets/completion.py +++ b/cola/widgets/completion.py @@ -300,7 +300,8 @@ class GatherCompletionsThread(QtCore.QThread): utils.catch_runtime_error(self.wait) def run(self): - text = None + text = '' + items = [] self.running = True # Loop when the matched text changes between the start and end time. # This happens when gather_matches() takes too long and the @@ -475,7 +476,6 @@ def _lower(x): def filter_matches(match_text, candidates, case_sensitive, sort_key=lambda x: x): """Filter candidates and return the matches""" - if case_sensitive: case_transform = _identity else: @@ -493,7 +493,6 @@ def filter_matches(match_text, candidates, case_sensitive, sort_key=lambda x: x) def filter_path_matches(match_text, file_list, case_sensitive): """Return matching completions from a list of candidate files""" - files = set(file_list) files_and_dirs = utils.add_parents(files) dirs = files_and_dirs.difference(files) @@ -526,7 +525,7 @@ class GitCompletionModel(CompletionModel): def __init__(self, context, parent): CompletionModel.__init__(self, context, parent) self.context = context - context.model.updated.connect(self.model_updated) + context.model.updated.connect(self.model_updated, type=Qt.QueuedConnection) def gather_matches(self, case_sensitive): refs = filter_matches( @@ -544,7 +543,7 @@ class GitRefCompletionModel(GitCompletionModel): def __init__(self, context, parent): GitCompletionModel.__init__(self, context, parent) - context.model.refs_updated.connect(self.model_updated) + context.model.refs_updated.connect(self.model_updated, type=Qt.QueuedConnection) def matches(self): model = self.context.model @@ -675,6 +674,7 @@ class GitLogCompletionModel(GitRefCompletionModel): self._model = context.model def gather_paths(self): + """Gather paths and store them in the model""" if not self._model.cfg.get(prefs.AUTOCOMPLETE_PATHS, True): self._paths = [] return @@ -682,6 +682,7 @@ class GitLogCompletionModel(GitRefCompletionModel): self._paths = gitcmds.tracked_files(context) def gather_matches(self, case_sensitive): + """Filter paths and refs to find matching entries""" if not self._paths: self.gather_paths() refs = filter_matches( diff --git a/cola/widgets/switcher.py b/cola/widgets/switcher.py index 67ba402a..1bae5d42 100644 --- a/cola/widgets/switcher.py +++ b/cola/widgets/switcher.py @@ -231,6 +231,7 @@ class SwitcherSortFilterProxyModel(QtCore.QSortFilterProxyModel): return self.entries.itemFromIndex(self.mapToSource(index)) +# pylint: disable=too-many-ancestors class SwitcherTreeView(standard.TreeView): """Tree view class for showing proxy items in SwitcherSortFilterProxyModel""" -- 2.11.4.GIT