Skip to content

Commit 0956e46

Browse files
committed
test: use zero-argument super() shortcut (Python 3.0+)
as defined in PEP 3135: "The new syntax: super() is equivalent to: super(__class__, <firstarg>) where __class__ is the class that the method was defined in, and <firstarg> is the first parameter of the method (normally self for instance methods, and cls for class methods)."
1 parent 5f19155 commit 0956e46

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

test/functional/test_framework/messages.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,16 +603,16 @@ class CBlock(CBlockHeader):
603603
__slots__ = ("vtx",)
604604

605605
def __init__(self, header=None):
606-
super(CBlock, self).__init__(header)
606+
super().__init__(header)
607607
self.vtx = []
608608

609609
def deserialize(self, f):
610-
super(CBlock, self).deserialize(f)
610+
super().deserialize(f)
611611
self.vtx = deser_vector(f, CTransaction)
612612

613613
def serialize(self, with_witness=True):
614614
r = b""
615-
r += super(CBlock, self).serialize()
615+
r += super().serialize()
616616
if with_witness:
617617
r += ser_vector(self.vtx, "serialize_with_witness")
618618
else:
@@ -752,7 +752,7 @@ def __repr__(self):
752752
class P2PHeaderAndShortWitnessIDs(P2PHeaderAndShortIDs):
753753
__slots__ = ()
754754
def serialize(self):
755-
return super(P2PHeaderAndShortWitnessIDs, self).serialize(with_witness=True)
755+
return super().serialize(with_witness=True)
756756

757757
# Calculate the BIP 152-compact blocks shortid for a given transaction hash
758758
def calculate_shortid(k0, k1, tx_hash):

test/functional/test_framework/script.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def __new__(cls, n):
9797
return _opcode_instances[n]
9898
except IndexError:
9999
assert len(_opcode_instances) == n
100-
_opcode_instances.append(super(CScriptOp, cls).__new__(cls, n))
100+
_opcode_instances.append(super().__new__(cls, n))
101101
return _opcode_instances[n]
102102

103103
# Populate opcode instance table
@@ -372,7 +372,7 @@ class CScriptTruncatedPushDataError(CScriptInvalidError):
372372
"""Invalid pushdata due to truncation"""
373373
def __init__(self, msg, data):
374374
self.data = data
375-
super(CScriptTruncatedPushDataError, self).__init__(msg)
375+
super().__init__(msg)
376376

377377

378378
# This is used, eg, for blockchain heights in coinbase scripts (bip34)
@@ -458,14 +458,14 @@ def join(self, iterable):
458458

459459
def __new__(cls, value=b''):
460460
if isinstance(value, bytes) or isinstance(value, bytearray):
461-
return super(CScript, cls).__new__(cls, value)
461+
return super().__new__(cls, value)
462462
else:
463463
def coerce_iterable(iterable):
464464
for instance in iterable:
465465
yield cls.__coerce_instance(instance)
466466
# Annoyingly on both python2 and python3 bytes.join() always
467467
# returns a bytes instance even when subclassed.
468-
return super(CScript, cls).__new__(cls, b''.join(coerce_iterable(value)))
468+
return super().__new__(cls, b''.join(coerce_iterable(value)))
469469

470470
def raw_iter(self):
471471
"""Raw iteration

test/functional/wallet_txn_clone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def add_options(self, parser):
2929

3030
def setup_network(self):
3131
# Start with split network:
32-
super(TxnMallTest, self).setup_network()
32+
super().setup_network()
3333
disconnect_nodes(self.nodes[1], 2)
3434
disconnect_nodes(self.nodes[2], 1)
3535

0 commit comments

Comments
 (0)