Skip to content

Commit 6fad48f

Browse files
committed
Code quality
1 parent 7a81d76 commit 6fad48f

19 files changed

Lines changed: 76 additions & 46 deletions

setup.cfg

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ ignore = E722,F841,W503
1818
# pylint honours the [MESSAGES CONTROL] section
1919
# as well as [MASTER] section
2020
[MESSAGES CONTROL]
21-
disable=invalid-name,bare-except,broad-except,superfluous-parens
21+
disable=
22+
invalid-name,bare-except,broad-except,superfluous-parens,
23+
bad-option-value
2224
# invalid-name: needs fixing during a large, project-wide refactor
2325
# bare-except,broad-except: Need fixing once thorough testing is easier
26+
# bad-option-value is for backward compatibility between python 2 and 3
2427
max-args = 8
2528
max-attributes = 8
2629

src/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272

7373
import six
7474
from six.moves import configparser, http_client, xmlrpc_server
75-
from six.moves.reprlib import repr
75+
from six.moves.reprlib import repr # pylint: disable=redefined-builtin,import-error
7676

7777
import helper_inbox
7878
import helper_sent

src/bitmessagemain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# yet contain logic to expand into further streams.
1212

1313
# flake8: noqa:402
14-
# pylint: disable=superfluous-parens
14+
# pylint: disable=superfluous-parens,relative-import
1515
import os
1616
import sys
1717

src/bitmessageqt/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
PyQt based UI for bitmessage, the main module
33
"""
4-
4+
# pylint: disable=import-error,relative-import,too-many-lines
55
import hashlib
66
import locale
77
import os
@@ -239,20 +239,20 @@ def init_inbox_popup_menu(self, connectSignal=True):
239239
QtCore.Qt.CustomContextMenu)
240240
if connectSignal:
241241
self.connect(self.ui.tableWidgetInbox, QtCore.SIGNAL(
242-
'customContextMenuRequested(const QPoint&)'),
243-
self.on_context_menuInbox)
242+
'customContextMenuRequested(const QPoint&)'),
243+
self.on_context_menuInbox)
244244
self.ui.tableWidgetInboxSubscriptions.setContextMenuPolicy(
245245
QtCore.Qt.CustomContextMenu)
246246
if connectSignal:
247247
self.connect(self.ui.tableWidgetInboxSubscriptions, QtCore.SIGNAL(
248-
'customContextMenuRequested(const QPoint&)'),
249-
self.on_context_menuInbox)
248+
'customContextMenuRequested(const QPoint&)'),
249+
self.on_context_menuInbox)
250250
self.ui.tableWidgetInboxChans.setContextMenuPolicy(
251251
QtCore.Qt.CustomContextMenu)
252252
if connectSignal:
253253
self.connect(self.ui.tableWidgetInboxChans, QtCore.SIGNAL(
254-
'customContextMenuRequested(const QPoint&)'),
255-
self.on_context_menuInbox)
254+
'customContextMenuRequested(const QPoint&)'),
255+
self.on_context_menuInbox)
256256

257257
def init_identities_popup_menu(self, connectSignal=True):
258258
# Popup menu for the Your Identities tab
@@ -291,8 +291,8 @@ def init_identities_popup_menu(self, connectSignal=True):
291291
QtCore.Qt.CustomContextMenu)
292292
if connectSignal:
293293
self.connect(self.ui.treeWidgetYourIdentities, QtCore.SIGNAL(
294-
'customContextMenuRequested(const QPoint&)'),
295-
self.on_context_menuYourIdentities)
294+
'customContextMenuRequested(const QPoint&)'),
295+
self.on_context_menuYourIdentities)
296296

297297
# load all gui.menu plugins with prefix 'address'
298298
self.menu_plugins = {'address': []}

src/bitmessageqt/account.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Account related functions.
77
88
"""
9-
9+
# pylint: disable=import-error
1010
from __future__ import absolute_import
1111

1212
import inspect

src/bitmessageqt/address_dialogs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""
22
Dialogs that work with BM address.
33
"""
4-
# pylint: disable=attribute-defined-outside-init,too-few-public-methods,relative-import
4+
# pylint: disable=attribute-defined-outside-init,too-few-public-methods
5+
# pylint: disable=relative-import,import-error
56

67
import hashlib
78

src/bitmessageqt/addressvalidator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Address validator module.
33
"""
44
# pylint: disable=too-many-branches,too-many-arguments
5+
# pylint: disable=import-error,relative-import
56

67
from Queue import Empty
78

@@ -103,7 +104,7 @@ def returnValid(self):
103104
return QtGui.QValidator.Acceptable
104105
return QtGui.QValidator.Intermediate
105106

