From 3d57bb2937be754f630a7728dc117ccdda113e3a Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 18 Mar 2023 14:40:16 -0700 Subject: [PATCH] pylint: return unnecessary else after return Signed-off-by: David Aguilar --- .pylintrc | 1 - cola/polib.py | 1 + cola/themes.py | 9 ++++----- cola/widgets/compare.py | 29 +++++++++++++---------------- cola/widgets/diff.py | 6 ++---- cola/widgets/merge.py | 4 ++-- cola/widgets/standard.py | 9 ++++----- cola/widgets/status.py | 4 ++-- 8 files changed, 28 insertions(+), 35 deletions(-) diff --git a/.pylintrc b/.pylintrc index 45a3b375..2d012227 100644 --- a/.pylintrc +++ b/.pylintrc @@ -63,7 +63,6 @@ disable= fixme, invalid-name, missing-docstring, - no-else-return, raise-missing-from, super-with-arguments, too-many-instance-attributes, diff --git a/cola/polib.py b/cola/polib.py index 99fef395..f1321349 100644 --- a/cola/polib.py +++ b/cola/polib.py @@ -2,6 +2,7 @@ # # License: MIT (see extras/polib/LICENSE file provided) # vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: +# pylint: disable=no-else-return """ **polib** allows you to manipulate, create, modify gettext files (pot, po and diff --git a/cola/themes.py b/cola/themes.py index 1ac6357a..e4e809c6 100644 --- a/cola/themes.py +++ b/cola/themes.py @@ -37,12 +37,11 @@ class Theme(object): def build_style_sheet(self, app_palette): if self.style_sheet == EStylesheet.CUSTOM: return self.style_sheet_custom(app_palette) - elif self.style_sheet == EStylesheet.FLAT: + if self.style_sheet == EStylesheet.FLAT: return self.style_sheet_flat() - else: - window = app_palette.color(QtGui.QPalette.Window) - self.is_palette_dark = window.lightnessF() < 0.5 - return style_sheet_default(app_palette) + window = app_palette.color(QtGui.QPalette.Window) + self.is_palette_dark = window.lightnessF() < 0.5 + return style_sheet_default(app_palette) def build_palette(self, app_palette): QPalette = QtGui.QPalette diff --git a/cola/widgets/compare.py b/cola/widgets/compare.py index 06c0c58c..f5bf4663 100644 --- a/cola/widgets/compare.py +++ b/cola/widgets/compare.py @@ -195,22 +195,19 @@ class CompareBranchesDialog(standard.Dialog): tracked_branch = gitcmds.tracked_branch(context) if tracked_branch: return gitcmds.merge_base(context, branch, tracked_branch) - else: - remote_branches = gitcmds.branch_list(context, remote=True) - remote_branch = 'origin/%s' % branch - if remote_branch in remote_branches: - return gitcmds.merge_base(context, branch, remote_branch) - - if 'origin/main' in remote_branches: - return gitcmds.merge_base(context, branch, 'origin/main') - - if 'origin/master' in remote_branches: - return gitcmds.merge_base(context, branch, 'origin/master') - - return 'HEAD' - else: - # Compare against the remote branch - return branch + remote_branches = gitcmds.branch_list(context, remote=True) + remote_branch = 'origin/%s' % branch + if remote_branch in remote_branches: + return gitcmds.merge_base(context, branch, remote_branch) + + if 'origin/main' in remote_branches: + return gitcmds.merge_base(context, branch, 'origin/main') + + if 'origin/master' in remote_branches: + return gitcmds.merge_base(context, branch, 'origin/master') + return 'HEAD' + # Compare against the remote branch + return branch def update_combo_boxes(self, left=False): """Update listwidgets from the combobox selection diff --git a/cola/widgets/diff.py b/cola/widgets/diff.py index fff55efa..b02b1348 100644 --- a/cola/widgets/diff.py +++ b/cola/widgets/diff.py @@ -1176,15 +1176,13 @@ class DiffEditor(DiffTextEdit): patch = diffparse.Patch.parse(self.model.filename, self.model.diff_text) if self.has_selection(): return patch.extract_subset(first_line_idx, last_line_idx, reverse=reverse) - else: - return patch.extract_hunk(first_line_idx, reverse=reverse) + return patch.extract_hunk(first_line_idx, reverse=reverse) def patch_encoding(self): if isinstance(self.model.diff_text, core.UStr): # original encoding must prevail return self.model.diff_text.encoding - else: - return self.context.cfg.file_encoding(self.model.filename) + return self.context.cfg.file_encoding(self.model.filename) def process_diff_selection( self, reverse=False, apply_to_worktree=False, edit=False diff --git a/cola/widgets/merge.py b/cola/widgets/merge.py index 98b88392..f325ec3d 100644 --- a/cola/widgets/merge.py +++ b/cola/widgets/merge.py @@ -202,9 +202,9 @@ class Merge(standard.Dialog): """Retrieve candidate items to merge""" if get(self.radio_local): return self.model.local_branches - elif get(self.radio_remote): + if get(self.radio_remote): return self.model.remote_branches - elif get(self.radio_tag): + if get(self.radio_tag): return self.model.tags return [] diff --git a/cola/widgets/standard.py b/cola/widgets/standard.py index 972784ca..49d6587d 100644 --- a/cola/widgets/standard.py +++ b/cola/widgets/standard.py @@ -375,12 +375,11 @@ class TreeMixin(object): widget = self.widget if hasattr(widget, 'selectedItems'): return widget.selectedItems() + if hasattr(widget, 'itemFromIndex'): + item_from_index = widget.itemFromIndex else: - if hasattr(widget, 'itemFromIndex'): - item_from_index = widget.itemFromIndex - else: - item_from_index = widget.model().itemFromIndex - return [item_from_index(i) for i in widget.selectedIndexes()] + item_from_index = widget.model().itemFromIndex + return [item_from_index(i) for i in widget.selectedIndexes()] def selected_item(self): """Return the first selected item""" diff --git a/cola/widgets/status.py b/cola/widgets/status.py index 304c9c23..0073cbe0 100644 --- a/cola/widgets/status.py +++ b/cola/widgets/status.py @@ -502,7 +502,7 @@ class StatusTreeWidget(QtWidgets.QTreeWidget): # if the modified or untracked headers are selected. cmds.do(cmds.UnstageAll, context) return # Everything was unstaged. There's nothing more to be done. - elif is_modified and is_untracked: + if is_modified and is_untracked: # If both modified and untracked headers are selected then # stage everything. cmds.do(cmds.StageModifiedAndUntracked, context) @@ -511,7 +511,7 @@ class StatusTreeWidget(QtWidgets.QTreeWidget): # possibly a subset of the other category (eg. all modified and # some untracked). We don't return here so that StageOrUnstage # gets a chance to run below. - elif is_modified: + if is_modified: cmds.do(cmds.StageModified, context) elif is_untracked: cmds.do(cmds.StageUntracked, context) -- 2.11.4.GIT