Skip to content

Commit d8f478e

Browse files
authored
docs: Add docstrings to account/account_info.py (#562) (#625)
Signed-off-by: Pranay <pranaygadh_mc24b06_003@dtu.ac.in>
1 parent 098821e commit d8f478e

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
88

99

1010
### Added
11+
- Add Google-style docstrings to `AccountInfo` class and its methods in `account_info.py`.
1112

1213
### Changed
1314

src/hiero_sdk_python/account/account_info.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ class AccountInfo:
5454

5555
@classmethod
5656
def _from_proto(cls, proto: CryptoGetInfoResponse.AccountInfo) -> "AccountInfo":
57+
"""Creates an AccountInfo instance from its protobuf representation.
58+
Deserializes a `CryptoGetInfoResponse.AccountInfo` message into this
59+
SDK's `AccountInfo` object. This method handles the conversion of
60+
protobuf types to their corresponding SDK types (e.g., tinybars to
61+
`Hbar`, proto `Timestamp` to SDK `Timestamp`).
62+
Args:
63+
proto (CryptoGetInfoResponse.AccountInfo): The source protobuf
64+
message containing account information.
65+
Returns:
66+
AccountInfo: A new `AccountInfo` instance populated with data
67+
from the protobuf message.
68+
Raises:
69+
ValueError: If the input `proto` is None.
70+
"""
5771
if proto is None:
5872
raise ValueError("Account info proto is None")
5973

@@ -80,6 +94,19 @@ def _from_proto(cls, proto: CryptoGetInfoResponse.AccountInfo) -> "AccountInfo":
8094
)
8195

8296
def _to_proto(self) -> CryptoGetInfoResponse.AccountInfo:
97+
"""Converts this AccountInfo object to its protobuf representation.
98+
Serializes this `AccountInfo` instance into a
99+
`CryptoGetInfoResponse.AccountInfo` message. This method handles
100+
the conversion of SDK types back to their protobuf equivalents
101+
(e.g., `Hbar` to tinybars, SDK `Timestamp` to proto `Timestamp`).
102+
Note:
103+
SDK fields that are `None` will be serialized as their
104+
default protobuf values (e.g., 0 for integers, False for booleans,
105+
empty strings/bytes).
106+
Returns:
107+
CryptoGetInfoResponse.AccountInfo: The protobuf message
108+
representation of this `AccountInfo` object.
109+
"""
83110
return CryptoGetInfoResponse.AccountInfo(
84111
accountID=self.account_id._to_proto() if self.account_id else None,
85112
contractAccountID=self.contract_account_id,

0 commit comments

Comments
 (0)