Skip to content

Commit d8f81a9

Browse files
committed
Code quality
1 parent f6f5273 commit d8f81a9

27 files changed

Lines changed: 167 additions & 110 deletions

.devcontainer/devcontainer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
"visualstudioexptteam.vscodeintellicode"
1818
],
1919
"settings": {
20+
"python.defaultInterpreterPath": "/usr/bin/python3",
21+
"flake8.interpreter": ["/usr/bin/python3"],
22+
"flake8.importStrategy": "fromEnvironment",
2023
"flake8.args": ["--config=setup.cfg"],
24+
"pylint.interpreter": ["/usr/bin/python3"],
2125
"pylint.args": ["--rcfile=setup.cfg", "--init-hook", "import sys;sys.path.append('src')"],
2226
"terminal.integrated.shell.linux": "/usr/bin/zsh",
2327
"terminal.integrated.defaultProfile.linux": "zsh",

.devcontainer/postCreateCommand.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/bin/sh
22

33
pip3 install -r requirements.txt
4-
pip3 install -r kivy-requirements.txt
4+
pip3 install -r kivy-requirements.txt
5+
6+
# Linter tools needed by the VS Code extensions (ms-python.flake8,
7+
# ms-python.pylint, nwgh.bandit). The apt-installed system packages
8+
# are not visible to the VS Code Python interpreter.
9+
pip3 install flake8 pylint bandit

setup.cfg

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,35 @@ ignore = E722,F841,W503
1515
# F841: pylint is preferred for unused-variable
1616
# W503: deprecated: https://bugs.python.org/issue26763 - https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator
1717

18-
# pylint honours the [MESSAGES CONTROL] section
19-
# as well as [MASTER] section
20-
[MESSAGES CONTROL]
21-
disable=
22-
invalid-name,bare-except,broad-except,superfluous-parens,
23-
bad-option-value
18+
# -- pylint (modern, >= 2.14) -- pylint.*-prefixed sections for setup.cfg
19+
20+
[pylint.main]
21+
init-hook = import sys;sys.path.append('src')
22+
ignore = bitmessagekivy
23+
24+
[pylint.messages_control]
25+
disable =
26+
invalid-name,bare-except,broad-except,relative-import,
27+
superfluous-parens,bad-option-value
2428
# invalid-name: needs fixing during a large, project-wide refactor
2529
# bare-except,broad-except: Need fixing once thorough testing is easier
2630
# bad-option-value is for backward compatibility between python 2 and 3
31+
32+
[pylint.design]
2733
max-args = 8
2834
max-attributes = 8
2935

36+
# -- pylint (legacy, < 2.0 / python 2.7) -- old .pylintrc-style section names
37+
3038
[MASTER]
3139
init-hook = import sys;sys.path.append('src')
3240
ignore = bitmessagekivy
41+
42+
[MESSAGES CONTROL]
43+
disable =
44+
invalid-name,bare-except,broad-except,relative-import,
45+
superfluous-parens,bad-option-value
46+
47+
[DESIGN]
48+
max-args = 8
49+
max-attributes = 8

src/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
For further examples please reference `.tests.test_api`.
5858
"""
5959

60-
# pylint: disable=too-many-lines,relative-import
60+
# pylint: disable=too-many-lines
6161

6262
import base64
6363
import errno

src/bitmessagecli.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33
# pylint: disable=too-many-lines,global-statement,too-many-branches,too-many-statements,inconsistent-return-statements
44
# pylint: disable=too-many-nested-blocks,too-many-locals,protected-access,too-many-arguments,too-many-function-args
5-
# pylint: disable=no-member
5+
# pylint: disable=no-member,superfluous-parens
66
"""
77
Created by Adam Melton (.dok) referenceing https://bitmessage.org/wiki/API_Reference for API documentation
88
Distributed under the MIT/X11 software license. See http://www.opensource.org/licenses/mit-license.php.
@@ -16,15 +16,14 @@
1616
import datetime
1717
import imghdr
1818
import json
19-
import ntpath
2019
import os
2120
import socket
2221
import sys
2322
import time
24-
2523
from six.moves import input as raw_input
2624
from six.moves import xmlrpc_client as xmlrpclib
2725

26+
import ntpath
2827
from bmconfigparser import config
2928

3029

src/bitmessagemain.py

Lines changed: 4 additions & 5 deletions
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,relative-import
14+
# pylint: disable=superfluous-parens
1515
import os
1616
import sys
1717

@@ -212,7 +212,7 @@ def start(self):
212212

213213
# API is also objproc dependent
214214
if config.safeGetBoolean('bitmessagesettings', 'apienabled'):
215-
import api # pylint: disable=relative-import
215+
import api
216216
singleAPIThread = api.singleAPI()
217217
# close the main program even if there are threads left
218218
singleAPIThread.daemon = True
@@ -256,14 +256,13 @@ def start(self):
256256
while state.shutdown == 0:
257257
time.sleep(1)
258258
if (
259-
state.testmode
260-
and time.time() - state.last_api_response >= 30
259+
state.testmode
260+
and time.time() - state.last_api_response >= 30
261261
):
262262
self.stop()
263263
elif not state.enableGUI:
264264
state.enableGUI = True
265265
try:
266-
# pylint: disable=relative-import
267266
from tests import core as test_core
268267
except ImportError:
269268
try:

src/bitmessageqt/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
PyQt based UI for bitmessage, the main module
33
"""
4-
# pylint: disable=import-error,relative-import,too-many-lines
4+
# pylint: disable=import-error,too-many-lines
55
import hashlib
66
import locale
77
import os

src/bitmessageqt/address_dialogs.py

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

77
import hashlib
88

src/bitmessageqt/addressvalidator.py

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

77
from Queue import Empty
88

src/bitmessageqt/newchandialog.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
=================================
44
55
"""
6-
# pylint: disable=import-error,relative-import,ungrouped-imports
6+
# pylint: disable=import-error,ungrouped-imports,wrong-import-order
77
from PyQt4 import QtCore, QtGui
88

99
import widgets
@@ -67,20 +67,28 @@ def accept(self):
6767
self.chanPassPhrase.text().toUtf8(),
6868
True))
6969
addressGeneratorReturnValue = apiAddressGeneratorReturnQueue.get(True)
70-
if addressGeneratorReturnValue and addressGeneratorReturnValue[0] != 'chan name does not match address':
71-
UISignalQueue.put(('updateStatusBar', _translate(
72-
"newchandialog", "Successfully created / joined chan %1").arg(unicode(self.chanPassPhrase.text()))))
70+
if addressGeneratorReturnValue \
71+
and addressGeneratorReturnValue[0] \
72+
!= 'chan name does not match address':
73+
UISignalQueue.put(('updateStatusBar',
74+
_translate("newchandialog",
75+
"Successfully created / joined chan %1").
76+
arg(unicode(self.chanPassPhrase.text())))) # pylint: disable=undefined-variable
7377
self.parent.ui.tabWidget.setCurrentIndex(
7478
self.parent.ui.tabWidget.indexOf(self.parent.ui.chans)
7579
)
7680
self.done(QtGui.QDialog.Accepted)
7781
else:
78-
UISignalQueue.put(('updateStatusBar', _translate("newchandialog", "Chan creation / joining failed")))
82+
UISignalQueue.put(('updateStatusBar',
83+
_translate("newchandialog",
84+
"Chan creation / joining failed")))
7985
self.done(QtGui.QDialog.Rejected)
8086

8187
def reject(self):
8288
"""Cancel joining the chan"""
8389
self.timer.stop()
8490
self.hide()
85-
UISignalQueue.put(('updateStatusBar', _translate("newchandialog", "Chan creation / joining cancelled")))
91+
UISignalQueue.put(('updateStatusBar',
92+
_translate("newchandialog",
93+
"Chan creation / joining cancelled")))
8694
self.done(QtGui.QDialog.Rejected)

0 commit comments

Comments
 (0)