Skip to content

Commit e1a142d

Browse files
committed
Code quality
1 parent 9d998a9 commit e1a142d

10 files changed

Lines changed: 51 additions & 48 deletions

src/api.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -112,40 +112,40 @@ class ErrorCodes(type):
112112
0: 'Invalid command parameters number',
113113
1: 'The specified passphrase is blank.',
114114
2: 'The address version number currently must be 3, 4, or 0'
115-
' (which means auto-select).',
115+
' (which means auto-select).',
116116
3: 'The stream number must be 1 (or 0 which means'
117-
' auto-select). Others aren\'t supported.',
117+
' auto-select). Others aren\'t supported.',
118118
4: 'Why would you ask me to generate 0 addresses for you?',
119119
5: 'You have (accidentally?) specified too many addresses to'
120-
' make. Maximum 999. This check only exists to prevent'
121-
' mischief; if you really want to create more addresses than'
122-
' this, contact the Bitmessage developers and we can modify'
123-
' the check or you can do it yourself by searching the source'
124-
' code for this message.',
120+
' make. Maximum 999. This check only exists to prevent'
121+
' mischief; if you really want to create more addresses than'
122+
' this, contact the Bitmessage developers and we can modify'
123+
' the check or you can do it yourself by searching the source'
124+
' code for this message.',
125125
6: 'The encoding type must be 2 or 3.',
126126
7: 'Could not decode address',
127127
8: 'Checksum failed for address',
128128
9: 'Invalid characters in address',
129129
10: 'Address version number too high (or zero)',
130130
11: 'The address version number currently must be 2, 3 or 4.'
131-
' Others aren\'t supported. Check the address.',
131+
' Others aren\'t supported. Check the address.',
132132
12: 'The stream number must be 1. Others aren\'t supported.'
133-
' Check the address.',
133+
' Check the address.',
134134
13: 'Could not find this address in your keys.dat file.',
135135
14: 'Your fromAddress is disabled. Cannot send.',
136136
15: 'Invalid ackData object size.',
137137
16: 'You are already subscribed to that address.',
138138
17: 'Label is not valid UTF-8 data.',
139139
18: 'Chan name does not match address.',
140140
19: 'The length of hash should be 32 bytes (encoded in hex'
141-
' thus 64 characters).',
141+
' thus 64 characters).',
142142
20: 'Invalid method:',
143143
21: 'Unexpected API Failure',
144144
22: 'Decode error',
145145
23: 'Bool expected in eighteenByteRipe',
146146
24: 'Chan address is already present.',
147147
25: 'Specified address is not a chan address.'
148-
' Use deleteAddress API call instead.',
148+
' Use deleteAddress API call instead.',
149149
26: 'Malformed varint in address: ',
150150
27: 'Message is too long.',
151151
28: 'Invalid parameter'
@@ -466,6 +466,7 @@ def APIAuthenticateClient(self):
466466
class BMRPCDispatcher(object):
467467
"""This class is used to dispatch API commands"""
468468

469+
# pylint: disable=inconsistent-return-statements
469470
@staticmethod
470471
def _decode(text, decode_type):
471472
try:
@@ -722,8 +723,8 @@ def HandleDeleteWhitelistEntry(self, address):
722723

723724
@command('createRandomAddress')
724725
def HandleCreateRandomAddress(
725-
self, label, eighteenByteRipe=False, totalDifficulty=0,
726-
smallMessageDifficulty=0
726+
self, label, eighteenByteRipe=False, totalDifficulty=0,
727+
smallMessageDifficulty=0
727728
):
728729
"""
729730
Create one address using the random number generator.
@@ -763,9 +764,9 @@ def HandleCreateRandomAddress(
763764

764765
@command('createDeterministicAddresses')
765766
def HandleCreateDeterministicAddresses(
766-
self, passphrase, numberOfAddresses=1, addressVersionNumber=0,
767-
streamNumber=0, eighteenByteRipe=False, totalDifficulty=0,
768-
smallMessageDifficulty=0
767+
self, passphrase, numberOfAddresses=1, addressVersionNumber=0,
768+
streamNumber=0, eighteenByteRipe=False, totalDifficulty=0,
769+
smallMessageDifficulty=0
769770
):
770771
"""
771772
Create many addresses deterministically using the passphrase.
@@ -1190,8 +1191,8 @@ def HandleTrashSentMessage(self, msgid):
11901191

