Skip to content

Conversation

@MrMadHatt
Copy link
Contributor

@MrMadHatt MrMadHatt commented Jan 3, 2026

Description:

Related issue(s):
Fixes #1299
Fixes #1301

Fixes # This PR applies black formatting to the examples/ directory

Notes for reviewer:
This PR strictly covers code style formatting using black. All 14 original commits have been squashed into a single verified commit. GPG and DCO signatures have been applied to meet the SDK contribution guidelines.
Checklist

  • [ x] Documented (Code comments, README, etc.)
  • [x ] Tested (unit, integration, etc.)

@coderabbitai
Copy link

coderabbitai bot commented Jan 3, 2026

📝 Walkthrough

Walkthrough

Apply Black formatting across many example files (quote normalization, blank-line and line-wrap changes), add environment/operator validation and a few helper functions in select examples (account, contract, consensus, topic), and introduce mock-data builders and CLI entry points in several example modules.

Changes

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Updated Unreleased entry to record Black formatting of examples; removed prior examples/tokens formatting note.
Account — token/allowance flows & validation
examples/account/account_allowance_approve_transaction_nft.py, examples/account/account_allowance_delete_transaction_nft.py
Reworked NFT examples to use token-centric transactions (TokenCreate/Mint/Associate), added operator env validation, improved prints/tracebacks and ensured cleanup; minor signature formatting only.
Account — creation flows & helpers
examples/account/account_create_transaction.py, examples/account/account_create_transaction_evm_alias.py, examples/account/account_create_transaction_with_fallback_alias.py
Added explicit operator key retrieval/signing, new helper functions (fetch_account_info, print_account_summary, alias/fallback key helpers), reflowed transaction construction and main flows; some new public functions and return values.
Account — formatting/refactors
examples/account/...
examples/account/account_create_transaction_create_with_alias.py, examples/account/account_create_transaction_without_alias.py, examples/account/account_delete_transaction.py, examples/account/account_id.py, examples/account/account_records_query.py, examples/account/account_update_transaction.py
Black-driven formatting: quote normalization, blank-line and chaining reflows, print rewraps; no semantic changes.
Account info — mocks
examples/account/account_info.py
Added many mock-builder functions for AccountInfo, print helper, and a main() entry point.
Client & consensus setup
examples/client/client.py, examples/consensus/topic_create_transaction.py, examples/consensus/topic_message_submit_transaction.py
Added environment parsing/validation for operator creds (early return on missing/invalid), load_dotenv usage; setup_client in one consensus example now returns operator_id/operator_key alongside client.
Consensus — formatting & mock adjustments
examples/consensus/...
examples/consensus/topic_create_transaction_revenue_generating.py, examples/consensus/topic_delete_transaction.py, examples/consensus/topic_update_transaction.py, examples/consensus/topic_message_submit_chunked_transaction.py
Quote normalization, blank-line and call reflows, small mock-response adjustments to support HasField/initialTransactionID in topic_message.
Consensus — Topic helpers & debug prints
examples/consensus/topic_id.py, examples/consensus/topic_message.py
Added debug prints for TopicId fields; extended mock protobuf helpers (HasField, initialTransactionID) and adjusted mock response construction.
Contract — new example helpers & formatting
examples/contract/contract_info_query.py, examples/contract/...
Added create_contract_file, create_contract, query_contract_info with runtime checks and CLI guard; other contract examples reformatted (quote/spacing).
Crypto examples
examples/crypto/*
Whitespace and blank-line adjustments only; no functional changes.
Errors & file examples
examples/errors/receipt_status_error.py, examples/file/*
Added try/except around credential parsing, quote/format normalization; many file examples formatted by Black.
Query, schedule, transaction examples
examples/query/topic_info_query.py, examples/query/transaction_get_receipt_query.py, examples/schedule/*, examples/transaction/*
Mostly formatting changes; one query example now returns created topic_id.
Topic info & assorted examples
examples/topic_info.py, examples/hbar.py, examples/logger/logging_example.py, examples/prng_transaction.py, examples/response_code.py, examples/utils.py, examples/tls_query_balance.py
topic_info.py gained multiple mock-builder helpers and a main; others updated for quote normalization, trailing newline, and cosmetic formatting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'style: apply black formatting to examples' directly and clearly describes the main change: applying Black code formatting to the examples directory.
Description check ✅ Passed The description is related to the changeset, stating that it applies Black formatting to all Python files in examples/, updates CHANGELOG.md, and references closed issues #1299 and #1301.
Linked Issues check ✅ Passed The PR successfully addresses both linked issues [#1299, #1301] by applying Black formatting to examples/file and examples/account directories, updating CHANGELOG.md, and providing signed commits with proper DCO/GPG signatures as required.
Out of Scope Changes check ✅ Passed While the PR scope expanded beyond the original issues (which targeted examples/file and examples/account only) to include all 64 files in the examples/ directory, this scope creep was acknowledged by the author and reviewers agreed to proceed with the broader formatting.
Docstring Coverage ✅ Passed Docstring coverage is 89.63% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
examples/contract/contract_delete_transaction.py (1)

64-70: Pre-existing: Consider adding freeze_with(client) before execute().

Per SDK best practices, transactions should follow the lifecycle: construct → freeze_with(client) → sign (if needed) → execute(client). This FileCreateTransaction and subsequent contract transactions skip freeze_with(). This is a pre-existing pattern—consider addressing in a follow-up issue rather than blocking this formatting PR.

Would you like me to open a new issue to track adding proper freeze_with() calls to this example?

examples/account/account_create_transaction.py (1)

1-10: Optional: Consider restoring module docstring.

The module docstring was removed (lines 1-2 now blank). While not blocking, examples typically benefit from a brief header explaining usage (e.g., "Example: Create a new Hedera account with initial balance"). This helps users understand what the example demonstrates at a glance.

examples/contract/contract_info_query.py (2)

36-42: Missing freeze_with(client) in transaction lifecycle.

The transaction executes without calling freeze_with(client), violating the documented SDK lifecycle pattern (construct → freeze_with → sign → execute). Users copying this example will encounter unexpected behavior.

🔎 Proposed fix
     file_receipt = (
         FileCreateTransaction()
         .set_keys(client.operator_private_key.public_key())
         .set_contents(SIMPLE_CONTRACT_BYTECODE)
         .set_file_memo("Simple contract bytecode file")
+        .freeze_with(client)
+        .sign(client.operator_private_key)
         .execute(client)
     )

As per coding guidelines, Priority 1-2: transaction lifecycle must include explicit freeze_with and signing steps.


56-66: Missing freeze_with(client) in transaction lifecycle.

The contract creation executes without freeze_with(client), breaking the required transaction lifecycle pattern. This prevents proper transaction finalization before execution.

🔎 Proposed fix
     receipt = (
         ContractCreateTransaction()
         .set_admin_key(client.operator_private_key.public_key())
         .set_initial_balance(1000)  # 1000 tinybars
         .set_max_automatic_token_associations(10)
         .set_auto_renew_account_id(client.operator_account_id)
         .set_auto_renew_period(Duration(seconds=5184000))  # 60 days in seconds
         .set_gas(1000000)  # 1M gas
         .set_bytecode_file_id(file_id)
         .set_contract_memo("Simple smart contract")
+        .freeze_with(client)
+        .sign(client.operator_private_key)
         .execute(client)
     )

As per coding guidelines, Priority 1-2: all transactions must follow the construct → freeze_with → sign → execute pattern.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ce63da and f40dc08.

📒 Files selected for processing (64)
  • CHANGELOG.md
  • examples/account/account_allowance_approve_transaction_hbar.py
  • examples/account/account_allowance_approve_transaction_nft.py
  • examples/account/account_allowance_delete_transaction_nft.py
  • examples/account/account_create_transaction.py
  • examples/account/account_create_transaction_create_with_alias.py
  • examples/account/account_create_transaction_evm_alias.py
  • examples/account/account_create_transaction_with_fallback_alias.py
  • examples/account/account_create_transaction_without_alias.py
  • examples/account/account_delete_transaction.py
  • examples/account/account_id.py
  • examples/account/account_info.py
  • examples/account/account_records_query.py
  • examples/account/account_update_transaction.py
  • examples/client/client.py
  • examples/consensus/topic_create_transaction.py
  • examples/consensus/topic_create_transaction_revenue_generating.py
  • examples/consensus/topic_delete_transaction.py
  • examples/consensus/topic_id.py
  • examples/consensus/topic_message.py
  • examples/consensus/topic_message_submit_chunked_transaction.py
  • examples/consensus/topic_message_submit_transaction.py
  • examples/consensus/topic_update_transaction.py
  • examples/contract/contract_bytecode_query.py
  • examples/contract/contract_call_query.py
  • examples/contract/contract_create_transaction_no_constructor_parameters.py
  • examples/contract/contract_create_transaction_with_bytecode.py
  • examples/contract/contract_create_transaction_with_constructor_parameters.py
  • examples/contract/contract_delete_transaction.py
  • examples/contract/contract_execute_transaction.py
  • examples/contract/contract_execute_transaction_with_value.py
  • examples/contract/contract_info_query.py
  • examples/contract/contract_update_transaction.py
  • examples/contract/ethereum_transaction.py
  • examples/crypto/private_key_der.py
  • examples/crypto/private_key_ecdsa.py
  • examples/crypto/private_key_ed25519.py
  • examples/crypto/public_key_der.py
  • examples/crypto/public_key_ecdsa.py
  • examples/crypto/public_key_ed25519.py
  • examples/errors/receipt_status_error.py
  • examples/file/file_append_transaction.py
  • examples/file/file_contents_query.py
  • examples/file/file_create_transaction.py
  • examples/file/file_delete_transaction.py
  • examples/file/file_info_query.py
  • examples/file/file_update_transaction.py
  • examples/hbar.py
  • examples/logger/logging_example.py
  • examples/prng_transaction.py
  • examples/query/topic_info_query.py
  • examples/query/transaction_get_receipt_query.py
  • examples/response_code.py
  • examples/schedule/schedule_create_transaction.py
  • examples/schedule/schedule_delete_transaction.py
  • examples/schedule/schedule_info_query.py
  • examples/schedule/schedule_sign_transaction.py
  • examples/tls_query_balance.py
  • examples/topic_info.py
  • examples/transaction/batch_transaction.py
  • examples/transaction/transfer_transaction_gigabar.py
  • examples/transaction/transfer_transaction_hbar.py
  • examples/transaction/transfer_transaction_tinybar.py
  • examples/utils.py
💤 Files with no reviewable changes (1)
  • examples/account/account_allowance_approve_transaction_hbar.py
🧰 Additional context used
📓 Path-based instructions (1)
examples/**/*

