Skip to content

Conversation

@Akshat8510
Copy link
Contributor

@Akshat8510 Akshat8510 commented Dec 17, 2025

Description:
This PR improves the developer experience by adding __repr__ and __str__ methods to the AccountInfo class. Previously, printing an AccountInfo object resulted in a generic object representation (e.g., <AccountInfo object at 0x...>). Now, it provides a human-readable summary (__str__) and a detailed debugging representation (__repr__).

  • Add __repr__ method to AccountInfo for detailed debugging output.
  • Add __str__ method to AccountInfo for a user-friendly summary of account details.
  • Update tests/unit/account_info_test.py to verify the new string representations.
  • Update examples/account/account_info.py to demonstrate the improved output.

Related issue(s):

Fixes #1098

Notes for reviewer:
Here is the verified output from the updated example script examples/account/account_info.py:

📜 AccountInfo String Representation:
Account ID: 0.0.1234
Balance: 100.00000000 ℏ
Key: <PublicKey (ECDSA) hex=0361a4ff482f7020a58d2519dcc459e39e0019760744b86ea4a2d8942658273b6d>
Memo: Mock Account for Example
Expiration Time: 1736539200.000000100
Auto Renew Period: Duration of 7776000 seconds.
Token Relationships: 1

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit)

Summary by CodeRabbit

  • New Features

    • Account information now includes human-readable and debug string representations showing key details (ID, balance, memo, NFT count and relevant status) for clearer logging and debugging.
  • Tests

    • Added unit tests validating the new user-facing and debug string representations.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 17, 2025

Walkthrough

Adds str and repr methods to AccountInfo, updates an example to print AccountInfo directly, documents the change in CHANGELOG, and adds a unit test verifying both string representations.

Changes

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Documents the addition of __str__ and __repr__ methods to AccountInfo.
Core implementation
src/hiero_sdk_python/account/account_info.py
Adds def __str__(self) -> str producing a multi-line, conditional summary of AccountInfo fields and def __repr__(self) -> str returning a concise constructor-like representation. No changes to serialization/deserialization or other behaviors.
Example
examples/account/account_info.py
Replaces field-by-field printing in print_account_info() with print(info) to rely on the new __str__ output.
Tests
tests/unit/account_info_test.py
Adds test_str_and_repr(account_info) asserting expected substrings appear in __str__() and __repr__() outputs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect __str__() formatting and conditional inclusion of optional fields (is_deleted, receiver_signature_required, decline_staking_reward, token_relationships count).
  • Verify __repr__() includes appropriate, non-sensitive fields and uses a clear constructor-like form.
  • Confirm example change and test assertions align with the new string formats.

Poem

🐰 I hop through bytes with joyful cheer,

AccountInfo now reads so clear.
No cryptic hex, no mystery map,
Just friendly lines for every app.
A rabbit's nod — the logs clap clap!

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding str and repr methods to the AccountInfo class.
Linked Issues check ✅ Passed The PR implements all required objectives from #1098: repr and str methods added to AccountInfo with appropriate formatting, unit tests added, and examples updated to demonstrate the new string representations.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing str and repr for AccountInfo as specified in #1098; no unrelated modifications are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09a99f5 and 9f30776.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md
⏰ 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). (7)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: build-and-test (3.13)
  • GitHub Check: build-and-test (3.10)
  • GitHub Check: build-and-test (3.12)
  • GitHub Check: build-and-test (3.11)
  • GitHub Check: run-examples
  • GitHub Check: StepSecurity Harden-Runner

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.

@Akshat8510 Akshat8510 marked this pull request as draft December 17, 2025 18:59
@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

❌ Patch coverage is 85.71429% with 2 lines in your changes missing coverage. Please review.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1129      +/-   ##
==========================================
+ Coverage   91.04%   91.08%   +0.03%     
==========================================
  Files         139      139              
  Lines        8409     8423      +14     
==========================================
+ Hits         7656     7672      +16     
+ Misses        753      751       -2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@exploreriii
Copy link
Contributor

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Dec 17, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Akshat8510 Akshat8510 requested a review from MonaaEid December 17, 2025 19:45
Copy link
Contributor

@MonaaEid MonaaEid left a comment

Choose a reason for hiding this comment

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

Really good work!

@exploreriii
Copy link
Contributor

Hi this si still in draft, is it ready to review once rebased?

@Akshat8510 Akshat8510 marked this pull request as ready for review December 18, 2025 02:27
@exploreriii exploreriii merged commit 02a09e1 into hiero-ledger:main Dec 18, 2025
20 checks passed
@exploreriii
Copy link
Contributor

Thank you so much @Akshat8510 and @MonaaEid !

prajeeta15 pushed a commit to prajeeta15/hiero-sdk-python that referenced this pull request Dec 23, 2025
…1129)

Signed-off-by: Akshat Kumar <[email protected]>
Signed-off-by: Akshat8510 <[email protected]>
Signed-off-by: prajeeta pal <[email protected]>
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.

Expand src/hiero_sdk_python/account/account_info.py to add __repr__ and __str__

3 participants