Skip to content

Commit 28a7bb6

Browse files
authored
chore: Use typing.NamedTuple for Operator in client.py (#669)
Signed-off-by: Adityarya11 <arya050411@gmail.com>
1 parent 5ef312c commit 28a7bb6

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
2121
- chore: Update env.example NETWORK to encourage testnet or local usage (#659)
2222
- chore: fix type hint for TokenCancelAirdropTransaction pending_airdrops parameter
2323
- chore: Moved documentation file `common_issues.md` from `examples/sdk_developers/` to `docs/sdk_developers/` for unified documentation management (#516).
24+
2425
- chore: Refactored the script of examples/custom_fee.py into modular functions
2526

27+
- fix: Replaced `collections.namedtuple` with `typing.NamedTuple` in `client.py` for improved type checking.
28+
29+
2630
### Fixed
2731

2832
- Added explicit read permissions to examples.yml (#623)

src/hiero_sdk_python/client/client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
Client module for interacting with the Hedera network.
33
"""
44

5-
from collections import namedtuple
6-
from typing import List, Union
5+
from typing import NamedTuple, List, Union
76

87
import grpc
98

@@ -18,7 +17,10 @@
1817

1918
from .network import Network
2019

21-
Operator = namedtuple('Operator', ['account_id', 'private_key'])
20+
class Operator(NamedTuple):
21+
"""A named tuple for the operator's account ID and private key."""
22+
account_id: AccountId
23+
private_key: PrivateKey
2224

2325
class Client:
2426
"""
@@ -112,4 +114,4 @@ def __exit__(self, exc_type, exc_value, traceback) -> None:
112114
"""
113115
Automatically close channels when exiting 'with' block.
114116
"""
115-
self.close()
117+
self.close()

0 commit comments

Comments
 (0)