⚙️ CodeRabbit configuration file

examples/**/*: You are acting as a senior maintainer reviewing SDK examples. Your goal is to ensure examples work verbatim for users who copy-paste them.

Priority 1 - Correctness:

  • Verify transaction lifecycle chain (construction -> freeze_with -> sign -> execute).
  • Ensure freeze_with(client) is called BEFORE signing.
  • Validate that methods referenced actually exist in the hiero_sdk_python codebase.
  • Ensure response validation checks receipt.status against ResponseCode enums (e.g., ResponseCode.SUCCESS).

Priority 2 - Transaction Lifecycle:

  • Check method chaining logic.
  • Verify correct signing order (especially for multi-sig).
  • Ensure explicit .execute(client) calls.
  • Verify response property extraction (e.g., using .token_id, .account_id, .serial_numbers).
  • Ensure error handling uses ResponseCode(receipt.status).name for clarity.

Priority 3 - Naming & Clarity:

  • Enforce role-based naming: operator_id/_key, treasury_account_id/_key, receiver_id/_key.
  • Use _id suffix for AccountId and _key suffix for PrivateKey variables.
  • Validate negative examples explicitly check for failure codes (e.g., TOKEN_HAS_NO_PAUSE_KEY).
  • Ensure logical top-to-bottom flow without ambiguity.

