Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 8b84120

Browse files
committed
PEP8
1 parent 0d1fe01 commit 8b84120

File tree

4 files changed

+25
-27
lines changed

4 files changed

+25
-27
lines changed

ethereum/chain.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from ethereum.exceptions import VerificationFailed, InvalidTransaction
1313
from ethereum.slogging import get_logger
1414
from ethereum.config import Env
15-
import sys
1615
log = get_logger('eth.chain')
1716

1817

ethereum/processblock.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import sys
22
import rlp
33
from rlp.sedes import CountableList, binary
4-
from rlp.utils import decode_hex, encode_hex, ascii_chr, str_to_bytes
4+
from rlp.utils import decode_hex, encode_hex, ascii_chr
55
from ethereum import opcodes
66
from ethereum import utils
77
from ethereum import specials
88
from ethereum import bloom
99
from ethereum import vm as vm
1010
from ethereum.exceptions import InvalidNonce, InsufficientStartGas, UnsignedTransaction, \
1111
BlockGasLimitReached, InsufficientBalance
12-
from ethereum.utils import safe_ord, normalize_address, mk_contract_address
12+
from ethereum.utils import safe_ord, mk_contract_address
1313
from ethereum import transactions
1414
import ethereum.config as config
1515

@@ -149,7 +149,7 @@ def rp(what, actual, target):
149149
log_tx.debug('TX NEW', tx_dict=tx.log_dict())
150150
# start transacting #################
151151
block.increment_nonce(tx.sender)
152-
152+
153153
# buy startgas
154154
assert block.get_balance(tx.sender) >= tx.startgas * tx.gasprice
155155
block.delta_balance(tx.sender, -tx.startgas * tx.gasprice)

ethereum/tests/test_contracts.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,13 @@ def test_hedge():
341341
c2 = s.abi_contract(hedge_code, sender=tester.k0)
342342
# Have the first party register, sending 10^16 wei and
343343
# asking for a hedge using currency code 500
344-
o1 = c2.main(c.address, 500, value=10**16)
344+
o1 = c2.main(c.address, 500, value=10 ** 16)
345345
assert o1 == 1
346346
# Have the second party register. It should receive the
347347
# amount of units of the second currency that it is
348348
# entitled to. Note that from the previous test this is
349349
# set to 726
350-
o2 = c2.main(0, 0, value=10**16, sender=tester.k2)
350+
o2 = c2.main(0, 0, value=10 ** 16, sender=tester.k2)
351351
assert o2 == 7260000000000000000
352352
snapshot = s.snapshot()
353353
# Set the price of the asset down to 300 wei
@@ -466,12 +466,12 @@ def recurse():
466466

467467
def test_reverter():
468468
s = tester.state()
469-
c = s.abi_contract(reverter_code, endowment=10**15)
469+
c = s.abi_contract(reverter_code, endowment=10 ** 15)
470470
c.entry()
471471
assert s.block.get_storage_data(c.address, 8080) == 4040
472-
assert s.block.get_balance(decode_hex('0'*39+'7')) == 9
472+
assert s.block.get_balance(decode_hex('0' * 39 + '7')) == 9
473473
assert s.block.get_storage_data(c.address, 8081) == 0
474-
assert s.block.get_balance(decode_hex('0'*39+'8')) == 0
474+
assert s.block.get_balance(decode_hex('0' * 39 + '8')) == 0
475475

476476
# Test stateless contracts
477477

@@ -932,7 +932,6 @@ def kall():
932932
"""
933933

934934

935-
936935
def test_saveload():
937936
s = tester.state()
938937
c = s.abi_contract(saveload_code)
@@ -1077,8 +1076,8 @@ def test_indirect_sort():
10771076
s = tester.state()
10781077
open(filename9, 'w').write(sort_code)
10791078
c = s.abi_contract(sort_tester_code)
1080-
assert c.test([80, 234, 112, 112, 29]) == [29, 80, 112, 112, 234]
10811079
os.remove(filename9)
1080+
assert c.test([80, 234, 112, 112, 29]) == [29, 80, 112, 112, 234]
10821081

10831082
multiarg_code = """
10841083
def kall(a:arr, b, c:arr, d:str, e):
@@ -1232,12 +1231,12 @@ def test_sha256():
12321231
s = tester.state()
12331232
c = s.abi_contract(sha256_code)
12341233
assert c.main() == [
1235-
0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - 2**256,
1236-
0xd9147961436944f43cd99d28b2bbddbf452ef872b30c8279e255e7daafc7f946 - 2**256,
1237-
0xcd6357efdd966de8c0cb2f876cc89ec74ce35f0968e11743987084bd42fb8944 - 2**256,
1238-
0xcd6357efdd966de8c0cb2f876cc89ec74ce35f0968e11743987084bd42fb8944 - 2**256,
1239-
0xb393978842a0fa3d3e1470196f098f473f9678e72463cb65ec4ab5581856c2e4 - 2**256,
1240-
0xb393978842a0fa3d3e1470196f098f473f9678e72463cb65ec4ab5581856c2e4 - 2**256
1234+
0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - 2 ** 256,
1235+
0xd9147961436944f43cd99d28b2bbddbf452ef872b30c8279e255e7daafc7f946 - 2 ** 256,
1236+
0xcd6357efdd966de8c0cb2f876cc89ec74ce35f0968e11743987084bd42fb8944 - 2 ** 256,
1237+
0xcd6357efdd966de8c0cb2f876cc89ec74ce35f0968e11743987084bd42fb8944 - 2 ** 256,
1238+
0xb393978842a0fa3d3e1470196f098f473f9678e72463cb65ec4ab5581856c2e4 - 2 ** 256,
1239+
0xb393978842a0fa3d3e1470196f098f473f9678e72463cb65ec4ab5581856c2e4 - 2 ** 256
12411240
]
12421241

