Updated code quality ignored bare except warning code changes in bitmessageqt/__init__.py

This commit is contained in:
kuldeep.k@cisinlabs.com 2021-08-24 20:50:07 +05:30
parent 6dffb1e470
commit 06707b3e1b
No known key found for this signature in database
GPG Key ID: AF4FB299BF7C7C2A

View File

@ -100,12 +100,12 @@ class MyForm(settingsmixin.SMainWindow):
try: try:
if not self.qmytranslator.isEmpty(): if not self.qmytranslator.isEmpty():
QtGui.QApplication.removeTranslator(self.qmytranslator) QtGui.QApplication.removeTranslator(self.qmytranslator)
except: except: # noqa:E722
pass pass
try: try:
if not self.qsystranslator.isEmpty(): if not self.qsystranslator.isEmpty():
QtGui.QApplication.removeTranslator(self.qsystranslator) QtGui.QApplication.removeTranslator(self.qsystranslator)
except: except: # noqa:E722
pass pass
self.qmytranslator = QtCore.QTranslator() self.qmytranslator = QtCore.QTranslator()
@ -142,7 +142,7 @@ class MyForm(settingsmixin.SMainWindow):
l10n.encoding = locale.getlocale()[1] l10n.encoding = locale.getlocale()[1]
logger.info("Successfully set locale to %s", lang) logger.info("Successfully set locale to %s", lang)
break break
except: except: # noqa:E722
logger.error("Failed to set locale to %s", lang, exc_info=True) logger.error("Failed to set locale to %s", lang, exc_info=True)
def init_file_menu(self): def init_file_menu(self):
@ -456,7 +456,7 @@ class MyForm(settingsmixin.SMainWindow):
subwidget.setUnreadCount(db[toAddress][subwidget.folderName]['count']) subwidget.setUnreadCount(db[toAddress][subwidget.folderName]['count'])
unread += db[toAddress][subwidget.folderName]['count'] unread += db[toAddress][subwidget.folderName]['count']
db[toAddress].pop(subwidget.folderName, None) db[toAddress].pop(subwidget.folderName, None)
except: except: # noqa:E722
widget.takeChild(j) widget.takeChild(j)
# no increment # no increment
continue continue
@ -576,7 +576,7 @@ class MyForm(settingsmixin.SMainWindow):
if subwidget.folderName not in ("new", "trash", "sent"): if subwidget.folderName not in ("new", "trash", "sent"):
unread += db[toAddress][subwidget.folderName] unread += db[toAddress][subwidget.folderName]
db[toAddress].pop(subwidget.folderName, None) db[toAddress].pop(subwidget.folderName, None)
except: except: # noqa:E722
widget.takeChild(j) widget.takeChild(j)
# no increment # no increment
continue continue
@ -1605,7 +1605,7 @@ class MyForm(settingsmixin.SMainWindow):
try: try:
addressVersionNumber = int( addressVersionNumber = int(
dialog.lineEditAddressVersionNumber.text()) dialog.lineEditAddressVersionNumber.text())
except: except: # noqa:E722
QtGui.QMessageBox.about( QtGui.QMessageBox.about(
self, self,
_translate("MainWindow", "Bad address version number"), _translate("MainWindow", "Bad address version number"),
@ -1834,7 +1834,7 @@ class MyForm(settingsmixin.SMainWindow):
sent.item(i, 3).setToolTip(textToDisplay) sent.item(i, 3).setToolTip(textToDisplay)
try: try:
newlinePosition = textToDisplay.indexOf('\n') newlinePosition = textToDisplay.indexOf('\n')
except: # If someone misses adding a "_translate" to a string before passing it to this function, this function won't receive a qstring which will cause an exception. except: # noqa:E722 # If someone misses adding a "_translate" to a string before passing it to this function, this function won't receive a qstring which will cause an exception.
newlinePosition = 0 newlinePosition = 0
if newlinePosition > 1: if newlinePosition > 1:
sent.item(i, 3).setText( sent.item(i, 3).setText(
@ -1862,7 +1862,7 @@ class MyForm(settingsmixin.SMainWindow):
sent.item(i, 3).setToolTip(textToDisplay) sent.item(i, 3).setToolTip(textToDisplay)
try: try:
newlinePosition = textToDisplay.indexOf('\n') newlinePosition = textToDisplay.indexOf('\n')
except: # If someone misses adding a "_translate" to a string before passing it to this function, this function won't receive a qstring which will cause an exception. except: # noqa:E722 # If someone misses adding a "_translate" to a string before passing it to this function, this function won't receive a qstring which will cause an exception.
newlinePosition = 0 newlinePosition = 0
if newlinePosition > 1: if newlinePosition > 1:
sent.item(i, 3).setText( sent.item(i, 3).setText(
@ -2079,7 +2079,7 @@ class MyForm(settingsmixin.SMainWindow):
if status != 'success': if status != 'success':
try: try:
toAddress = unicode(toAddress, 'utf-8', 'ignore') toAddress = unicode(toAddress, 'utf-8', 'ignore')
except: except: # noqa:E722
pass pass
logger.error('Error: Could not decode recipient address ' + toAddress + ':' + status) logger.error('Error: Could not decode recipient address ' + toAddress + ':' + status)
@ -3163,7 +3163,7 @@ class MyForm(settingsmixin.SMainWindow):
try: try:
subjectAtCurrentInboxRow = str(tableWidget.item( subjectAtCurrentInboxRow = str(tableWidget.item(
currentInboxRow, 2).data(QtCore.Qt.UserRole)) currentInboxRow, 2).data(QtCore.Qt.UserRole))
except: except: # noqa:E722
subjectAtCurrentInboxRow = '' subjectAtCurrentInboxRow = ''
# Retrieve the message data out of the SQL database # Retrieve the message data out of the SQL database
@ -3438,7 +3438,7 @@ class MyForm(settingsmixin.SMainWindow):
return self.ui.treeWidgetSubscriptions return self.ui.treeWidgetSubscriptions
else: else:
return self.ui.treeWidgetYourIdentities return self.ui.treeWidgetYourIdentities
except: except: # noqa:E722
return self.ui.treeWidgetYourIdentities return self.ui.treeWidgetYourIdentities
def getCurrentMessagelist(self): def getCurrentMessagelist(self):
@ -3460,7 +3460,7 @@ class MyForm(settingsmixin.SMainWindow):
return self.ui.tableWidgetInboxSubscriptions return self.ui.tableWidgetInboxSubscriptions
else: else:
return self.ui.tableWidgetInbox return self.ui.tableWidgetInbox
except: except: # noqa:E722
return self.ui.tableWidgetInbox return self.ui.tableWidgetInbox
def getCurrentMessageId(self): def getCurrentMessageId(self):
@ -3489,7 +3489,7 @@ class MyForm(settingsmixin.SMainWindow):
return self.ui.textEditInboxSubscriptions return self.ui.textEditInboxSubscriptions
else: else:
return self.ui.textEditInboxMessage return self.ui.textEditInboxMessage
except: except: # noqa:E722
return self.ui.textEditInboxMessage return self.ui.textEditInboxMessage
def getCurrentSearchLine(self, currentIndex=None, retObj=False): def getCurrentSearchLine(self, currentIndex=None, retObj=False):