--- a/eric6/Plugins/VcsPlugins/vcsGit/GitStatusDialog.py Fri Apr 02 11:59:41 2021 +0200 +++ b/eric6/Plugins/VcsPlugins/vcsGit/GitStatusDialog.py Sat May 01 14:27:20 2021 +0200 @@ -10,6 +10,7 @@ import os import tempfile +import contextlib from PyQt5.QtCore import pyqtSlot, Qt, QProcess, QTimer, QSize from PyQt5.QtGui import QTextCursor @@ -50,7 +51,7 @@ @param vcs reference to the vcs object @param parent parent widget (QWidget) """ - super(GitStatusDialog, self).__init__(parent) + super().__init__(parent) self.setupUi(self) self.__toBeCommittedColumn = 0 @@ -288,7 +289,7 @@ """ Public slot to show the dialog. """ - super(GitStatusDialog, self).show() + super().show() geom = self.vcs.getPlugin().getPreferences( "StatusDialogGeometry") @@ -574,7 +575,7 @@ self.intercept = False evt.accept() return - super(GitStatusDialog, self).keyPressEvent(evt) + super().keyPressEvent(evt) @pyqtSlot() def on_refreshButton_clicked(self): @@ -1070,12 +1071,9 @@ """ self.lDiffEdit.clear() self.rDiffEdit.clear() - try: + with contextlib.suppress(AttributeError): self.lDiffHighlighter.regenerateRules() self.rDiffHighlighter.regenerateRules() - except AttributeError: - # backward compatibility - pass selectedItems = self.statusList.selectedItems() if len(selectedItems) == 1: @@ -1167,10 +1165,11 @@ """ cursor = self.lDiffEdit.textCursor() startIndex, endIndex = self.__selectedLinesIndexes(self.lDiffEdit) - if cursor.hasSelection(): - patch = self.lDiffParser.createLinesPatch(startIndex, endIndex) - else: - patch = self.lDiffParser.createHunkPatch(startIndex) + patch = ( + self.lDiffParser.createLinesPatch(startIndex, endIndex) + if cursor.hasSelection() else + self.lDiffParser.createHunkPatch(startIndex) + ) if patch: patchFile = self.__tmpPatchFileName() try: @@ -1188,11 +1187,12 @@ """ cursor = self.rDiffEdit.textCursor() startIndex, endIndex = self.__selectedLinesIndexes(self.rDiffEdit) - if cursor.hasSelection(): - patch = self.rDiffParser.createLinesPatch(startIndex, endIndex, - reverse=True) - else: - patch = self.rDiffParser.createHunkPatch(startIndex) + patch = ( + self.rDiffParser.createLinesPatch(startIndex, endIndex, + reverse=True) + if cursor.hasSelection() else + self.rDiffParser.createHunkPatch(startIndex) + ) if patch: patchFile = self.__tmpPatchFileName() try: @@ -1210,10 +1210,11 @@ """ cursor = self.lDiffEdit.textCursor() startIndex, endIndex = self.__selectedLinesIndexes(self.lDiffEdit) - if cursor.hasSelection(): - title = self.tr("Revert selected lines") - else: - title = self.tr("Revert hunk") + title = ( + self.tr("Revert selected lines") + if cursor.hasSelection() else + self.tr("Revert hunk") + ) res = E5MessageBox.yesNo( self, title,