11911192
@command('sendMessage')
11921193
def HandleSendMessage(
1193-
self, toAddress, fromAddress, subject, message,
1194-
encodingType=2, TTL=4 * 24 * 60 * 60
1194+
self, toAddress, fromAddress, subject, message,
1195+
encodingType=2, TTL=4 * 24 * 60 * 60
11951196
):
11961197
"""
11971198
Send the message and return ackdata (hex encoded string).
@@ -1242,7 +1243,7 @@ def HandleSendMessage(
12421243

12431244
@command('sendBroadcast')
12441245
def HandleSendBroadcast(
1245-
self, fromAddress, subject, message, encodingType=2,
1246+
self, fromAddress, subject, message, encodingType=2,
12461247
TTL=4 * 24 * 60 * 60):
12471248
"""Send the broadcast message. Similiar to *sendMessage*."""
12481249

@@ -1361,9 +1362,9 @@ def ListSubscriptions(self):
13611362

13621363
@command('disseminatePreEncryptedMsg', 'disseminatePreparedObject')
13631364
def HandleDisseminatePreparedObject(
1364-
self, encryptedPayload,
1365-
nonceTrialsPerByte=networkDefaultProofOfWorkNonceTrialsPerByte,
1366-
payloadLengthExtraBytes=networkDefaultPayloadLengthExtraBytes
1365+
self, encryptedPayload,
1366+
nonceTrialsPerByte=networkDefaultProofOfWorkNonceTrialsPerByte,
1367+
payloadLengthExtraBytes=networkDefaultPayloadLengthExtraBytes
13671368
):
13681369
"""
13691370
Handle a request to disseminate an encrypted message.

src/bitmessagemain.py

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

1313
# flake8: noqa:402
14+
# pylint: disable=superfluous-parens
1415
import os
1516
import sys
1617

src/bmconfigparser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def save(self):
128128
shutil.copyfile(fileName, fileNameBak)
129129
# The backup succeeded.
130130
fileNameExisted = True
131-
except(IOError, Exception):
131+
except (IOError, Exception):
132132
# The backup failed. This can happen if the file
133133
# didn't exist before.
134134
fileNameExisted = False

src/class_addressGenerator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ def stopThread(self):
3232

3333
super(addressGenerator, self).stopThread()
3434

