Skip to content

Commit b09af7a

Browse files
committed
chore: fix ruff linting
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
1 parent 1f291da commit b09af7a

8 files changed

Lines changed: 187 additions & 264 deletions

File tree

examples/transaction/transaction_record.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,16 @@ def create_mock_record():
3333
tx_id = TransactionId.from_string("0.0.1234@1698765432.000000000")
3434

3535
receipt_proto = transaction_receipt_pb2.TransactionReceipt()
36-
receipt_proto.status = ResponseCode.SUCCESS.value
36+
receipt_proto.status = ResponseCode.SUCCESS.value
3737

38-
receipt = TransactionReceipt(
39-
receipt_proto=receipt_proto,
40-
transaction_id=tx_id
41-
)
38+
receipt = TransactionReceipt(receipt_proto=receipt_proto, transaction_id=tx_id)
4239

4340
ts = Timestamp(seconds=1698765432, nanos=123456789)
4441
sched = ScheduleId(0, 0, 9999)
4542

4643
record = TransactionRecord(
4744
transaction_id=tx_id,
48-
transaction_hash=b'\x01\x02\x03\x04' * 12,
45+
transaction_hash=b"\x01\x02\x03\x04" * 12,
4946
transaction_memo="Hello from example!",
5047
transaction_fee=50000,
5148
receipt=receipt,
@@ -63,26 +60,25 @@ def create_mock_record():
6360
AssessedCustomFee(
6461
amount=1000000,
6562
fee_collector_account_id=AccountId(shard=0, realm=0, num=98),
66-
effective_payer_account_ids=[AccountId(shard=0, realm=0, num=100)]
63+
effective_payer_account_ids=[AccountId(shard=0, realm=0, num=100)],
6764
)
6865
],
6966
automatic_token_associations=[
7067
TokenAssociation(
71-
token_id=TokenId(shard=0, realm=0, num=5678),
72-
account_id=AccountId(shard=0, realm=0, num=1234)
68+
token_id=TokenId(shard=0, realm=0, num=5678), account_id=AccountId(shard=0, realm=0, num=1234)
7369
)
7470
],
7571
parent_consensus_timestamp=ts,
76-
alias=b'\x12\x34\x56\x78\x9a\xbc',
77-
ethereum_hash=b'\xab' * 32,
72+
alias=b"\x12\x34\x56\x78\x9a\xbc",
73+
ethereum_hash=b"\xab" * 32,
7874
paid_staking_rewards=[
7975
(AccountId(shard=0, realm=0, num=456), 500000),
80-
(AccountId(shard=0, realm=0, num=789), 250000)
76+
(AccountId(shard=0, realm=0, num=789), 250000),
8177
],
82-
evm_address=b'\xef' * 20,
78+
evm_address=b"\xef" * 20,
8379
contract_create_result=ContractFunctionResult(
8480
contract_id=ContractId(shard=0, realm=0, contract=1000),
85-
contract_call_result=b"Contract created successfully!"
81+
contract_call_result=b"Contract created successfully!",
8682
),
8783
)
8884

@@ -91,6 +87,7 @@ def create_mock_record():
9187

9288
return record
9389

90+
9491
def _print_basic_fields(record):
9592
print("Basic:")
9693
print(f" Transaction ID: {record.transaction_id}")
@@ -112,7 +109,9 @@ def _print_basic_fields(record):
112109
def _print_transfer_fields(record):
113110
print(f" HBAR Transfers: {dict(record.transfers) if record.transfers else 'None'}")
114111
print(f" Token Transfers: {dict(record.token_transfers) if record.token_transfers else 'None'}")
115-
print(f" NFT Transfers: { {k: len(v) for k, v in record.nft_transfers.items()} if record.nft_transfers else 'None'}")
112+
print(
113+
f" NFT Transfers: { {k: len(v) for k, v in record.nft_transfers.items()} if record.nft_transfers else 'None' }"
114+
)
116115
print(f" Pending Airdrops: {len(record.new_pending_airdrops)}")
117116

118117

