Skip to content

Commit dacb11e

Browse files
edit docstrings
1 parent b78498c commit dacb11e

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

bittensor/core/async_subtensor.py

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,19 @@ def __init__(
149149
"""Initializes an AsyncSubtensor instance for blockchain interaction.
150150
151151
Arguments:
152-
network: The network name or type to connect to (e.g., "finney", "test"). If `None`, uses the default
152+
network: The network name or type to connect to (e.g., "finney", "test"). If ``None``, uses the default
153153
network from config.
154-
config: Configuration object for the AsyncSubtensor instance. If `None`, uses the default configuration.
155-
log_verbose: Enables or disables verbose logging. Defaults to `False`.
154+
config: Configuration object for the AsyncSubtensor instance. If ``None``, uses the default configuration.
155+
log_verbose: Enables or disables verbose logging. Defaults to ``False``.
156156
fallback_endpoints: List of fallback endpoints to use if default or provided network is not available.
157-
Defaults to `None`.
158-
retry_forever: Whether to retry forever on connection errors. Defaults to `False`.
159-
_mock: Whether this is a mock instance. Mainly for testing purposes. Defaults to `False`.
157+
Defaults to ``None``.
158+
retry_forever: Whether to retry forever on connection errors. Defaults to ``False``.
159+
_mock: Whether this is a mock instance. Mainly for testing purposes. Defaults to ``False``.
160160
archive_endpoints: Similar to fallback_endpoints, but specifically only archive nodes. Will be used in
161161
cases where you are requesting a block that is too old for your current (presumably lite) node.
162-
Defaults to `None`.
162+
Defaults to ``None``.
163163
websocket_shutdown_timer: Amount of time, in seconds, to wait after the last response from the chain to
164-
close the connection. Defaults to `5.0`.
164+
close the connection. Defaults to ``5.0``.
165165
Returns:
166166
None
167167
@@ -330,7 +330,7 @@ async def determine_block_hash(
330330
# Ensure that only one of the parameters is specified.
331331
if sum(bool(x) for x in [block, block_hash, reuse_block]) > 1:
332332
raise ValueError(
333-
"Only one of `block`, `block_hash`, or `reuse_block` can be specified."
333+
"Only one of ``block``, ``block_hash``, or ``reuse_block`` can be specified."
334334
)
335335

336336
# Return the appropriate value.
@@ -462,12 +462,12 @@ def _get_substrate(
462462
463463
Arguments:
464464
fallback_endpoints: List of fallback endpoints to use if default or provided network is not available.
465-
Defaults to `None`.
466-
retry_forever: Whether to retry forever on connection errors. Defaults to `False`.
467-
_mock: Whether this is a mock instance. Mainly for testing purposes. Defaults to `False`.
465+
Defaults to ``None``.
466+
retry_forever: Whether to retry forever on connection errors. Defaults to ``False``.
467+
_mock: Whether this is a mock instance. Mainly for testing purposes. Defaults to ``False``.
468468
archive_endpoints: Similar to fallback_endpoints, but specifically only archive nodes. Will be used in
469469
cases where you are requesting a block that is too old for your current (presumably lite) node. Defaults
470-
to `None`.
470+
to ``None``.
471471
ws_shutdown_timer: Amount of time, in seconds, to wait after the last response from the chain to close
472472
the connection.
473473
@@ -521,10 +521,10 @@ async def query_constant(
521521
reuse_block.
522522
block_hash: The hash of the blockchain block at which to query the constant. Do not specify if using
523523
block or reuse_block.
524-
reuse_block: Whether to reuse the blockchain block at which to query the constant. Defaults to `False`.
524+
reuse_block: Whether to reuse the blockchain block at which to query the constant. Defaults to ``False``.
525525
526526
Returns:
527-
Optional[async_substrate_interface.types.ScaleObj]: The value of the constant if found, `None` otherwise.
527+
Optional[async_substrate_interface.types.ScaleObj]: The value of the constant if found, ``None`` otherwise.
528528
529529
Example:
530530
# Get existential deposit constant
@@ -565,12 +565,12 @@ async def query_map(
565565
Arguments:
566566
module: The name of the module from which to query the map storage (e.g., "SubtensorModule", "System").
567567
name: The specific storage function within the module to query (e.g., "Bonds", "Weights").
568-
block: The blockchain block number at which to perform the query. Defaults to `None` (latest block).
568+
block: The blockchain block number at which to perform the query. Defaults to ``None`` (latest block).
569569
block_hash: The hash of the block to retrieve the parameter from. Do not specify if using block or
570570
reuse_block.
571571
reuse_block: Whether to use the last-used block. Do not set if using block_hash or block. Defaults to
572-
`False`.
573-
params: Parameters to be passed to the query. Defaults to `None`.
572+
``False``.
573+
params: Parameters to be passed to the query. Defaults to ``None``.
574574
575575
Returns:
576576
AsyncQueryMapResult: A data structure representing the map storage if found, None otherwise.
@@ -613,7 +613,7 @@ async def query_map_subtensor(
613613
params: A list of parameters to pass to the query function.
614614
615615
Returns:
616-
An object containing the map-like data structure, or `None` if not found.
616+
An object containing the map-like data structure, or ``None`` if not found.
617617
618618
This function is particularly useful for analyzing and understanding complex network structures and
619619
relationships within the Bittensor ecosystem, such as interneuronal connections and stake distributions.
@@ -650,7 +650,7 @@ async def query_module(
650650
params: A list of parameters to pass to the query function.
651651
652652
Returns:
653-
An object containing the requested data if found, `None` otherwise.
653+
An object containing the requested data if found, ``None`` otherwise.
654654
655655
This versatile query function is key to accessing a wide range of data and insights from different parts of the
656656
Bittensor blockchain, enhancing the understanding and analysis of the network's state and dynamics.
@@ -687,7 +687,7 @@ async def query_runtime_api(
687687
reuse_block: Whether to reuse the last-used block hash. Do not set if using block_hash or block.
688688
689689
Returns:
690-
The decoded result from the runtime API call, or `None` if the call fails.
690+
The decoded result from the runtime API call, or ``None`` if the call fails.
691691
692692
This function enables access to the deeper layers of the Bittensor blockchain, allowing for detailed and
693693
specific interactions with the network's runtime environment.
@@ -856,7 +856,7 @@ async def blocks_since_last_step(
856856
return query.value if query is not None and hasattr(query, "value") else query
857857

858858
async def blocks_since_last_update(self, netuid: int, uid: int) -> Optional[int]:
859-
"""Returns the number of blocks since the last update, or `None` if the subnetwork or UID does not exist.
859+
"""Returns the number of blocks since the last update, or ``None`` if the subnetwork or UID does not exist.
860860
861861
Arguments:
862862
netuid: The unique identifier of the subnetwork.
@@ -1267,7 +1267,7 @@ async def get_block_hash(self, block: Optional[int] = None) -> str:
12671267
the trustworthiness of the blockchain.
12681268
12691269
Arguments:
1270-
block: The block number for which the hash is to be retrieved. If `None`, returns the latest block hash.
1270+
block: The block number for which the hash is to be retrieved. If ``None``, returns the latest block hash.
12711271
12721272
Returns:
12731273
str: The cryptographic hash of the specified block.
@@ -1572,7 +1572,7 @@ async def get_revealed_commitment_by_hotkey(
15721572
15731573
Arguments:
15741574
netuid: The unique identifier of the subnetwork.
1575-
block: The block number to retrieve the commitment from. Default is `None`.
1575+
block: The block number to retrieve the commitment from. Default is ``None``.
15761576
hotkey_ss58_address: The ss58 address of the committee member.
15771577
block_hash: The hash of the block to retrieve the subnet unique identifiers from.
15781578
reuse_block: Whether to reuse the last-used block hash.
@@ -1606,7 +1606,7 @@ async def get_revealed_commitment(
16061606
Arguments:
16071607
netuid: The unique identifier of the subnetwork.
16081608
uid: The neuron uid to retrieve the commitment from.
1609-
block: The block number to retrieve the commitment from. Default is `None`.
1609+
block: The block number to retrieve the commitment from. Default is ``None``.
16101610
16111611
Returns:
16121612
result (Optional[tuple[int, str]]: A tuple of reveal block and commitment message.
@@ -1639,7 +1639,7 @@ async def get_all_revealed_commitments(
16391639
16401640
Arguments:
16411641
netuid: The unique identifier of the subnetwork.
1642-
block: The block number to retrieve the commitment from. Default is `None`.
1642+
block: The block number to retrieve the commitment from. Default is ``None``.
16431643
block_hash: The hash of the block to retrieve the subnet unique identifiers from.
16441644
reuse_block: Whether to reuse the last-used block hash.
16451645
@@ -1682,7 +1682,7 @@ async def get_current_weight_commit_info(
16821682
16831683
Arguments:
16841684
netuid: The unique identifier of the subnet.
1685-
block: The blockchain block number for the query. Default is `None`.
1685+
block: The blockchain block number for the query. Default is ``None``.
16861686
block_hash: The hash of the block to retrieve the subnet unique identifiers from.
16871687
reuse_block: Whether to reuse the last-used block hash.
16881688
@@ -1714,13 +1714,13 @@ async def get_delegate_by_hotkey(
17141714
comprehensive view of the delegate's status, including its stakes, nominators, and reward distribution.
17151715
17161716
Arguments:
1717-
hotkey_ss58: The `SS58` address of the delegate's hotkey.
1717+
hotkey_ss58: The ``SS58`` address of the delegate's hotkey.
17181718
block: The blockchain block number for the query.
17191719
block_hash: The hash of the block to retrieve the subnet unique identifiers from.
17201720
reuse_block: Whether to reuse the last-used block hash.
17211721
17221722
Returns:
1723-
Optional[DelegateInfo]: Detailed information about the delegate neuron, `None` if not found.
1723+
Optional[DelegateInfo]: Detailed information about the delegate neuron, ``None`` if not found.
17241724
17251725
This function is essential for understanding the roles and influence of delegate neurons within the Bittensor
17261726
network's consensus and governance structures.
@@ -1818,7 +1818,7 @@ async def get_delegated(
18181818
delegates that a specific account has staked tokens on.
18191819
18201820
Arguments:
1821-
coldkey_ss58: The `SS58` address of the account's coldkey.
1821+
coldkey_ss58: The ``SS58`` address of the account's coldkey.
18221822
block: The blockchain block number for the query.
18231823
block_hash: The hash of the blockchain block number for the query.
18241824
reuse_block: Whether to reuse the last-used blockchain block hash.
@@ -1887,7 +1887,7 @@ async def get_existential_deposit(
18871887
18881888
Arguments:
18891889
block: The blockchain block number for the query.
1890-
block_hash: Block hash at which to query the deposit amount. If `None`, the current block is used.
1890+
block_hash: Block hash at which to query the deposit amount. If ``None``, the current block is used.
18911891
reuse_block: Whether to reuse the last-used blockchain block hash.
18921892
18931893
Returns:
@@ -2025,7 +2025,7 @@ async def get_metagraph_info(
20252025
]
20262026
else:
20272027
raise ValueError(
2028-
"`field_indices` must be a list of SelectiveMetagraphIndex enums or ints."
2028+
"``field_indices`` must be a list of SelectiveMetagraphIndex enums or ints."
20292029
)
20302030

20312031
query = await self.substrate.runtime_call(
@@ -2135,7 +2135,7 @@ async def get_neuron_certificate(
21352135
reuse_block: Whether to use the last-used block. Do not set if using block_hash or block.
21362136
21372137
Returns:
2138-
the certificate of the neuron if found, `None` otherwise.
2138+
the certificate of the neuron if found, ``None`` otherwise.
21392139
21402140
This function is used for certificate discovery for setting up mutual tls communication between neurons.
21412141
"""
@@ -2372,15 +2372,15 @@ async def get_neuron_for_pubkey_and_subnet(
23722372
network.
23732373
23742374
Arguments:
2375-
hotkey: The `SS58` address of the neuron's hotkey.
2375+
hotkey: The ``SS58`` address of the neuron's hotkey.
23762376
netuid: The unique identifier of the subnet.
23772377
block: The blockchain block number for the query.
23782378
block_hash: The blockchain block number at which to perform the query.
23792379
reuse_block: Whether to reuse the last-used blockchain block hash.
23802380
23812381
Returns:
23822382
Optional[bittensor.core.chain_data.neuron_info.NeuronInfo]: Detailed information about the neuron if found,
2383-
`None` otherwise.
2383+
``None`` otherwise.
23842384
23852385
This function is crucial for accessing specific neuron data and understanding its status, stake, and other
23862386
attributes within a particular subnet of the Bittensor ecosystem.
@@ -2414,7 +2414,7 @@ async def get_next_epoch_start_block(
24142414
"""
24152415
Calculates the first block number of the next epoch for the given subnet.
24162416
2417-
If `block` is not provided, the current chain block will be used. Epochs are
2417+
If ``block`` is not provided, the current chain block will be used. Epochs are
24182418
determined based on the subnet's tempo (i.e., blocks per epoch). The result
24192419
is the block number at which the next epoch will begin.
24202420
@@ -2770,7 +2770,7 @@ async def get_stake_for_coldkey_and_hotkey(
27702770
Arguments:
27712771
coldkey_ss58: The SS58 address of the coldkey.
27722772
hotkey_ss58: The SS58 address of the hotkey.
2773-
netuids: The subnet IDs to query for. Set to `None` for all subnets.
2773+
netuids: The subnet IDs to query for. Set to ``None`` for all subnets.
27742774
block: The block number at which to query the stake information.
27752775
block_hash: The hash of the block to retrieve the stake from. Do not specify if using block
27762776
or reuse_block
@@ -2821,7 +2821,7 @@ async def get_stake_for_coldkey(
28212821
reuse_block: Whether to reuse the last-used block hash.
28222822
28232823
Returns:
2824-
Optional[list[StakeInfo]]: A list of StakeInfo objects, or `None` if no stake information is found.
2824+
Optional[list[StakeInfo]]: A list of StakeInfo objects, or ``None`` if no stake information is found.
28252825
"""
28262826
result = await self.query_runtime_api(
28272827
runtime_api="StakeInfoRuntimeApi",
@@ -2926,7 +2926,7 @@ async def get_subnet_hyperparameters(
29262926
reuse_block: Whether to reuse the last-used blockchain hash.
29272927
29282928
Returns:
2929-
The subnet's hyperparameters, or `None` if not available.
2929+
The subnet's hyperparameters, or ``None`` if not available.
29302930
29312931
Understanding the hyperparameters is crucial for comprehending how subnets are configured and managed, and how
29322932
they interact with the network's consensus and incentive mechanisms.
@@ -3028,7 +3028,7 @@ async def get_transfer_fee(
30283028
30293029
Arguments:
30303030
wallet: The wallet from which the transfer is initiated.
3031-
dest: The `SS58` address of the destination account.
3031+
dest: The ``SS58`` address of the destination account.
30323032
value: The amount of tokens to be transferred, specified as a Balance object, or in Tao (float) or Rao
30333033
(int) units.
30343034
@@ -3076,7 +3076,7 @@ async def get_vote_data(
30763076
reuse_block: Whether to reuse the last-used blockchain block hash.
30773077
30783078
Returns:
3079-
An object containing the proposal's voting data, or `None` if not found.
3079+
An object containing the proposal's voting data, or ``None`` if not found.
30803080
30813081
This function is important for tracking and understanding the decision-making processes within the Bittensor
30823082
network, particularly how proposals are received and acted upon by the governing body.
@@ -3114,7 +3114,7 @@ async def get_uid_for_hotkey_on_subnet(
31143114
reuse_block: Whether to reuse the last-used blockchain block hash.
31153115
31163116
Returns:
3117-
Optional[int]: The UID of the neuron if it is registered on the subnet, `None` otherwise.
3117+
Optional[int]: The UID of the neuron if it is registered on the subnet, ``None`` otherwise.
31183118
31193119
The UID is a critical identifier within the network, linking the neuron's hotkey to its operational and
31203120
governance activities on a particular subnet.
@@ -3205,7 +3205,7 @@ async def immunity_period(
32053205
reuse_block: Whether to reuse the last-used blockchain block hash.
32063206
32073207
Returns:
3208-
Optional[int]: The value of the 'ImmunityPeriod' hyperparameter if the subnet exists, `None` otherwise.
3208+
Optional[int]: The value of the 'ImmunityPeriod' hyperparameter if the subnet exists, ``None`` otherwise.
32093209
32103210
The 'ImmunityPeriod' is a critical aspect of the network's governance system, ensuring that new participants
32113211
have a grace period to establish themselves and contribute to the network without facing immediate
@@ -3244,7 +3244,7 @@ async def is_hotkey_delegate(
32443244
reuse_block: Whether to reuse the last-used block hash.
32453245
32463246
Returns:
3247-
`True` if the hotkey is a delegate, `False` otherwise.
3247+
``True`` if the hotkey is a delegate, ``False`` otherwise.
32483248
32493249
Being a delegate is a significant status within the Bittensor network, indicating a neuron's involvement in
32503250
consensus and governance processes.
@@ -3271,7 +3271,7 @@ async def is_hotkey_registered(
32713271
32723272
Arguments:
32733273
hotkey_ss58: The SS58 address of the neuron's hotkey.
3274-
netuid: The unique identifier of the subnet to check the registration. If `None`, the
3274+
netuid: The unique identifier of the subnet to check the registration. If ``None``, the
32753275
registration is checked across all subnets.
32763276
block: The blockchain block number at which to perform the query.
32773277
block_hash: The blockchain block_hash representation of the block id. Do not specify if using block or
@@ -3280,8 +3280,8 @@ async def is_hotkey_registered(
32803280
reuse_block.
32813281
32823282
Returns:
3283-
bool: `True` if the hotkey is registered in the specified context (either any subnet or a specific subnet),
3284-
`False` otherwise.
3283+
bool: ``True`` if the hotkey is registered in the specified context (either any subnet or a specific subnet),
3284+
``False`` otherwise.
32853285
32863286
This function is important for verifying the active status of neurons in the Bittensor network. It aids in
32873287
understanding whether a neuron is eligible to participate in network processes such as consensus,
@@ -3313,7 +3313,7 @@ async def is_hotkey_registered_any(
33133313
reuse_block: Whether to reuse the last-used block hash.
33143314
33153315
Returns:
3316-
bool: `True` if the hotkey is registered on any subnet, False otherwise.
3316+
bool: ``True`` if the hotkey is registered on any subnet, False otherwise.
33173317
33183318
This function is essential for determining the network-wide presence and participation of a neuron.
33193319
"""

0 commit comments

Comments
 (0)