Skip to content

Commit 6474a93

Browse files
committed
Merge pull request input-output-hk#289 from input-output-hk/fix_docstrings
refactor: update docstrings to use 'data container'
2 parents 8ba0d2f + 3842fef commit 6474a93

11 files changed

+50
-42
lines changed

cardano_clusterlib/address_group.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def gen_payment_key_pair(
9393
destination_dir: A path to directory for storing artifacts (optional).
9494
9595
Returns:
96-
structs.KeyPair: A tuple containing the key pair.
96+
structs.KeyPair: A data container containing the key pair.
9797
"""
9898
destination_dir = pl.Path(destination_dir).expanduser()
9999
vkey = destination_dir / f"{key_name}.vkey"
@@ -155,7 +155,7 @@ def get_address_info(
155155
address: A Cardano address.
156156
157157
Returns:
158-
structs.AddressInfo: A tuple containing address info.
158+
structs.AddressInfo: A data container containing address info.
159159
"""
160160
addr_dict: dict[str, str] = json.loads(
161161
self._clusterlib_obj.cli(["address", "info", "--address", str(address)])
@@ -180,7 +180,8 @@ def gen_payment_addr_and_keys(
180180
destination_dir: A path to directory for storing artifacts (optional).
181181
182182
Returns:
183-
structs.AddressRecord: A tuple containing the address and key pair / script file.
183+
structs.AddressRecord: A data container containing the address and
184+
key pair / script file.
184185
"""
185186
key_pair = self.gen_payment_key_pair(key_name=name, destination_dir=destination_dir)
186187
addr = self.gen_payment_addr(

cardano_clusterlib/clusterlib_klass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def cli(
249249
add_default_args: Whether to add default arguments to the command (optional).
250250
251251
Returns:
252-
structs.CLIOut: A tuple containing command stdout and stderr.
252+
structs.CLIOut: A data container containing command stdout and stderr.
253253
"""
254254
cli_args_strs_all = [str(arg) for arg in cli_args]
255255

cardano_clusterlib/conway_gov_drep_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def gen_key_pair(self, key_name: str, destination_dir: itp.FileType = ".") -> st
6868
destination_dir: A path to directory for storing artifacts (optional).
6969
7070
Returns:
71-
structs.KeyPair: A tuple containing the key pair.
71+
structs.KeyPair: A data container containing the key pair.
7272
"""
7373
destination_dir = pl.Path(destination_dir).expanduser()
7474
vkey = destination_dir / f"{key_name}_drep.vkey"

cardano_clusterlib/genesis_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, clusterlib_obj: "itp.ClusterLib") -> None:
2222

2323
@property
2424
def genesis_keys(self) -> structs.GenesisKeys:
25-
"""Return tuple with genesis-related keys."""
25+
"""Return data container with genesis-related keys."""
2626
if self._genesis_keys:
2727
return self._genesis_keys
2828

cardano_clusterlib/governance_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def submit_update_proposal(
194194
destination_dir: A path to directory for storing artifacts (optional).
195195
196196
Returns:
197-
structs.TxRawOutput: A tuple with transaction output details.
197+
structs.TxRawOutput: A data container with transaction output details.
198198
"""
199199
# TODO: assumption is update proposals submitted near beginning of epoch
200200
epoch = epoch if epoch is not None else self._clusterlib_obj.g_query.get_epoch()

cardano_clusterlib/node_group.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def gen_kes_key_pair(
2525
destination_dir: A path to directory for storing artifacts (optional).
2626
2727
Returns:
28-
structs.KeyPair: A tuple containing the key pair.
28+
structs.KeyPair: A data container containing the key pair.
2929
"""
3030
destination_dir = pl.Path(destination_dir).expanduser()
3131
vkey = destination_dir / f"{node_name}_kes.vkey"
@@ -56,7 +56,7 @@ def gen_vrf_key_pair(
5656
destination_dir: A path to directory for storing artifacts (optional).
5757
5858
Returns:
59-
structs.KeyPair: A tuple containing the key pair.
59+
structs.KeyPair: A data container containing the key pair.
6060
"""
6161
destination_dir = pl.Path(destination_dir).expanduser()
6262
vkey = destination_dir / f"{node_name}_vrf.vkey"
@@ -87,7 +87,7 @@ def gen_cold_key_pair_and_counter(
8787
destination_dir: A path to directory for storing artifacts (optional).
8888
8989
Returns:
90-
structs.ColdKeyPair: A tuple containing the key pair and the counter.
90+
structs.ColdKeyPair: A data container containing the key pair and the counter.
9191
"""
9292
destination_dir = pl.Path(destination_dir).expanduser()
9393
vkey = destination_dir / f"{node_name}_cold.vkey"

cardano_clusterlib/query_group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def get_stake_addr_info(self, stake_addr: str) -> structs.StakeAddrInfo:
248248
stake_addr: A stake address string.
249249
250250
Returns:
251-
structs.StakeAddrInfo: A tuple containing stake address info.
251+
structs.StakeAddrInfo: A data container containing stake address info.
252252
"""
253253
output_json = json.loads(self.query_cli(["stake-address-info", "--address", stake_addr]))
254254
if not output_json:
@@ -433,7 +433,7 @@ def get_utxo_with_highest_amount(
433433
coin: A coin name (asset IDs).
434434
435435
Returns:
436-
structs.UTXOData: An UTxO record with the highest amount.
436+
structs.UTXOData: A UTxO record with the highest amount.
437437
"""
438438
utxo = self.get_utxo(address=address, coins=[coin])
439439
highest_amount_rec = max(utxo, key=lambda x: x.amount)

cardano_clusterlib/stake_address_group.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def gen_stake_key_pair(
139139
destination_dir: A path to directory for storing artifacts (optional).
140140
141141
Returns:
142-
structs.KeyPair: A tuple containing the key pair.
142+
structs.KeyPair: A data container containing the key pair.
143143
"""
144144
destination_dir = pl.Path(destination_dir).expanduser()
145145
vkey = destination_dir / f"{key_name}_stake.vkey"
@@ -485,7 +485,8 @@ def gen_stake_addr_and_keys(
485485
destination_dir: A path to directory for storing artifacts (optional).
486486
487487
Returns:
488-
structs.AddressRecord: A tuple containing the address and key pair / script file.
488+
structs.AddressRecord: A data container containing the address
489+
and key pair / script file.
489490
"""
490491
key_pair = self.gen_stake_key_pair(key_name=name, destination_dir=destination_dir)
491492
addr = self.gen_stake_addr(
@@ -535,8 +536,10 @@ def withdraw_reward(
535536
"""Withdraw reward to payment address.
536537
537538
Args:
538-
stake_addr_record: An `structs.AddressRecord` tuple for the stake address with reward.
539-
dst_addr_record: An `structs.AddressRecord` tuple for the destination payment address.
539+
stake_addr_record: A `structs.AddressRecord` data container for the stake address
540+
with reward.
541+
dst_addr_record: A `structs.AddressRecord` data container for the destination
542+
payment address.
540543
tx_name: A name of the transaction.
541544
verify: A bool indicating whether to verify that the reward was transferred correctly.
542545
destination_dir: A path to directory for storing artifacts (optional).

cardano_clusterlib/stake_pool_group.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def gen_pool_registration_cert(
4444
"""Generate a stake pool registration certificate.
4545
4646
Args:
47-
pool_data: A `structs.PoolData` tuple containing info about the stake pool.
47+
pool_data: A `structs.PoolData` data container containing info about the stake pool.
4848
vrf_vkey_file: A path to node VRF vkey file.
4949
cold_vkey_file: A path to pool cold vkey file.
5050
owner_stake_vkey_files: A list of paths to pool owner stake vkey files.
@@ -182,14 +182,14 @@ def create_stake_pool(
182182
"""Create and register a stake pool.
183183
184184
Args:
185-
pool_data: A `structs.PoolData` tuple containing info about the stake pool.
185+
pool_data: A `structs.PoolData` data container containing info about the stake pool.
186186
pool_owners: A list of `structs.PoolUser` structures containing pool user addresses
187187
and keys.
188188
tx_name: A name of the transaction.
189189
destination_dir: A path to directory for storing artifacts (optional).
190190
191191
Returns:
192-
structs.PoolCreationOutput: A tuple containing pool creation output.
192+
structs.PoolCreationOutput: A data container containing pool creation output.
193193
"""
194194
# Create the KES key pair
195195
node_kes = self._clusterlib_obj.g_node.gen_kes_key_pair(
@@ -249,11 +249,12 @@ def register_stake_pool(
249249
"""Register a stake pool.
250250
251251
Args:
252-
pool_data: A `structs.PoolData` tuple containing info about the stake pool.
252+
pool_data: A `structs.PoolData` data container containing info about the stake pool.
253253
pool_owners: A list of `structs.PoolUser` structures containing pool user addresses
254254
and keys.
255255
vrf_vkey_file: A path to node VRF vkey file.
256-
cold_key_pair: A `structs.ColdKeyPair` tuple containing the key pair and the counter.
256+
cold_key_pair: A `structs.ColdKeyPair` data container containing the key pair
257+
and the counter.
257258
tx_name: A name of the transaction.
258259
reward_account_vkey_file: A path to reward account vkey file (optional).
259260
deposit: A deposit amount needed by the transaction (optional).
@@ -307,14 +308,15 @@ def deregister_stake_pool(
307308
Args:
308309
pool_owners: A list of `structs.PoolUser` structures containing pool user addresses
309310
and keys.
310-
cold_key_pair: A `structs.ColdKeyPair` tuple containing the key pair and the counter.
311+
cold_key_pair: A `structs.ColdKeyPair` data container containing the key pair
312+
and the counter.
311313
epoch: An epoch where the update proposal will take effect (optional).
312314
pool_name: A name of the stake pool.
313315
tx_name: A name of the transaction.
314316
destination_dir: A path to directory for storing artifacts (optional).
315317
316318
Returns:
317-
Tuple[Path, structs.TxRawOutput]: A tuple with pool registration cert file and
319+
Tuple[Path, structs.TxRawOutput]: A data container with pool registration cert file and
318320
transaction output details.
319321
"""
320322
tx_name = f"{tx_name}_dereg_pool"

cardano_clusterlib/transaction_group.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ def get_tx_deposit(self, tx_files: structs.TxFiles) -> int:
139139
"""Get deposit amount for a transaction (based on certificates used for the TX).
140140
141141
Args:
142-
tx_files: A `structs.TxFiles` tuple containing files needed for the transaction.
142+
tx_files: A `structs.TxFiles` data container containing files needed
143+
for the transaction.
143144
144145
Returns:
145146
int: A total deposit amount needed for the transaction.
@@ -205,7 +206,8 @@ def build_raw_tx_bare( # noqa: C901
205206
Args:
206207
out_file: An output file.
207208
txouts: A list (iterable) of `TxOuts`, specifying transaction outputs.
208-
tx_files: A `structs.TxFiles` tuple containing files needed for the transaction.
209+
tx_files: A `structs.TxFiles` data container containing files needed
210+
for the transaction.
209211
fee: A fee amount.
210212
txins: An iterable of `structs.UTXOData`, specifying input UTxOs (optional).
211213
readonly_reference_txins: An iterable of `structs.UTXOData`, specifying input
@@ -239,7 +241,7 @@ def build_raw_tx_bare( # noqa: C901
239241
by payment address (True by default).
240242
241243
Returns:
242-
structs.TxRawOutput: A tuple with transaction output details.
244+
structs.TxRawOutput: A data container with transaction output details.
243245
"""
244246
if (treasury_donation is not None) != (current_treasury_value is not None):
245247
msg = (
@@ -444,7 +446,7 @@ def build_raw_tx(
444446
total_collateral_amount: An integer indicating the total amount of collateral
445447
(optional).
446448
mint: An iterable of `Mint`, specifying script minting data (optional).
447-
tx_files: A `structs.TxFiles` tuple containing files needed for the transaction
449+
tx_files: A `structs.TxFiles` data container containing files needed for the transaction
448450
(optional).
449451
complex_certs: An iterable of `ComplexCert`, specifying certificates script data
450452
(optional).
@@ -472,7 +474,7 @@ def build_raw_tx(
472474
destination_dir: A path to directory for storing artifacts (optional).
473475
474476
Returns:
475-
structs.TxRawOutput: A tuple with transaction output details.
477+
structs.TxRawOutput: A data container with transaction output details.
476478
"""
477479
destination_dir = pl.Path(destination_dir).expanduser()
478480
out_file = destination_dir / f"{tx_name}_tx.body"
@@ -631,7 +633,7 @@ def calculate_tx_fee(
631633
total_collateral_amount: An integer indicating the total amount of collateral
632634
(optional).
633635
mint: An iterable of `Mint`, specifying script minting data (optional).
634-
tx_files: A `structs.TxFiles` tuple containing files needed for the transaction
636+
tx_files: A `structs.TxFiles` data container containing files needed for the transaction
635637
(optional).
636638
complex_certs: An iterable of `ComplexCert`, specifying certificates script data
637639
(optional).
@@ -723,7 +725,7 @@ def calculate_min_req_utxo(
723725
txouts: A list of `TxOut` records that correspond to a single transaction output (UTxO).
724726
725727
Returns:
726-
structs.Value: A tuple describing the value.
728+
structs.Value: A data container describing the value.
727729
"""
728730
if not txouts:
729731
msg = "No txout was specified."
@@ -798,7 +800,7 @@ def build_tx( # noqa: C901
798800
total_collateral_amount: An integer indicating the total amount of collateral
799801
(optional).
800802
mint: An iterable of `Mint`, specifying script minting data (optional).
801-
tx_files: A `structs.TxFiles` tuple containing files needed for the transaction
803+
tx_files: A `structs.TxFiles` data container containing files needed for the transaction
802804
(optional).
803805
complex_certs: An iterable of `ComplexCert`, specifying certificates script data
804806
(optional).
@@ -831,7 +833,7 @@ def build_tx( # noqa: C901
831833
(`build` command balance the assets automatically in newer versions).
832834
833835
Returns:
834-
structs.TxRawOutput: A tuple with transaction output details.
836+
structs.TxRawOutput: A data container with transaction output details.
835837
"""
836838
max_txout = [o for o in txouts if o.amount == -1 and o.coin in ("", consts.DEFAULT_COIN)]
837839
if max_txout:
@@ -1266,7 +1268,7 @@ def send_tx(
12661268
total_collateral_amount: An integer indicating the total amount of collateral
12671269
(optional).
12681270
mint: An iterable of `Mint`, specifying script minting data (optional).
1269-
tx_files: A `structs.TxFiles` tuple containing files needed for the transaction
1271+
tx_files: A `structs.TxFiles` data container containing files needed for the transaction
12701272
(optional).
12711273
complex_certs: An iterable of `ComplexCert`, specifying certificates script data
12721274
(optional).
@@ -1297,7 +1299,7 @@ def send_tx(
12971299
destination_dir: A path to directory for storing artifacts (optional).
12981300
12991301
Returns:
1300-
structs.TxRawOutput: A tuple with transaction output details.
1302+
structs.TxRawOutput: A data container with transaction output details.
13011303
"""
13021304
tx_files = tx_files or structs.TxFiles()
13031305

@@ -1512,7 +1514,7 @@ def calculate_plutus_script_cost(
15121514
total_collateral_amount: An integer indicating the total amount of collateral
15131515
(optional).
15141516
mint: An iterable of `Mint`, specifying script minting data (optional).
1515-
tx_files: A `structs.TxFiles` tuple containing files needed for the transaction
1517+
tx_files: A `structs.TxFiles` data container containing files needed for the transaction
15161518
(optional).
15171519
complex_certs: An iterable of `ComplexCert`, specifying certificates script data
15181520
(optional).
@@ -1578,7 +1580,7 @@ def send_funds(
15781580
src_address: An address used for fee and inputs.
15791581
destinations: A list (iterable) of `TxOuts`, specifying transaction outputs.
15801582
tx_name: A name of the transaction.
1581-
tx_files: A `structs.TxFiles` tuple containing files needed for the transaction
1583+
tx_files: A `structs.TxFiles` data container containing files needed for the transaction
15821584
(optional).
15831585
fee: A fee amount (optional).
15841586
ttl: A last block when the transaction is still valid
@@ -1590,7 +1592,7 @@ def send_funds(
15901592
destination_dir: A path to directory for storing artifacts (optional).
15911593
15921594
Returns:
1593-
structs.TxRawOutput: A tuple with transaction output details.
1595+
structs.TxRawOutput: A data container with transaction output details.
15941596
"""
15951597
warnings.warn(
15961598
"`send_funds` is deprecated, use `send_tx` instead",

cardano_clusterlib/txtools.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def _pick_utxos_with_defragmentation(
131131
"""Pick UTxOs to meet or exceed the target amount while prioritizing defragmentation.
132132
133133
Args:
134-
utxos (list of tuple): A list of tuples (utxo_id, coin_amount).
134+
utxos (list of tuples): A list of tuples (utxo_id, coin_amount).
135135
target_amount (int): The desired amount.
136136
target_with_change (int): The desired amount with minimal change.
137137
accumulated_amount (int): The accumulated amount.
@@ -645,7 +645,7 @@ def _get_tx_ins_outs(
645645
Args:
646646
clusterlib_obj: An instance of `ClusterLib`.
647647
src_address: An address used for fee and inputs (if inputs not specified by `txins`).
648-
tx_files: A `structs.TxFiles` tuple containing files needed for the transaction.
648+
tx_files: A `structs.TxFiles` data container containing files needed for the transaction.
649649
txins: An iterable of `structs.UTXOData`, specifying input UTxOs (optional).
650650
txouts: A list (iterable) of `TxOuts`, specifying transaction outputs (optional).
651651
fee: A fee amount (optional).
@@ -771,7 +771,7 @@ def collect_data_for_build(
771771
txouts: A list (iterable) of `TxOuts`, specifying transaction outputs (optional).
772772
script_txins: An iterable of `ScriptTxIn`, specifying input script UTxOs (optional).
773773
mint: An iterable of `Mint`, specifying script minting data (optional).
774-
tx_files: A `structs.TxFiles` tuple containing files needed for the transaction
774+
tx_files: A `structs.TxFiles` data container containing files needed for the transaction
775775
(optional).
776776
complex_certs: An iterable of `ComplexCert`, specifying certificates script data
777777
(optional).
@@ -788,7 +788,7 @@ def collect_data_for_build(
788788
(`build` command balance the assets automatically in newer versions).
789789
790790
Returns:
791-
structs.DataForBuild: A tuple with data for build(-raw) commands.
791+
structs.DataForBuild: A data container with data for build(-raw) commands.
792792
"""
793793
tx_files = tx_files or structs.TxFiles()
794794

@@ -960,7 +960,7 @@ def filter_utxo_with_highest_amount(
960960
coin: A coin name (asset IDs).
961961
962962
Returns:
963-
structs.UTXOData: An UTxO record with the highest amount.
963+
structs.UTXOData: A UTxO record with the highest amount.
964964
"""
965965
filtered_utxos = [u for u in utxos if u.coin == coin]
966966
highest_amount_rec = max(filtered_utxos, key=lambda x: x.amount)

0 commit comments

Comments
 (0)