106-
def validate(self, s, pos):
107+
def validate(self, s, pos): # pylint: disable=unused-argument
107108
"""Top level validator method"""
108109
if self.addressObject is None:
109110
address = None

src/bitmessageqt/bitmessage_icons_rc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# WARNING! All changes made in this file will be lost!
99

10-
from PyQt4 import QtCore
10+
from PyQt4 import QtCore # pylint: disable=import-error
1111

1212
qt_resource_data = "\
1313
\x00\x00\x03\x66\

src/bitmessageqt/messagecompose.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"""
22
Message editor with a wheel zoom functionality
33
"""
4-
# pylint: disable=bad-continuation
54

6-
from PyQt4 import QtCore, QtGui
5+
from PyQt4 import QtCore, QtGui # pylint disable:import-error
76

87

98
class MessageCompose(QtGui.QTextEdit):
@@ -15,18 +14,22 @@ def __init__(self, parent=0):
1514

1615
def wheelEvent(self, event):
1716
"""Mouse wheel scroll event handler"""
18-
if (
19-
QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ControlModifier
20-
) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical:
17+
if (QtGui.QApplication.queryKeyboardModifiers()
18+
& QtCore.Qt.ControlModifier) == \
19+
QtCore.Qt.ControlModifier \
20+
and event.orientation() == QtCore.Qt.Vertical:
2121
if event.delta() > 0:
2222
self.zoomIn(1)
2323
else:
2424
self.zoomOut(1)
25-
zoom = self.currentFont().pointSize() * 100 / self.defaultFontPointSize
26-
QtGui.QApplication.activeWindow().statusBar().showMessage(
27-
QtGui.QApplication.translate("MainWindow", "Zoom level %1%").arg(
28-
str(zoom)
29-
)
25+
zoom = self.currentFont().pointSize() \
26+
* 100 \
27+
/ self.defaultFontPointSize
28+
QtGui.QApplication.activeWindow().statusBar(). \
29+
showMessage(
30+
QtGui.QApplication.translate("MainWindow",
31+
"Zoom level %1%").
32+
arg(str(zoom))
3033
)
3134
else:
3235
# in QTextEdit, super does not zoom, only scroll

src/bitmessageqt/messageview.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,17 @@ def wheelEvent(self, event):
5252
# super will actually automatically take care of zooming
5353
super(MessageView, self).wheelEvent(event)
5454
if (
55-
QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ControlModifier
56-
) == QtCore.Qt.ControlModifier and event.orientation() == QtCore.Qt.Vertical:
57-
zoom = self.currentFont().pointSize() * 100 / self.defaultFontPointSize
58-
QtGui.QApplication.activeWindow().statusBar().showMessage(_translate(
59-
"MainWindow", "Zoom level %1%").arg(str(zoom)))
55+
QtGui.QApplication.queryKeyboardModifiers()
56+
& QtCore.Qt.ControlModifier) == \
57+
QtCore.Qt.ControlModifier \
58+
and event.orientation() == QtCore.Qt.Vertical:
59+
zoom = self.currentFont().pointSize() \
60+
* 100 \
61+
/ self.defaultFontPointSize
62+
QtGui.QApplication.activeWindow().statusBar().\
63+
showMessage(_translate("MainWindow",
64+
"Zoom level %1%").
65+
arg(str(zoom)))
6066

6167
def setWrappingWidth(self, width=None):
6268
"""Set word-wrapping width"""
@@ -114,17 +120,21 @@ def lazyRender(self):
114120
self.rendering = True
115121
position = self.verticalScrollBar().value()
116122
cursor = QtGui.QTextCursor(self.document())
117-
while self.outpos < len(self.out) and self.verticalScrollBar().value(
118-
) >= self.document().size().height() - 2 * self.size().height():
123+
while self.outpos < len(self.out) \
124+
and self.verticalScrollBar().value() \
125+
>= self.document().size().height() \
126+
- 2 * self.size().height():
119127
startpos = self.outpos
120128
self.outpos += 10240
121129
# find next end of tag
122130
if self.mode == MessageView.MODE_HTML:
123131
pos = self.out.find(">", self.outpos)
124132
if pos > self.outpos:
125133
self.outpos = pos + 1
126-
cursor.movePosition(QtGui.QTextCursor.End, QtGui.QTextCursor.MoveAnchor)
127-
cursor.insertHtml(QtCore.QString(self.out[startpos:self.outpos]))
134+
cursor.movePosition(QtGui.QTextCursor.End,
135+
QtGui.QTextCursor.MoveAnchor)
136+
cursor.insertHtml(
137+
QtCore.QString(self.out[startpos:self.outpos]))
128138
self.verticalScrollBar().setValue(position)
129139
self.rendering = False
130140

0 commit comments

Comments
 (0)