Skip to content

Commit 57cb69a

Browse files
committed
Code quality
1 parent f6f5273 commit 57cb69a

9 files changed

Lines changed: 40 additions & 33 deletions

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ 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:

src/class_addressGenerator.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ def run(self):
221221
))
222222

223223
elif command in (
224-
'createDeterministicAddresses', 'createChan',
225-
'getDeterministicAddress', 'joinChan'
224+
'createDeterministicAddresses', 'createChan',
225+
'getDeterministicAddress', 'joinChan'
226226
):
227227
if not deterministicPassphrase:
228228
self.logger.warning(
@@ -268,8 +268,8 @@ def run(self):
268268
ripe = highlevelcrypto.to_ripe(
269269
potentialPubSigningKey, potentialPubEncryptionKey)
270270
if (
271-
ripe[:numberOfNullBytesDemandedOnFrontOfRipeHash]
272-
== b'\x00' * numberOfNullBytesDemandedOnFrontOfRipeHash
271+
ripe[:numberOfNullBytesDemandedOnFrontOfRipeHash]
272+
== b'\x00' * numberOfNullBytesDemandedOnFrontOfRipeHash
273273
):
274274
break
275275

@@ -303,9 +303,9 @@ def run(self):
303303
saveAddressToDisk = False
304304

305305
if saveAddressToDisk and live and self.save_address(
306-
addressVersionNumber, streamNumber, ripe, label,
307-
potentialPrivSigningKey, potentialPrivEncryptionKey,
308-
nonceTrialsPerByte, payloadLengthExtraBytes
306+
addressVersionNumber, streamNumber, ripe, label,
307+
potentialPrivSigningKey, potentialPrivEncryptionKey,
308+
nonceTrialsPerByte, payloadLengthExtraBytes
309309
):
310310
if command in ('createChan', 'joinChan'):
311311
config.set(address, 'chan', 'true')
@@ -326,7 +326,7 @@ def run(self):
326326

327327
# Done generating addresses.
328328
if command in (
329-
'createDeterministicAddresses', 'createChan', 'joinChan'
329+
'createDeterministicAddresses', 'createChan', 'joinChan'
330330
):
331331
queues.apiAddressGeneratorReturnQueue.put(
332332
listOfNewAddressesToSendOutThroughTheAPI)

src/class_objectProcessor.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55
# pylint: disable=too-many-locals,too-many-return-statements
66
# pylint: disable=too-many-branches,too-many-statements
7+
# pylint: disable=too-many-lines
78
import hashlib
89
import logging
910
import os
@@ -718,10 +719,10 @@ def processmsg(self, data):
718719
# Don't send ACK if invalid, blacklisted senders, invisible
719720
# messages, disabled or chan
720721
if (
721-
self.ackDataHasAValidHeader(ackData) and not blockMessage
722-
and messageEncodingType != 0
723-
and not config.safeGetBoolean(toAddress, 'dontsendack')
724-
and not config.safeGetBoolean(toAddress, 'chan')
722+
self.ackDataHasAValidHeader(ackData) and not blockMessage
723+
and messageEncodingType != 0
724+
and not config.safeGetBoolean(toAddress, 'dontsendack')
725+
and not config.safeGetBoolean(toAddress, 'chan')
725726
):
726727
ackPayload = ackData[24:]
727728
objectType, toStreamNumber, expiresTime = \

src/class_singleWorker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,9 +772,9 @@ def sendMsg(self):
772772
if queryreturn != []:
773773
# set the status of this msg to doingmsgpow
774774
if not sqlExecute(
775-
'''UPDATE sent SET status='doingmsgpow' '''
776-
''' WHERE toaddress=? AND status='msgqueued' AND folder='sent' ''',
777-
toaddress
775+
'''UPDATE sent SET status='doingmsgpow' '''
776+
''' WHERE toaddress=? AND status='msgqueued' AND folder='sent' ''',
777+
toaddress
778778
):
779779
continue
780780
status = 'doingmsgpow'

src/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"""Mock kivy app with mock threads."""
55

66
import os
7-
from kivy.config import Config
8-
from mockbm import multiqueue
9-
import state
7+
from kivy.config import Config # pylint: disable=import-error
108

11-
from mockbm.class_addressGenerator import FakeAddressGenerator # noqa:E402
12-
from bitmessagekivy.mpybit import NavigateApp # noqa:E402
13-
from mockbm import network # noqa:E402
9+
import pybitmessage.state as state
10+
from pybitmessage.bitmessagekivy.mpybit import NavigateApp # noqa:E402
11+
from pybitmessage.mockbm import multiqueue
12+
from pybitmessage.mockbm.class_addressGenerator import FakeAddressGenerator # noqa:E402
13+
from pybitmessage.mockbm import network # noqa:E402
1414

1515
stats = network.stats
1616
objectracker = network.objectracker

src/pathmagic.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"""
2+
Hack to work around relative imports
3+
"""
14
import os
25
import sys
36

src/proofofwork.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ def buildCPoW():
279279

280280
subprocess.check_call(make_cmd) # nosec B603
281281
if os.path.exists(
282-
os.path.join(paths.codePath(), 'bitmsghash', 'bitmsghash.so')
282+
os.path.join(paths.codePath(),
283+
'bitmsghash',
284+
'bitmsghash.so')
283285
):
284286
init()
285287
except (OSError, subprocess.CalledProcessError):
@@ -323,14 +325,15 @@ def getTarget(payloadLength, ttl, nonceTrialsPerByte, payloadLengthExtraBytes):
323325

324326

325327
def calculate(
326-
payload, ttl,
327-
nonceTrialsPerByte=networkDefaultProofOfWorkNonceTrialsPerByte,
328-
payloadLengthExtraBytes=networkDefaultPayloadLengthExtraBytes
328+
payload, ttl,
329+
nonceTrialsPerByte=networkDefaultProofOfWorkNonceTrialsPerByte,
330+
payloadLengthExtraBytes=networkDefaultPayloadLengthExtraBytes
329331
):
330332
"""Do the PoW for the payload and TTL with optional difficulty params"""
331333
return run(getTarget(
332-
len(payload), ttl, nonceTrialsPerByte, payloadLengthExtraBytes),
333-
hashlib.sha512(payload).digest())
334+
len(payload), ttl, nonceTrialsPerByte,
335+
payloadLengthExtraBytes),
336+
hashlib.sha512(payload).digest())
334337

335338

336339
def resetPoW():

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ ignore = E722,F841,W503
163163
disable =
164164
invalid-name,consider-using-f-string,fixme,raise-missing-from,
165165
super-with-arguments,unnecessary-pass,unknown-option-value,
166-
unspecified-encoding,useless-object-inheritance,useless-option-value
166+
unspecified-encoding,useless-object-inheritance,useless-option-value,
167+
bad-option-value
167168
ignore = bitmessagecurses,bitmessagekivy,bitmessageqt,messagetypes,mockbm,
168169
network,plugins,umsgpack,bitmessagecli.py
169170

0 commit comments

Comments
 (0)