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

Commit 34d8ba2

Browse files
committed
Cleaned up type hints.
1 parent 0e117be commit 34d8ba2

File tree

1 file changed

+43
-44
lines changed

1 file changed

+43
-44
lines changed

iota/transaction/base.py

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
from iota.codecs import TrytesDecodeError
1010
from iota.crypto import Curl, HASH_LENGTH
1111
from iota.json import JsonSerializable
12-
from iota.transaction.types import BundleHash, Fragment, TransactionHash, \
13-
TransactionTrytes, Nonce
14-
from iota.types import Address, Hash, Tag, TryteString, TrytesCompatible, \
12+
from iota.transaction.types import BundleHash, Fragment, Nonce, TransactionHash, \
13+
TransactionTrytes
14+
from iota.types import Address, Tag, TryteString, TrytesCompatible, \
1515
int_from_trits, trits_from_int
1616

1717
__all__ = [
@@ -69,68 +69,67 @@ def from_tryte_string(cls, trytes, hash_=None):
6969

7070
def __init__(
7171
self,
72-
hash_,
73-
signature_message_fragment,
74-
address,
75-
value,
76-
timestamp,
77-
current_index,
78-
last_index,
79-
bundle_hash,
80-
trunk_transaction_hash,
81-
branch_transaction_hash,
82-
tag,
83-
attachment_timestamp,
84-
attachment_timestamp_lower_bound,
85-
attachment_timestamp_upper_bound,
86-
nonce,
87-
legacy_tag = None
72+
hash_, # type: Optional[TransactionHash]
73+
signature_message_fragment, # type: Optional[Fragment]
74+
address, # type: Address
75+
value, # type: int
76+
timestamp, # type: int
77+
current_index, # type: Optional[int]
78+
last_index, # type: Optional[int]
79+
bundle_hash, # type: Optional[BundleHash]
80+
trunk_transaction_hash, # type: Optional[TransactionHash]
81+
branch_transaction_hash, # type: Optional[TransactionHash]
82+
tag, # type: Optional[Tag]
83+
attachment_timestamp, # type: Optional[int]
84+
attachment_timestamp_lower_bound, # type: Optional[int]
85+
attachment_timestamp_upper_bound, # type: Optional[int]
86+
nonce, # type: Optional[Nonce]
87+
legacy_tag = None # type: Optional[Tag]
8888
):
89-
# type: (Optional[TransactionHash], Optional[Fragment], Address, int, int, Optional[int], Optional[int], Optional[BundleHash], Optional[TransactionHash], Optional[TransactionHash], Optional[Tag], Optional[int], Optional[int], Optional[int] Optional[Hash]) -> None
90-
self.hash = hash_ # type: Optional[TransactionHash]
89+
self.hash = hash_
9190
"""
9291
Transaction ID, generated by taking a hash of the transaction
9392
trits.
9493
"""
9594

96-
self.bundle_hash = bundle_hash # type: Optional[BundleHash]
95+
self.bundle_hash = bundle_hash
9796
"""
9897
Bundle hash, generated by taking a hash of metadata from all the
9998
transactions in the bundle.
10099
"""
101100

102-
self.address = address # type: Address
101+
self.address = address
103102
"""
104103
The address associated with this transaction.
105104
If ``value`` is != 0, the associated address' balance is adjusted
106105
as a result of this transaction.
107106
"""
108107

109-
self.value = value # type: int
108+
self.value = value
110109
"""
111110
Amount to adjust the balance of ``address``.
112111
Can be negative (i.e., for spending inputs).
113112
"""
114113

115-
self._legacy_tag = legacy_tag # type: Optional[Tag]
114+
self._legacy_tag = legacy_tag
116115
"""
117116
Optional classification legacy_tag applied to this transaction.
118117
"""
119118

120-
self.nonce = nonce # type: Optional[Nonce]
119+
self.nonce = nonce
121120
"""
122121
Unique value used to increase security of the transaction hash.
123122
"""
124123

125-
self.timestamp = timestamp # type: int
124+
self.timestamp = timestamp
126125
"""
127126
Timestamp used to increase the security of the transaction hash.
128127
129128
IMPORTANT: This value is easy to forge!
130129
Do not rely on it when resolving conflicts!
131130
"""
132131

133-
self.current_index = current_index # type: Optional[int]
132+
self.current_index = current_index
134133
"""
135134
The position of the transaction inside the bundle.
136135
@@ -139,12 +138,12 @@ def __init__(
139138
last.
140139
"""
141140

142-
self.last_index = last_index # type: Optional[int]
141+
self.last_index = last_index
143142
"""
144143
The position of the final transaction inside the bundle.
145144
"""
146145

147-
self.trunk_transaction_hash = trunk_transaction_hash # type: Optional[TransactionHash]
146+
self.trunk_transaction_hash = trunk_transaction_hash
148147
"""
149148
In order to add a transaction to the Tangle, you must perform PoW
150149
to "approve" two existing transactions, called the "trunk" and
@@ -154,27 +153,27 @@ def __init__(
154153
a bundle.
155154
"""
156155

157-
self.branch_transaction_hash = branch_transaction_hash # type: Optional[TransactionHash]
156+
self.branch_transaction_hash = branch_transaction_hash
158157
"""
159158
In order to add a transaction to the Tangle, you must perform PoW
160159
to "approve" two existing transactions, called the "trunk" and
161160
"branch" transactions.
162161
163162
The branch transaction generally has no significance.
164163
"""
165-
166-
self.tag = tag # type: Optional[Tag]
164+
165+
self.tag = tag
167166
"""
168167
Optional classification tag applied to this transaction.
169168
"""
170-
171-
self.attachment_timestamp = attachment_timestamp # type: int
172-
173-
self.attachment_timestamp_lower_bound = attachment_timestamp_lower_bound # type: int
174-
175-
self.attachment_timestamp_upper_bound = attachment_timestamp_upper_bound # type: int
176169

177-
self.signature_message_fragment = signature_message_fragment # type: Optional[Fragment]
170+
self.attachment_timestamp = attachment_timestamp
171+
172+
self.attachment_timestamp_lower_bound = attachment_timestamp_lower_bound
173+
174+
self.attachment_timestamp_upper_bound = attachment_timestamp_upper_bound
175+
176+
self.signature_message_fragment = signature_message_fragment
178177
"""
179178
"Signature/Message Fragment" (note the slash):
180179
@@ -246,7 +245,7 @@ def last_index_as_trytes(self):
246245
"""
247246
# Note that we are padding to 27 _trits_.
248247
return TryteString.from_trits(trits_from_int(self.last_index, pad=27))
249-
248+
250249
@property
251250
def attachment_timestamp_as_trytes(self):
252251
# type: () -> TryteString
@@ -256,7 +255,7 @@ def attachment_timestamp_as_trytes(self):
256255
"""
257256
#Note that we are padding to 27 _trits_.
258257
return TryteString.from_trits(trits_from_int(self.attachment_timestamp, pad=27))
259-
258+
260259
@property
261260
def attachment_timestamp_lower_bound_as_trytes(self):
262261
# type: () -> TryteString
@@ -266,7 +265,7 @@ def attachment_timestamp_lower_bound_as_trytes(self):
266265
"""
267266
#Note that we are padding to 27 _trits_.
268267
return TryteString.from_trits(trits_from_int(self.attachment_timestamp_lower_bound, pad=27))
269-
268+
270269
@property
271270
def attachment_timestamp_upper_bound_as_trytes(self):
272271
# type: () -> TryteString
@@ -341,7 +340,7 @@ def get_signature_validation_trytes(self):
341340
+ self.current_index_as_trytes
342341
+ self.last_index_as_trytes
343342
)
344-
343+
345344
@property
346345
def legacy_tag(self):
347346
# type: () -> Tag

0 commit comments

Comments
 (0)