@@ -123,7 +122,9 @@ def _print_new_fields(record):
123122
print(f" Assessed Custom Fees ({len(record.assessed_custom_fees)}):")
124123
for fee in record.assessed_custom_fees:
125124
token = fee.token_id if fee.token_id else "HBAR"
126-
payers = ", ".join(str(p) for p in fee.effective_payer_account_ids) if fee.effective_payer_account_ids else "N/A"
125+
payers = (
126+
", ".join(str(p) for p in fee.effective_payer_account_ids) if fee.effective_payer_account_ids else "N/A"
127+
)
127128
print(f" - {fee.amount} {token} → Collector: {fee.fee_collector_account_id}, Payers: {payers}")
128129
print(f" Automatic Token Associations ({len(record.automatic_token_associations)}):")
129130
for assoc in record.automatic_token_associations:
@@ -136,7 +137,9 @@ def _print_new_fields(record):
136137
print(f" EVM Address (hex): {record.evm_address.hex() if record.evm_address else 'None'}")
137138
if record.contract_create_result:
138139
print(f" Contract Create Result: {record.contract_create_result.contract_id}")
139-
print(f" Result bytes (first 32): {record.contract_create_result.contract_call_result[:32].hex() if record.contract_create_result.contract_call_result else 'None'}...")
140+
print(
141+
f" Result bytes (first 32): {record.contract_create_result.contract_call_result[:32].hex() if record.contract_create_result.contract_call_result else 'None'}..."
142+
)
140143
else:
141144
print(" Contract Create Result: None")
142145

@@ -147,7 +150,8 @@ def print_all_fields(record):
147150
_print_basic_fields(record)
148151
_print_transfer_fields(record)
149152
_print_new_fields(record)
150-
153+
154+
151155
def main():
152156
"""Run the TransactionRecord example."""
153157
print("Creating mock TransactionRecord...\n")
@@ -157,4 +161,3 @@ def main():
157161

158162
if __name__ == "__main__":
159163
main()
160-

src/hiero_sdk_python/__init__.py

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -55,56 +55,6 @@
5555
from .file.file_info import FileInfo
5656
from .file.file_info_query import FileInfoQuery
5757
from .file.file_update_transaction import FileUpdateTransaction
58-
from .crypto.evm_address import EvmAddress
59-
60-
# Tokens
61-
from .tokens.token_create_transaction import TokenCreateTransaction
62-
from .tokens.token_associate_transaction import TokenAssociateTransaction
63-
from .tokens.token_dissociate_transaction import TokenDissociateTransaction
64-
from .tokens.token_delete_transaction import TokenDeleteTransaction
65-
from .tokens.token_info import TokenInfo
66-
from .tokens.token_mint_transaction import TokenMintTransaction
67-
from .tokens.token_freeze_transaction import TokenFreezeTransaction
68-
from .tokens.token_unfreeze_transaction import TokenUnfreezeTransaction
69-
from .tokens.token_wipe_transaction import TokenWipeTransaction
70-
from .tokens.token_reject_transaction import TokenRejectTransaction
71-
from .tokens.token_update_nfts_transaction import TokenUpdateNftsTransaction
72-
from .tokens.token_burn_transaction import TokenBurnTransaction
73-
from .tokens.token_grant_kyc_transaction import TokenGrantKycTransaction
74-
from .tokens.token_revoke_kyc_transaction import TokenRevokeKycTransaction
75-
from .tokens.token_update_transaction import TokenUpdateTransaction
76-
from .tokens.token_airdrop_transaction import TokenAirdropTransaction
77-
from .tokens.token_airdrop_transaction_cancel import TokenCancelAirdropTransaction
78-
from .tokens.token_airdrop_pending_id import PendingAirdropId
79-
from .tokens.token_airdrop_pending_record import PendingAirdropRecord
80-
from .tokens.token_id import TokenId
81-
from .tokens.token_type import TokenType
82-
from .tokens.supply_type import SupplyType
83-
from .tokens.nft_id import NftId
84-
from .tokens.token_nft_transfer import TokenNftTransfer
85-
from .tokens.token_nft_info import TokenNftInfo
86-
from .tokens.token_relationship import TokenRelationship
87-
from .tokens.token_allowance import TokenAllowance
88-
from .tokens.token_nft_allowance import TokenNftAllowance
89-
from .tokens.hbar_allowance import HbarAllowance
90-
from .tokens.hbar_transfer import HbarTransfer
91-
from .tokens.token_unpause_transaction import TokenUnpauseTransaction
92-
from .tokens.token_pause_transaction import TokenPauseTransaction
93-
from .tokens.token_airdrop_claim import TokenClaimAirdropTransaction
94-
from .tokens.assessed_custom_fee import AssessedCustomFee
95-
from .tokens.token_association import TokenAssociation
96-
97-
# Transaction
98-
from .transaction.transaction import Transaction
99-
from .transaction.transfer_transaction import TransferTransaction
100-
from .transaction.transaction_id import TransactionId
101-
from .transaction.transaction_receipt import TransactionReceipt
102-
from .transaction.transaction_response import TransactionResponse
103-
from .transaction.transaction_record import TransactionRecord
104-
from .transaction.batch_transaction import BatchTransaction
105-
106-
# Response / Codes
107-
from .response_code import ResponseCode
10858