12431242
sha3_code = """
@@ -1250,12 +1249,12 @@ def test_sha3():
12501249
s = tester.state()
12511250
c = s.abi_contract(sha3_code)
12521251
assert c.main() == [
1253-
0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 - 2**256,
1254-
0xc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b - 2**256,
1252+
0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 - 2 ** 256,
1253+
0xc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b - 2 ** 256,
12551254
0x41791102999c339c844880b23950704cc43aa840f3739e365323cda4dfa89e7a,
12561255
0x41791102999c339c844880b23950704cc43aa840f3739e365323cda4dfa89e7a,
1257-
0xdfded4ed5ac76ba7379cfe7b3b0f53e768dca8d45a34854e649cfc3c18cbd9cd - 2**256,
1258-
0xdfded4ed5ac76ba7379cfe7b3b0f53e768dca8d45a34854e649cfc3c18cbd9cd - 2**256
1256+
0xdfded4ed5ac76ba7379cfe7b3b0f53e768dca8d45a34854e649cfc3c18cbd9cd - 2 ** 256,
1257+
0xdfded4ed5ac76ba7379cfe7b3b0f53e768dca8d45a34854e649cfc3c18cbd9cd - 2 ** 256
12591258
]
12601259

12611260
types_in_functions_code = """
@@ -1316,21 +1315,22 @@ def get_prevhashes(k):
13161315
return(o:arr)
13171316
"""
13181317

1318+
13191319
@pytest.mark.timeout(100)
13201320
def test_prevhashes():
13211321
s = tester.state()
13221322
c = s.abi_contract(prevhashes_code)
13231323
s.mine(7)
13241324
# Hashes of last 14 blocks including existing one
1325-
o1 = [x % 2**256 for x in c.get_prevhashes(14)]
1325+
o1 = [x % 2 ** 256 for x in c.get_prevhashes(14)]
13261326
# hash of self = 0, hash of blocks back to genesis block as is, hash of
13271327
# blocks before genesis block = 0
13281328
t1 = [0] + [utils.big_endian_to_int(b.hash) for b in s.blocks[-2::-1]] \
13291329
+ [0] * 6
13301330
assert o1 == t1
13311331
s.mine(256)
13321332
# Test 256 limit: only 1 <= g <= 256 generation ancestors get hashes shown
1333-
o2 = [x % 2**256 for x in c.get_prevhashes(270)]
1333+
o2 = [x % 2 ** 256 for x in c.get_prevhashes(270)]
13341334
t2 = [0] + [utils.big_endian_to_int(b.hash) for b in s.blocks[-2:-258:-1]] \
13351335
+ [0] * 13
13361336
assert o2 == t2

ethereum/transactions.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf8 -*-
22
import rlp
3-
from bitcoin import encode_pubkey, N, P, encode_privkey
3+
from bitcoin import encode_pubkey, N, encode_privkey
44
from rlp.sedes import big_endian_int, binary
55
from rlp.utils import encode_hex, str_to_bytes, ascii_chr
66
from secp256k1 import PublicKey, ALL_FLAGS, PrivateKey
@@ -171,10 +171,9 @@ def intrinsic_gas_used(self):
171171
@property
172172
def creates(self):
173173
"returns the address of a contract created by this tx"
174-
if self.to in (b'', '\0'*20):
174+
if self.to in (b'', '\0' * 20):
175175
return mk_contract_address(self.sender, self.nonce)
176176

177-
178177
def __eq__(self, other):
179178
return isinstance(other, self.__class__) and self.hash == other.hash
180179

@@ -194,7 +193,7 @@ def __structlog__(self):
194193
# The >= operator is replaced by > because the integer division N/2 always produces the value
195194
# which is by 0.5 less than the real N/2
196195
def check_low_s(self):
197-
if self.s > N/2 or self.s == 0:
196+
if self.s > N / 2 or self.s == 0:
198197
raise InvalidTransaction("Invalid signature S value!")
199198

200199

0 commit comments

Comments
 (0)