-
Notifications
You must be signed in to change notification settings - Fork 193
Description
🐥 Beginner Friendly
This issue is intended for contributors who have previously completed a Good First Issue in Hiero and are at a beginner level.
We recognize that gaining confidence and building skills are equally important steps in the open-source contributor journey.
The purpose of this issue—and others listed under Find a beginner issue—is to provide a supportive, low-pressure environment where you can learn, practice, and grow your contribution skills with confidence.
Important
🐥 Beginner Issue Guidelines
Beginner Issues are intended for contributors who are familiar with the project workflow and have some programming experience and are wanting opportunities to build skills.
These issues may require light investigation, interpretation of existing code, and some self-initiative, but should remain well-scoped with a clear intent.
👾 Description of the issue
The NftId class in src/hiero_sdk_python/tokens/nft_id.py has a __str__ method that returns a human-readable representation like 0.0.123/5, but it lacks a custom __repr__ method. When developers debug code using repr() or inspect objects in a REPL, they see the default dataclass representation which is less informative.
Currently, printing an NftId with repr() may produce:
>>> nft_id = NftId(TokenId(0, 0, 123), 5)
>>> repr(nft_id)
"NftId(token_id=TokenId(shard=0, realm=0, num=123, checksum=None), serial_number=5)"While the default dataclass __repr__ is somewhat helpful, it could be improved to be more concise and match the style used elsewhere in the SDK.
💡 Proposed Solution
Implement a custom __repr__() method for the NftId class that returns a clear, constructor-style representation showing the token ID and serial number. The format should be:
>>> nft_id = NftId(TokenId(0, 0, 123), 5)
>>> repr(nft_id)
"NftId(token_id=0.0.123, serial_number=5)"👩💻 Implementation Steps
- Open the file
src/hiero_sdk_python/tokens/nft_id.py - Review the existing
__str__()method to understand the current string formatting - Review the
__init__()method to see which fields define an NftId (token_id,serial_number) - Add a new
__repr__()method after the existing__str__()method (around line 105):def __repr__(self) -> str: """ Returns a detailed representation of the NftId suitable for debugging. Returns: str: A string in the format 'NftId(token_id=X.X.X, serial_number=Y)'. """ return f"NftId(token_id={self.token_id}, serial_number={self.serial_number})"
- Write a unit test for the new
__repr__()method in the appropriate test file (likelytests/unit/test_nft_id.pyor create one if needed):def test_nft_id_repr(): token_id = TokenId(0, 0, 123) nft_id = NftId(token_id, 5) assert repr(nft_id) == "NftId(token_id=0.0.123, serial_number=5)"
- Run the tests to verify everything works:
pytest tests/
✅ Acceptance Criteria
-
The issue is solved:
My changes do exactly what the issue asked for. -
I did not add extra changes:
I did not modify anything that was not mentioned in the issue description. -
Nothing else was broken:
All existing features still work the same as before. -
All checks pass:
The automated tests (unit and integration tests) run successfully.
📋 Step-by-Step Contribution Guide
- Assignment: You must be assigned to the issue, comment:
/assignin the issue to get assigned see guide - Fork, Branch and Work on the issue: Create a copy of the repository, create a branch for the issue and solve the problem. For instructions, please read our Contributing guide file. Further help can be found at Set-up Training (including the Windows Setup Guide for Windows users) and Workflow Training.
- DCO and GPG key sign each commit : each commit must be -s and -S signed. An explanation on how to do this is at Signing Guide
- Add a Changelog Entry : your pull request will require a changelog. Read Changelog Entry Guide to learn how.
- Push and Create a Pull Request : Once your issue is resolved, and your commits are signed, and you have a changelog entry, push your changes and create a pull request. Detailed instructions can be found at Submit PR Training, part of Workflow Training.
- You did it 🎉: A maintainer or committer will review your pull request and provide feedback. If approved, we will merge the fix in the main branch. Thanks for being part of the Hiero community as an open-source contributor ❤️
IMPORTANT You will ONLY be assigned to the issue if you comment: /assign
IMPORTANT Your pull request CANNOT BE MERGED until you add a changelog entry AND sign your commits each with git commit -S -s -m "chore: your commit message" with a GPG key setup.
🤖 AI Usage Guidelines
You are welcome to use AI to help you understand and solve this issue.
Because AI tools can sometimes make mistakes, please take care to:
- Only implement what is described in this issue
- Avoid changing anything else in the file
- Be careful when modifying parameters or return statements, as this may affect runtime behavior
If you're unsure, ask your mentor or the maintainers for help — they can provide expert Python SDK guidance and point you to the right examples or methods.
🤔 Additional Information
For more help, we have extensive documentation:
Additionally, we invite you to join our community on our Discord server.
We also invite you to attend each Wednesday, 2pm UTC our Python SDK Office Hour and Community Calls. The Python SDK Office hour is for hands-on-help and the Community Call for general community discussion.
You can also ask for help in a comment below!