10959
# HBAR
11060
from .hbar import Hbar
@@ -150,15 +100,13 @@
150100

151101
# Timestamp
152102
from .timestamp import Timestamp
103+
from .tokens.assessed_custom_fee import AssessedCustomFee
153104

154105
# Custom Fees
155-
from .tokens.assessed_custom_fee import AssessedCustomFee
156106
from .tokens.custom_fee import CustomFee
157107
from .tokens.custom_fixed_fee import CustomFixedFee
158108
from .tokens.custom_fractional_fee import CustomFractionalFee
159109
from .tokens.custom_royalty_fee import CustomRoyaltyFee
160-
161-
# Tokens
162110
from .tokens.hbar_allowance import HbarAllowance
163111
from .tokens.hbar_transfer import HbarTransfer
164112
from .tokens.nft_id import NftId
@@ -170,7 +118,10 @@
170118
from .tokens.token_airdrop_transaction_cancel import TokenCancelAirdropTransaction
171119
from .tokens.token_allowance import TokenAllowance
172120
from .tokens.token_associate_transaction import TokenAssociateTransaction
121+
from .tokens.token_association import TokenAssociation
173122
from .tokens.token_burn_transaction import TokenBurnTransaction
123+
124+
# Tokens
174125
from .tokens.token_create_transaction import TokenCreateTransaction
175126
from .tokens.token_delete_transaction import TokenDeleteTransaction
176127
from .tokens.token_dissociate_transaction import TokenDissociateTransaction
@@ -192,9 +143,9 @@
192143
from .tokens.token_update_nfts_transaction import TokenUpdateNftsTransaction
193144
from .tokens.token_update_transaction import TokenUpdateTransaction
194145
from .tokens.token_wipe_transaction import TokenWipeTransaction
146+
from .transaction.batch_transaction import BatchTransaction
195147

196148
# Transaction
197-
from .transaction.batch_transaction import BatchTransaction
198149
from .transaction.custom_fee_limit import CustomFeeLimit
199150
from .transaction.transaction import Transaction
200151
from .transaction.transaction_id import TransactionId

src/hiero_sdk_python/tokens/token_association.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Dataclass for automatic token associations in Hedera transaction records."""
2+
23
from __future__ import annotations
34

45
from dataclasses import dataclass
@@ -30,16 +31,8 @@ class TokenAssociation:
3031
def _from_proto(cls, proto: TokenAssociationProto) -> TokenAssociation:
3132
"""Create a TokenAssociation instance from the protobuf message."""
3233
return cls(
33-
token_id=(
34-
TokenId._from_proto(proto.token_id)
35-
if proto.HasField("token_id")
36-
else None
37-
),
38-
account_id=(
39-
AccountId._from_proto(proto.account_id)
40-
if proto.HasField("account_id")
41-
else None
42-
),
34+
token_id=(TokenId._from_proto(proto.token_id) if proto.HasField("token_id") else None),
35+
account_id=(AccountId._from_proto(proto.account_id) if proto.HasField("account_id") else None),
4336
)
4437

4538
def _to_proto(self) -> TokenAssociationProto:
@@ -64,12 +57,11 @@ def from_bytes(cls, data: bytes) -> TokenAssociation:
6457
proto = TokenAssociationProto()
6558
proto.ParseFromString(data)
6659
return cls._from_proto(proto)
67-
60+
6861
def __repr__(self) -> str:
6962
"""Returns an unambiguous string representation for debugging."""
7063
return f"TokenAssociation(token_id={self.token_id!r}, account_id={self.account_id!r})"
7164

7265
def __str__(self) -> str:
7366
"""Returns a human-readable string representation."""
7467
return self.__repr__()
75-

0 commit comments

Comments
 (0)