Skip to content

Commit 4b3a1db

Browse files
authored
Merge pull request #45 from mikeshultz/hexbytes
refactor: use isinstance() instead of type() == x, to allow support for subclasses
2 parents 4eb50c1 + 2b6557e commit 4b3a1db

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

ledgereth/messages.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def sign_message(
4040
message = message.encode("utf-8")
4141

4242
# Silence mypy due to type cohersion above
43-
assert type(message) == bytes
43+
assert isinstance(message, bytes)
4444

4545
encoded = struct.pack(">I", len(message))
4646
encoded += message
@@ -125,8 +125,8 @@ def sign_typed_data_draft(
125125
message_hash = message_hash.encode("utf-8")
126126

127127
# Silence mypy due to type cohersion above
128-
assert type(domain_hash) == bytes
129-
assert type(message_hash) == bytes
128+
assert isinstance(domain_hash, bytes)
129+
assert isinstance(message_hash, bytes)
130130

131131
encoded = domain_hash + message_hash
132132

ledgereth/transactions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ def create_transaction(
203203
data = decode_hex(data)
204204

205205
# be cool mypy
206-
assert type(destination) == bytes
207-
assert type(data) == bytes
206+
assert isinstance(destination, bytes)
207+
assert isinstance(data, bytes)
208208

209209
# EIP-1559 transactions should never have gas_price
210210
if gas_price and (max_priority_fee_per_gas or max_fee_per_gas):

ledgereth/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def decode_web3_access_list(
138138
if "storageKeys" not in item:
139139
raise ValueError(f"Access list item at position {idx} missing storageKeys")
140140

141-
assert type(item["address"]) == str
141+
assert isinstance(item["address"], str)
142142

143143
work_list.append(
144144
(

0 commit comments

Comments
 (0)