Priority 4 - Consistency:

  • Verify standard patterns: def main(), if __name__ == "__main__":, load_dotenv().
  • IMPORT RULES:
    1. Accept both top-level imports (e.g., from hiero_sdk_python import PrivateKey) and fully qualified imports (e.g., from hiero_sdk_python.crypto.private_key import PrivateKey).
    2. STRICTLY validate that the import path actually exists in the project structure. Compare against other files in /examples or your knowledge of the SDK file tree.
    3. Flag hallucinations immediately (e.g., hiero_sdk_python.keys does not exist).
  • Check for try-except blocks with sys.exit(1) for critical failures.

Priority 5 - User Experience:

  • Ensure comments explain SDK usage patterns (for users,...

Files:

  • examples/transaction/batch_transaction.py
  • examples/crypto/private_key_ecdsa.py
  • examples/query/transaction_get_receipt_query.py
  • examples/contract/contract_create_transaction_with_bytecode.py
  • examples/contract/contract_call_query.py
  • examples/query/topic_info_query.py
  • examples/contract/contract_execute_transaction_with_value.py
  • examples/tls_query_balance.py
  • examples/contract/ethereum_transaction.py
  • examples/contract/contract_info_query.py
  • examples/schedule/schedule_info_query.py
  • examples/consensus/topic_create_transaction_revenue_generating.py
  • examples/account/account_records_query.py
  • examples/prng_transaction.py
  • examples/client/client.py
  • examples/account/account_update_transaction.py
  • examples/file/file_append_transaction.py
  • examples/transaction/transfer_transaction_gigabar.py
  • examples/schedule/schedule_create_transaction.py
  • examples/transaction/transfer_transaction_hbar.py
  • examples/file/file_create_transaction.py
  • examples/account/account_delete_transaction.py
  • examples/contract/contract_delete_transaction.py
  • examples/file/file_contents_query.py
  • examples/contract/contract_create_transaction_with_constructor_parameters.py
  • examples/crypto/public_key_ecdsa.py
  • examples/logger/logging_example.py
  • examples/schedule/schedule_sign_transaction.py
  • examples/contract/contract_execute_transaction.py
  • examples/errors/receipt_status_error.py
  • examples/crypto/private_key_der.py
  • examples/account/account_create_transaction_without_alias.py
  • examples/account/account_id.py
  • examples/transaction/transfer_transaction_tinybar.py
  • examples/account/account_create_transaction_create_with_alias.py
  • examples/utils.py
  • examples/contract/contract_bytecode_query.py
  • examples/consensus/topic_message_submit_chunked_transaction.py
  • examples/consensus/topic_delete_transaction.py
  • examples/contract/contract_update_transaction.py
  • examples/crypto/private_key_ed25519.py
  • examples/contract/contract_create_transaction_no_constructor_parameters.py
  • examples/account/account_info.py
  • examples/crypto/public_key_ed25519.py
  • examples/hbar.py
  • examples/schedule/schedule_delete_transaction.py
  • examples/file/file_update_transaction.py
  • examples/account/account_allowance_approve_transaction_nft.py
  • examples/crypto/public_key_der.py
  • examples/account/account_create_transaction_evm_alias.py
  • examples/account/account_create_transaction.py
  • examples/file/file_info_query.py
  • examples/consensus/topic_message_submit_transaction.py
  • examples/response_code.py
  • examples/consensus/topic_message.py
  • examples/consensus/topic_update_transaction.py
  • examples/file/file_delete_transaction.py
  • examples/consensus/topic_create_transaction.py
  • examples/consensus/topic_id.py
  • examples/account/account_allowance_delete_transaction_nft.py
  • examples/account/account_create_transaction_with_fallback_alias.py
  • examples/topic_info.py
🧬 Code graph analysis (37)
examples/transaction/batch_transaction.py (2)
src/hiero_sdk_python/crypto/private_key.py (1)
  • public_key (305-309)
src/hiero_sdk_python/response_code.py (1)
  • ResponseCode (4-387)
examples/crypto/private_key_ecdsa.py (2)
tests/unit/conftest.py (1)
  • private_key (54-56)
src/hiero_sdk_python/crypto/private_key.py (1)
  • PrivateKey (14-471)
examples/query/topic_info_query.py (3)
src/hiero_sdk_python/client/client.py (1)
  • Client (28-255)
src/hiero_sdk_python/query/topic_info_query.py (1)
  • TopicInfoQuery (13-190)
src/hiero_sdk_python/consensus/topic_create_transaction.py (1)
  • TopicCreateTransaction (27-243)
examples/tls_query_balance.py (2)
src/hiero_sdk_python/client/client.py (1)
  • set_transport_security (196-206)
src/hiero_sdk_python/client/network.py (1)
  • set_transport_security (300-308)
examples/schedule/schedule_info_query.py (1)
src/hiero_sdk_python/schedule/schedule_info_query.py (1)
  • ScheduleInfoQuery (18-135)
examples/account/account_records_query.py (1)
src/hiero_sdk_python/response_code.py (1)
  • ResponseCode (4-387)
examples/prng_transaction.py (1)
src/hiero_sdk_python/response_code.py (1)
  • ResponseCode (4-387)
examples/file/file_append_transaction.py (2)
src/hiero_sdk_python/file/file_append_transaction.py (1)
  • FileAppendTransaction (37-388)
src/hiero_sdk_python/response_code.py (1)
  • ResponseCode (4-387)
examples/schedule/schedule_create_transaction.py (1)
src/hiero_sdk_python/response_code.py (1)
  • ResponseCode (4-387)
examples/transaction/transfer_transaction_hbar.py (3)
src/hiero_sdk_python/response_code.py (1)
  • ResponseCode (4-387)
src/hiero_sdk_python/query/account_balance_query.py (1)
  • CryptoGetAccountBalanceQuery (10-138)
src/hiero_sdk_python/transaction/transaction_receipt.py (1)
  • account_id (88-100)
examples/file/file_create_transaction.py (3)
examples/account/account_allowance_approve_transaction_nft.py (1)
  • setup_client (57-76)
examples/account/account_update_transaction.py (1)
  • setup_client (26-37)
examples/consensus/topic_create_transaction.py (1)
  • setup_client (24-53)
examples/account/account_delete_transaction.py (3)
src/hiero_sdk_python/hbar.py (1)
  • Hbar (18-213)
src/hiero_sdk_python/account/account_delete_transaction.py (1)
  • AccountDeleteTransaction (20-145)
src/hiero_sdk_python/response_code.py (1)
  • ResponseCode (4-387)
examples/contract/contract_delete_transaction.py (2)
src/hiero_sdk_python/response_code.py (1)
  • ResponseCode (4-387)
src/hiero_sdk_python/hbar.py (2)
  • Hbar (18-213)
  • from_tinybars (97-109)
examples/file/file_contents_query.py (1)
src/hiero_sdk_python/crypto/private_key.py (1)
  • public_key (305-309)
examples/crypto/public_key_ecdsa.py (2)
src/hiero_sdk_python/crypto/public_key.py (1)
  • PublicKey (22-556)
src/hiero_sdk_python/utils/crypto_utils.py (1)
  • keccak256 (18-27)
examples/logger/logging_example.py (2)
src/hiero_sdk_python/logger/logger.py (2)
  • set_level (56-78)
  • set_silent (89-104)
src/hiero_sdk_python/logger/log_level.py (1)
  • LogLevel (10-60)
examples/errors/receipt_status_error.py (3)
src/hiero_sdk_python/tokens/token_associate_transaction.py (1)
  • TokenAssociateTransaction (23-176)
src/hiero_sdk_python/tokens/token_id.py (1)
  • TokenId (21-180)
src/hiero_sdk_python/exceptions.py (1)
  • ReceiptStatusError (63-91)
examples/account/account_create_transaction_without_alias.py (1)
src/hiero_sdk_python/account/account_create_transaction.py (2)
  • AccountCreateTransaction (27-380)
  • set_key_without_alias (94-107)
examples/transaction/transfer_transaction_tinybar.py (3)
src/hiero_sdk_python/response_code.py (1)
  • ResponseCode (4-387)
src/hiero_sdk_python/query/account_balance_query.py (1)
  • CryptoGetAccountBalanceQuery (10-138)
src/hiero_sdk_python/transaction/transaction_receipt.py (1)
  • account_id (88-100)
examples/account/account_create_transaction_create_with_alias.py (3)
src/hiero_sdk_python/account/account_create_transaction.py (2)
  • AccountCreateTransaction (27-380)
  • set_key_with_alias (109-135)
src/hiero_sdk_python/query/account_info_query.py (1)
  • AccountInfoQuery (11-131)
src/hiero_sdk_python/transaction/transaction_receipt.py (1)
  • account_id (88-100)
examples/consensus/topic_message_submit_chunked_transaction.py (2)
examples/consensus/topic_create_transaction.py (1)
  • setup_client (24-53)
src/hiero_sdk_python/client/client.py (2)
  • Client (28-255)
  • set_operator (149-154)
examples/consensus/topic_delete_transaction.py (2)
src/hiero_sdk_python/response_code.py (1)
  • ResponseCode (4-387)
src/hiero_sdk_python/consensus/topic_delete_transaction.py (1)
  • TopicDeleteTransaction (23-101)
examples/account/account_info.py (4)
src/hiero_sdk_python/account/account_id.py (1)
  • AccountId (21-198)
src/hiero_sdk_python/hbar.py (1)
  • Hbar (18-213)
src/hiero_sdk_python/timestamp.py (1)
  • Timestamp (8-166)
src/hiero_sdk_python/account/account_info.py (1)
  • AccountInfo (20-208)
examples/crypto/public_key_ed25519.py (1)
src/hiero_sdk_python/crypto/public_key.py (3)
  • PublicKey (22-556)
  • to_string_ed25519 (434-439)
  • verify (500-514)
examples/hbar.py (2)
src/hiero_sdk_python/hbar.py (2)
  • Hbar (18-213)
  • from_string (160-179)
src/hiero_sdk_python/hbar_unit.py (1)
  • from_string (33-47)
examples/account/account_allowance_approve_transaction_nft.py (4)
src/hiero_sdk_python/transaction/transfer_transaction.py (1)
  • TransferTransaction (24-238)
src/hiero_sdk_python/tokens/nft_id.py (1)
  • NftId (17-105)
src/hiero_sdk_python/account/account_allowance_approve_transaction.py (2)
  • AccountAllowanceApproveTransaction (27-396)
  • approve_token_nft_allowance_all_serials (256-277)
src/hiero_sdk_python/tokens/abstract_token_transfer_transaction.py (1)
  • add_approved_nft_transfer (315-338)
examples/crypto/public_key_der.py (2)
src/hiero_sdk_python/crypto/public_key.py (2)
  • PublicKey (22-556)
  • verify (500-514)
src/hiero_sdk_python/utils/crypto_utils.py (1)
  • keccak256 (18-27)
examples/account/account_create_transaction_evm_alias.py (2)
src/hiero_sdk_python/account/account_id.py (1)
  • AccountId (21-198)
src/hiero_sdk_python/crypto/private_key.py (1)
  • PrivateKey (14-471)
examples/account/account_create_transaction.py (1)
src/hiero_sdk_python/client/client.py (3)
  • Client (28-255)
  • from_env (54-98)
  • close (184-194)
examples/file/file_info_query.py (1)
src/hiero_sdk_python/crypto/private_key.py (1)
  • public_key (305-309)
examples/consensus/topic_message_submit_transaction.py (2)
src/hiero_sdk_python/response_code.py (1)
  • ResponseCode (4-387)
src/hiero_sdk_python/consensus/topic_create_transaction.py (1)
  • TopicCreateTransaction (27-243)
examples/consensus/topic_message.py (1)
src/hiero_sdk_python/consensus/topic_message.py (4)
  • TopicMessage (34-192)
  • TopicMessageChunk (14-31)
  • of_single (66-89)
  • of_many (92-142)
examples/consensus/topic_create_transaction.py (1)
src/hiero_sdk_python/crypto/private_key.py (1)
  • public_key (305-309)
examples/consensus/topic_id.py (1)
src/hiero_sdk_python/consensus/topic_id.py (1)
  • TopicId (21-128)
examples/account/account_allowance_delete_transaction_nft.py (4)
src/hiero_sdk_python/client/client.py (2)
  • set_operator (149-154)
  • Client (28-255)
src/hiero_sdk_python/tokens/nft_id.py (1)
  • NftId (17-105)
src/hiero_sdk_python/account/account_id.py (1)
  • AccountId (21-198)
src/hiero_sdk_python/account/account_allowance_approve_transaction.py (3)
  • AccountAllowanceApproveTransaction (27-396)
  • approve_token_nft_allowance_all_serials (256-277)
  • delete_token_nft_allowance_all_serials (279-319)
examples/account/account_create_transaction_with_fallback_alias.py (1)
src/hiero_sdk_python/account/account_create_transaction.py (2)
  • AccountCreateTransaction (27-380)
  • set_key_with_alias (109-135)
examples/topic_info.py (3)
src/hiero_sdk_python/timestamp.py (1)
  • Timestamp (8-166)
tests/unit/topic_info_test.py (1)
  • topic_info (16-56)
src/hiero_sdk_python/consensus/topic_info.py (1)
  • TopicInfo (21-169)
🪛 Ruff (0.14.10)
examples/client/client.py

77-77: Loop control variable i not used within loop body

Rename unused i to _i

(B007)

examples/logger/logging_example.py

87-87: f-string without any placeholders

Remove extraneous f prefix

(F541)

examples/errors/receipt_status_error.py

64-64: Abstract raise to an inner function

(TRY301)


78-78: Do not catch blind exception: Exception

(BLE001)

examples/consensus/topic_message_submit_chunked_transaction.py

68-68: Consider moving this statement to an else block

(TRY300)


69-69: Do not catch blind exception: Exception

(BLE001)


89-89: Consider moving this statement to an else block

(TRY300)


90-90: Do not catch blind exception: Exception

(BLE001)


118-118: f-string without any placeholders

Remove extraneous f prefix

(F541)


120-120: Cannot reuse outer quote character in f-strings on Python 3.10 (syntax was added in Python 3.12)

(invalid-syntax)


123-123: Do not catch blind exception: Exception

(BLE001)


124-124: Use explicit conversion flag

Replace with conversion flag

(RUF010)

examples/account/account_allowance_approve_transaction_nft.py

236-236: Do not catch blind exception: Exception

(BLE001)

examples/account/account_create_transaction_evm_alias.py

168-168: Do not catch blind exception: Exception

(BLE001)

examples/account/account_create_transaction.py

42-44: Abstract raise to an inner function

(TRY301)


42-44: Create your own exception

(TRY002)


42-44: Avoid specifying long messages outside the exception class

(TRY003)


46-46: Do not catch blind exception: Exception

(BLE001)


47-47: Use explicit conversion flag

Replace with conversion flag

(RUF010)

examples/response_code.py

6-6: Missing return type annotation for special method __init__

Add return type annotation: None

(ANN204)

examples/consensus/topic_message.py

21-21: Missing return type annotation for special method __init__

Add return type annotation: None

(ANN204)


29-29: Missing return type annotation for special method __init__

Add return type annotation: None

(ANN204)


39-39: Missing return type annotation for special method __init__

Add return type annotation: None

(ANN204)


64-64: Missing return type annotation for special method __init__

Add return type annotation: None

(ANN204)


87-87: Boolean-typed positional argument in function definition

(FBT001)


87-87: Boolean default positional argument in function definition

(FBT002)


89-89: Boolean-typed positional argument in function definition

(FBT001)


89-89: Boolean default positional argument in function definition

(FBT002)

examples/consensus/topic_update_transaction.py

88-88: Do not catch blind exception: Exception

(BLE001)


89-89: Use explicit conversion flag

Replace with conversion flag

(RUF010)

examples/account/account_allowance_delete_transaction_nft.py

147-147: Do not catch blind exception: Exception

(BLE001)


172-172: Do not catch blind exception: Exception

(BLE001)


202-202: Do not catch blind exception: Exception

(BLE001)


264-264: f-string without any placeholders

Remove extraneous f prefix

(F541)


271-271: Do not catch blind exception: Exception

(BLE001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis

@Akshat8510
Copy link
Contributor

Hi @MrMadHatt, thank you for the clean PR! You did an excellent job with the squashing and signing, the single verified commit looks great.

@Akshat8510
Copy link
Contributor

Akshat8510 commented Jan 3, 2026

I’ll need a bit more time to finish reviewing all 64 changed files, but in the meantime feel free to address the bot’s committable suggestions

Copy link
Contributor

@exploreriii exploreriii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MrMadHatt
This is a very extensive PR, thank you! Looks really amazing.

One issue I see - is the issue description was just to black examples/account, i think you have done: black examples
(all of examples, rather than just account).

We have another PR from another person that has done black/file, which means you might be overwriting their change.

I think in this case we could just go ahead with black the entire examples, but as pointed out, its a lot to review which is why we encourage splitting them up.

How would you like to proceed with this? Would you like to close this PR, and just do black for examples/account? Or shall we press forward as the PR is very good

@exploreriii
Copy link
Contributor

I re-read the issue description and noticed it was terribly unclear what to black!
I intended to write examples/file but I did say, format examples!

In this case, i will proceed by reviewing this PR as it is, many thanks @MrMadHatt

@exploreriii exploreriii marked this pull request as draft January 3, 2026 10:20
@MrMadHatt
Copy link
Contributor Author

Thank you @exploreriii and @Akshat8510!

@exploreriii - Apologies for the scope creep! I was running into some issues running the command for just a single file, and it ended up formatting the entire examples/ directory. I decided to push it for review, but I apologize if I overstepped our original plan and someone else's work. I'm glad to hear the broader update is helpful!

@Akshat8510 - I can address the bot's suggestions now, I'll fix these locally and update the PR so we can keep a clean single commit history. Since I've also been assigned to #1301, would you like me to prioritize the bot fixes here first, or should I jump straight to the new issue?

Happy to handle it whichever way works best for your review timeline!

@exploreriii
Copy link
Contributor

Hi @MrMadHatt

Please could you prioritize fixing the one example file mentioned here:
"This file examples/account/account_create_transaction.py has an error, you have deleted multiple sections of the docstrings compared to main."

Once that is done, we can merge this 🥇

@Akshat8510
Copy link
Contributor

Agreed. @MrMadHatt, let's follow those steps from @exploreriii to get that specific file restored. I'm standing by if you need any help with the git commands or the re-formatting. Looking forward to the final push! 🥇

@MrMadHatt MrMadHatt force-pushed the style/format-account-example branch from d06097b to 1a9dada Compare January 3, 2026 15:57
@MrMadHatt
Copy link
Contributor Author

@exploreriii I have followed the steps: restored account_create_transaction.py from main, applied black formatting to it, and moved the Changelog entry to line 83.

@Akshat8510 The history should be clean and ready for the final look!

@MrMadHatt MrMadHatt marked this pull request as ready for review January 3, 2026 16:18
@Akshat8510
Copy link
Contributor

Hi @MrMadHatt, I see you marked the conversation as resolved, but the security prints are actually still present in file_append_transaction.py

@MrMadHatt
Copy link
Contributor Author

Thanks for catching that @Akshat8510! I've located the prints in examples/file/file_append_transactions.py. To fix this would you prefer I delete those lines entirely, or mask the output? (e.g., print("Operator Key: ") to keep the example flow intact?

Once you let me know, I'll push the update right away.

@Akshat8510
Copy link
Contributor

It's best to delete those lines entirely. Printing credentials (even if masked) isn't necessary for the example's functionality and it's generally a safer coding practice to avoid any logic that touches those secrets in the console output.

@exploreriii
Copy link
Contributor

I'm cognizant this is @MrMadHatt first PR and has followed the issue description

These print statements are an existing issue in the example codebase, which has generally been considered fine as its testnet (though you are right we should un-print them), maybe we can create a second good first issue to correct this (and similar instances)?
@Akshat8510 how would you like to proceed?

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
examples/consensus/topic_message_submit_chunked_transaction.py (1)

118-118: Remove unnecessary f-string prefix.

Line 118 uses an f-string prefix without any interpolation placeholders, which is wasteful and demonstrates incorrect f-string usage in an example file that users will copy.

This issue was flagged in the previous review but remains unresolved.

🔎 Proposed fix
-        print(f"Message size:", len(BIG_CONTENT), "bytes")
+        print("Message size:", len(BIG_CONTENT), "bytes")
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2afd153 and b6531ad.

📒 Files selected for processing (2)
  • examples/consensus/topic_message_submit_chunked_transaction.py
  • examples/file/file_append_transaction.py
🧰 Additional context used
📓 Path-based instructions (1)
examples/**/*

⚙️ CodeRabbit configuration file

examples/**/*: You are acting as a senior maintainer reviewing SDK examples. Your goal is to ensure examples work verbatim for users who copy-paste them.

Priority 1 - Correctness:

  • Verify transaction lifecycle chain (construction -> freeze_with -> sign -> execute).
  • Ensure freeze_with(client) is called BEFORE signing.
  • Validate that methods referenced actually exist in the hiero_sdk_python codebase.
  • Ensure response validation checks receipt.status against ResponseCode enums (e.g., ResponseCode.SUCCESS).

Priority 2 - Transaction Lifecycle:

  • Check method chaining logic.
  • Verify correct signing order (especially for multi-sig).
  • Ensure explicit .execute(client) calls.
  • Verify response property extraction (e.g., using .token_id, .account_id, .serial_numbers).
  • Ensure error handling uses ResponseCode(receipt.status).name for clarity.

Priority 3 - Naming & Clarity:

  • Enforce role-based naming: operator_id/_key, treasury_account_id/_key, receiver_id/_key.
  • Use _id suffix for AccountId and _key suffix for PrivateKey variables.
  • Validate negative examples explicitly check for failure codes (e.g., TOKEN_HAS_NO_PAUSE_KEY).
  • Ensure logical top-to-bottom flow without ambiguity.

Priority 4 - Consistency:

  • Verify standard patterns: def main(), if __name__ == "__main__":, load_dotenv().
  • IMPORT RULES:
    1. Accept both top-level imports (e.g., from hiero_sdk_python import PrivateKey) and fully qualified imports (e.g., from hiero_sdk_python.crypto.private_key import PrivateKey).
    2. STRICTLY validate that the import path actually exists in the project structure. Compare against other files in /examples or your knowledge of the SDK file tree.
    3. Flag hallucinations immediately (e.g., hiero_sdk_python.keys does not exist).
  • Check for try-except blocks with sys.exit(1) for critical failures.

Priority 5 - User Experience:

  • Ensure comments explain SDK usage patterns (for users,...

Files:

  • examples/consensus/topic_message_submit_chunked_transaction.py
  • examples/file/file_append_transaction.py
🧬 Code graph analysis (2)
examples/consensus/topic_message_submit_chunked_transaction.py (3)
examples/consensus/topic_create_transaction.py (2)
  • setup_client (24-53)
  • create_topic (56-77)
examples/consensus/topic_message_submit_transaction.py (2)
  • setup_client (25-40)
  • create_topic (43-61)
examples/consensus/topic_update_transaction.py (2)
  • setup_client (25-40)
  • create_topic (43-61)
examples/file/file_append_transaction.py (1)
src/hiero_sdk_python/file/file_append_transaction.py (1)
  • FileAppendTransaction (37-388)
🪛 Ruff (0.14.10)
examples/consensus/topic_message_submit_chunked_transaction.py

68-68: Consider moving this statement to an else block

(TRY300)


69-69: Do not catch blind exception: Exception

(BLE001)


89-89: Consider moving this statement to an else block

(TRY300)


90-90: Do not catch blind exception: Exception

(BLE001)


118-118: f-string without any placeholders

Remove extraneous f prefix

(F541)


123-123: Do not catch blind exception: Exception

(BLE001)


124-124: Use explicit conversion flag

Replace with conversion flag

(RUF010)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (6)
examples/file/file_append_transaction.py (4)

32-44: ✅ Security concern resolved: debug prints removed.

The previous review flagged insecure print statements exposing OPERATOR_KEY to stdout. These have been removed from setup_client(). Users can now safely copy-paste this example without risk of credential leakage.


47-118: ✅ Transaction lifecycle and multi-chunk support correct.

All three transaction operations follow the proper chain:

  • set_*() configuration
  • freeze_with(client) before signing
  • sign(key) operation
  • execute(client) submission

Multi-chunk append (lines 93–118) correctly configures set_chunk_size() and set_max_chunks(). Error handling validates receipt.status against ResponseCode.SUCCESS and exits on failure.


1-143: ✅ Black formatting applied correctly throughout.

All style changes follow Black conventions:

  • Imports properly formatted (lines 19–27)
  • String quoting normalized to double quotes (lines 29, 39–40)
  • Long print statements wrapped for readability (lines 61–63, 85–87, 110–112)
  • Whitespace and blank lines adjusted per Black standards

No functional changes; formatting-only modifications are appropriate for this PR.


19-27: All imports in examples/file/file_append_transaction.py (lines 19-27) are valid and correctly exported from hiero_sdk_python.

Import verification confirms:

  • Client, Network, PrivateKey, FileCreateTransaction, AccountId, FileAppendTransaction, and ResponseCode all exist in the SDK codebase
  • All are properly exported via hiero_sdk_python/__init__.py
  • Top-level import syntax is correct and idiomatic
examples/consensus/topic_message_submit_chunked_transaction.py (2)

119-121: Excellent fix for the Python 3.10 syntax error!

The nested quotes issue has been resolved. Line 120 now correctly uses single quotes '...' inside the f-string, making this code compatible with Python 3.10+. This addresses the critical syntax error flagged by reviewers.


128-147: Query pattern looks correct.

The fetch_topic_info function correctly constructs and executes a TopicInfoQuery. Query operations don't require freeze_with or signing, and the pattern TopicInfoQuery().set_topic_id(...).execute(client) follows SDK conventions.

Note: This depends on the TopicInfoQuery import being valid (addressed in separate comment).

@Akshat8510
Copy link
Contributor

Actually, @MrMadHatt has already been a superstar and handled both the Python 3.10 syntax fix and the security prints in his latest commit!

@Akshat8510
Copy link
Contributor

Since those critical items are now cleared and the formatting is consistent, I'm completely satisfied with this PR. I agree that any further 'consistency' fixes (like the ones the bot is suggesting now regarding explicit signing) should be handled in a separate issue to keep this one focused.

Copy link
Contributor

@Akshat8510 Akshat8510 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great first contribution by @MrMadHatt!

@codecov
Copy link

codecov bot commented Jan 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1320   +/-   ##
=======================================
  Coverage   92.29%   92.29%           
=======================================
  Files         139      139           
  Lines        8515     8515           
=======================================
  Hits         7859     7859           
  Misses        656      656           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@exploreriii exploreriii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much @MrMadHatt for this massive formatting improvement and taking the time to get it just right!

@exploreriii exploreriii merged commit ab1c569 into hiero-ledger:main Jan 4, 2026
21 checks passed
@MrMadHatt
Copy link
Contributor Author

Thank you so much @Akshat8510 and @exploreriii! I really appreciate the mentorship and the kind words.

Extra thanks for helping me navigate through those 14 commits and the hit history hurdle the other day! Getting that sorted was a huge learning moment for me. I'm glad the final fixes for the Python 3.10 syntax and security prints hit the mark. Looking forward to the next one!

@MrMadHatt MrMadHatt deleted the style/format-account-example branch January 4, 2026 13:10
@exploreriii
Copy link
Contributor

Really happy to hear that you are feeling good about overcoming those hurdles!!

If you are up for the next level up, we have a couple of beginner friendly issues here:
https://github.com/hiero-ledger/hiero-sdk-python/issues?q=is%3Aissue%20state%3Aopen%20label%3Abeginner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Good First Issue]: format black examples/account [Good First Issue]: Format examples/file with black

3 participants