35+
# pylint: disable=too-many-arguments,too-many-positional-arguments
3536
def save_address(
36-
# pylint: disable=too-many-arguments,too-many-positional-arguments
37-
self, version, stream, ripe, label, signing_key, encryption_key,
38-
nonceTrialsPerByte, payloadLengthExtraBytes
37+
self, version, stream, ripe, label, signing_key, encryption_key,
38+
nonceTrialsPerByte, payloadLengthExtraBytes
3939
):
4040
"""Write essential address config values and reload cryptors"""
4141
address = encodeAddress(version, stream, ripe)
@@ -183,8 +183,8 @@ def run(self):
183183
ripe = highlevelcrypto.to_ripe(
184184
pubSigningKey, potentialPubEncryptionKey)
185185
if (
186-
ripe[:numberOfNullBytesDemandedOnFrontOfRipeHash]
187-
== b'\x00' * numberOfNullBytesDemandedOnFrontOfRipeHash
186+
ripe[:numberOfNullBytesDemandedOnFrontOfRipeHash]
187+
== b'\x00' * numberOfNullBytesDemandedOnFrontOfRipeHash
188188
):
189189
break
190190
self.logger.info(

src/class_singleWorker.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ def _getKeysForAddress(self, address):
221221

222222
@classmethod
223223
def _doPOWDefaults(
224-
cls, payload, TTL,
225-
nonceTrialsPerByte=None, payloadLengthExtraBytes=None,
226-
log_prefix='', log_time=False
224+
cls, payload, TTL,
225+
nonceTrialsPerByte=None, payloadLengthExtraBytes=None,
226+
log_prefix='', log_time=False
227227
):
228228
if not nonceTrialsPerByte:
229229
nonceTrialsPerByte = \
@@ -755,9 +755,9 @@ def sendMsg(self):
755755
# in our keys.dat file.
756756
elif config.has_section(toaddress):
757757
if not sqlExecute(
758-
'''UPDATE sent SET status='doingmsgpow' '''
759-
''' WHERE toaddress=? AND status='msgqueued' AND folder='sent' ''',
760-
toaddress
758+
'''UPDATE sent SET status='doingmsgpow' '''
759+
''' WHERE toaddress=? AND status='msgqueued' AND folder='sent' ''',
760+
toaddress
761761
):
762762
continue
763763
status = 'doingmsgpow'

src/helper_search.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99

1010
def search_sql(
11-
xAddress='toaddress', account=None, folder='inbox', where=None,
12-
what=None, unreadOnly=False
11+
xAddress='toaddress', account=None, folder='inbox', where=None,
12+
what=None, unreadOnly=False
1313
):
1414
"""
1515
Search for messages from given account and folder having search term
@@ -88,24 +88,24 @@ def check_match(
8888
return True
8989

9090
if where in (
91-
_translate("MainWindow", "To"), _translate("MainWindow", "All")
91+
_translate("MainWindow", "To"), _translate("MainWindow", "All")
9292
):
9393
if what.lower() not in toAddress.lower():
9494
return False
9595
elif where in (
96-
_translate("MainWindow", "From"), _translate("MainWindow", "All")
96+
_translate("MainWindow", "From"), _translate("MainWindow", "All")
9797
):
9898
if what.lower() not in fromAddress.lower():
9999
return False
100100
elif where in (
101-
_translate("MainWindow", "Subject"),
102-
_translate("MainWindow", "All")
101+
_translate("MainWindow", "Subject"),
102+
_translate("MainWindow", "All")
103103
):
104104
if what.lower() not in subject.lower():
105105
return False
106106
elif where in (
107-
_translate("MainWindow", "Message"),
108-
_translate("MainWindow", "All")
107+
_translate("MainWindow", "Message"),
108+
_translate("MainWindow", "All")
109109
):
110110
if what.lower() not in message.lower():
111111
return False

src/main-android-live.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This module is for thread start."""
2+
# pylint: disable=superfluous-parens
23
import state
34
import sys
45
from bitmessagemain import main

src/network/asyncore_pollchoose.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,12 +560,12 @@ def del_channel(self):
560560
try:
561561
kqueue_poller.pollster.control([select.kevent(
562562
fd, select.KQ_FILTER_READ, select.KQ_EV_DELETE)], 0)
563-
except(AttributeError, KeyError, TypeError, IOError, OSError):
563+
except (AttributeError, KeyError, TypeError, IOError, OSError):
564564
pass
565565
try:
566566
kqueue_poller.pollster.control([select.kevent(
567567
fd, select.KQ_FILTER_WRITE, select.KQ_EV_DELETE)], 0)
568-
except(AttributeError, KeyError, TypeError, IOError, OSError):
568+
except (AttributeError, KeyError, TypeError, IOError, OSError):
569569
pass
570570
try:
571571
epoll_poller.pollster.unregister(fd)

src/qidenticon.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ def decode(self, code, twoColor):
262262
else:
263263
secondColor = foreColor
264264

265-
return (middleType, middleInvert, 0),\
266-
(cornerType, cornerInvert, cornerTurn),\
267-
(sideType, sideInvert, sideTurn),\
265+
return (middleType, middleInvert, 0), \
266+
(cornerType, cornerInvert, cornerTurn), \
267+
(sideType, sideInvert, sideTurn), \
268268
foreColor, secondColor, swap_cross
269269

270270

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ basepython = python3
6666
deps =
6767
pycodestyle
6868
commands =
69-
- pycodestyle --config=tox.ini pybitmessage
69+
pycodestyle --config=tox.ini pybitmessage
7070

7171
[testenv:bandit-py27]
7272
skip_install = true

0 commit comments

Comments
 (0)