Skip to content

Commit 8842af5

Browse files
committed
Corrected import order, ran ruff.
1 parent bc6dfa0 commit 8842af5

File tree

6 files changed

+173
-78
lines changed

6 files changed

+173
-78
lines changed

bittensor_cli/cli.py

+133-46
Original file line numberDiff line numberDiff line change
@@ -389,54 +389,119 @@ def __init__(self):
389389
self.config_app.command("metagraph")(self.metagraph_config)
390390

391391
# wallet commands
392-
self.wallet_app.command("list", rich_help_panel=HELP_PANELS["WALLET"]["MANAGEMENT"])(self.wallet_list)
393-
self.wallet_app.command("regen-coldkey", rich_help_panel=HELP_PANELS["WALLET"]["SECURITY"])(self.wallet_regen_coldkey)
394-
self.wallet_app.command("regen-coldkeypub", rich_help_panel=HELP_PANELS["WALLET"]["SECURITY"])(self.wallet_regen_coldkey_pub)
395-
self.wallet_app.command("regen-hotkey", rich_help_panel=HELP_PANELS["WALLET"]["SECURITY"])(self.wallet_regen_hotkey)
396-
self.wallet_app.command("new-hotkey", rich_help_panel=HELP_PANELS["WALLET"]["MANAGEMENT"])(self.wallet_new_hotkey)
397-
self.wallet_app.command("new-coldkey", rich_help_panel=HELP_PANELS["WALLET"]["MANAGEMENT"])(self.wallet_new_coldkey)
398-
self.wallet_app.command("create", rich_help_panel=HELP_PANELS["WALLET"]["MANAGEMENT"])(self.wallet_create_wallet)
399-
self.wallet_app.command("balance", rich_help_panel=HELP_PANELS["WALLET"]["INFORMATION"])(self.wallet_balance)
400-
self.wallet_app.command("history", rich_help_panel=HELP_PANELS["WALLET"]["INFORMATION"])(self.wallet_history)
401-
self.wallet_app.command("overview", rich_help_panel=HELP_PANELS["WALLET"]["INFORMATION"])(self.wallet_overview)
402-
self.wallet_app.command("transfer", rich_help_panel=HELP_PANELS["WALLET"]["OPERATIONS"])(self.wallet_transfer)
403-
self.wallet_app.command("inspect", rich_help_panel=HELP_PANELS["WALLET"]["INFORMATION"])(self.wallet_inspect)
404-
self.wallet_app.command("faucet", rich_help_panel=HELP_PANELS["WALLET"]["OPERATIONS"])(self.wallet_faucet)
405-
self.wallet_app.command("set-identity", rich_help_panel=HELP_PANELS["WALLET"]["IDENTITY"])(self.wallet_set_id)
406-
self.wallet_app.command("get-identity", rich_help_panel=HELP_PANELS["WALLET"]["IDENTITY"])(self.wallet_get_id)
407-
self.wallet_app.command("check-swap", rich_help_panel=HELP_PANELS["WALLET"]["SECURITY"])(self.wallet_check_ck_swap)
408-
self.wallet_app.command("sign", rich_help_panel=HELP_PANELS["WALLET"]["OPERATIONS"])(self.wallet_sign)
392+
self.wallet_app.command(
393+
"list", rich_help_panel=HELP_PANELS["WALLET"]["MANAGEMENT"]
394+
)(self.wallet_list)
395+
self.wallet_app.command(
396+
"regen-coldkey", rich_help_panel=HELP_PANELS["WALLET"]["SECURITY"]
397+
)(self.wallet_regen_coldkey)
398+
self.wallet_app.command(
399+
"regen-coldkeypub", rich_help_panel=HELP_PANELS["WALLET"]["SECURITY"]
400+
)(self.wallet_regen_coldkey_pub)
401+
self.wallet_app.command(
402+
"regen-hotkey", rich_help_panel=HELP_PANELS["WALLET"]["SECURITY"]
403+
)(self.wallet_regen_hotkey)
404+
self.wallet_app.command(
405+
"new-hotkey", rich_help_panel=HELP_PANELS["WALLET"]["MANAGEMENT"]
406+
)(self.wallet_new_hotkey)
407+
self.wallet_app.command(
408+
"new-coldkey", rich_help_panel=HELP_PANELS["WALLET"]["MANAGEMENT"]
409+
)(self.wallet_new_coldkey)
410+
self.wallet_app.command(
411+
"create", rich_help_panel=HELP_PANELS["WALLET"]["MANAGEMENT"]
412+
)(self.wallet_create_wallet)
413+
self.wallet_app.command(
414+
"balance", rich_help_panel=HELP_PANELS["WALLET"]["INFORMATION"]
415+
)(self.wallet_balance)
416+
self.wallet_app.command(
417+
"history", rich_help_panel=HELP_PANELS["WALLET"]["INFORMATION"]
418+
)(self.wallet_history)
419+
self.wallet_app.command(
420+
"overview", rich_help_panel=HELP_PANELS["WALLET"]["INFORMATION"]
421+
)(self.wallet_overview)
422+
self.wallet_app.command(
423+
"transfer", rich_help_panel=HELP_PANELS["WALLET"]["OPERATIONS"]
424+
)(self.wallet_transfer)
425+
self.wallet_app.command(
426+
"inspect", rich_help_panel=HELP_PANELS["WALLET"]["INFORMATION"]
427+
)(self.wallet_inspect)
428+
self.wallet_app.command(
429+
"faucet", rich_help_panel=HELP_PANELS["WALLET"]["OPERATIONS"]
430+
)(self.wallet_faucet)
431+
self.wallet_app.command(
432+
"set-identity", rich_help_panel=HELP_PANELS["WALLET"]["IDENTITY"]
433+
)(self.wallet_set_id)
434+
self.wallet_app.command(
435+
"get-identity", rich_help_panel=HELP_PANELS["WALLET"]["IDENTITY"]
436+
)(self.wallet_get_id)
437+
self.wallet_app.command(
438+
"check-swap", rich_help_panel=HELP_PANELS["WALLET"]["SECURITY"]
439+
)(self.wallet_check_ck_swap)
440+
self.wallet_app.command(
441+
"sign", rich_help_panel=HELP_PANELS["WALLET"]["OPERATIONS"]
442+
)(self.wallet_sign)
409443

410444
# root commands
411445
self.root_app.command("list")(self.root_list)
412-
self.root_app.command("set-weights", rich_help_panel=HELP_PANELS["ROOT"]["WEIGHT_MGMT"])(self.root_set_weights)
413-
self.root_app.command("get-weights", rich_help_panel=HELP_PANELS["ROOT"]["WEIGHT_MGMT"])(self.root_get_weights)
414-
self.root_app.command("boost", rich_help_panel=HELP_PANELS["ROOT"]["WEIGHT_MGMT"])(self.root_boost)
415-
self.root_app.command("slash", rich_help_panel=HELP_PANELS["ROOT"]["WEIGHT_MGMT"])(self.root_slash)
416-
self.root_app.command("senate", rich_help_panel=HELP_PANELS["ROOT"]["GOVERNANCE"])(self.root_senate)
417-
self.root_app.command("senate-vote", rich_help_panel=HELP_PANELS["ROOT"]["GOVERNANCE"])(self.root_senate_vote)
446+
self.root_app.command(
447+
"set-weights", rich_help_panel=HELP_PANELS["ROOT"]["WEIGHT_MGMT"]
448+
)(self.root_set_weights)
449+
self.root_app.command(
450+
"get-weights", rich_help_panel=HELP_PANELS["ROOT"]["WEIGHT_MGMT"]
451+
)(self.root_get_weights)
452+
self.root_app.command(
453+
"boost", rich_help_panel=HELP_PANELS["ROOT"]["WEIGHT_MGMT"]
454+
)(self.root_boost)
455+
self.root_app.command(
456+
"slash", rich_help_panel=HELP_PANELS["ROOT"]["WEIGHT_MGMT"]
457+
)(self.root_slash)
458+
self.root_app.command(
459+
"senate", rich_help_panel=HELP_PANELS["ROOT"]["GOVERNANCE"]
460+
)(self.root_senate)
461+
self.root_app.command(
462+
"senate-vote", rich_help_panel=HELP_PANELS["ROOT"]["GOVERNANCE"]
463+
)(self.root_senate_vote)
418464
self.root_app.command("register")(self.root_register)
419-
self.root_app.command("proposals", rich_help_panel=HELP_PANELS["ROOT"]["GOVERNANCE"])(self.root_proposals)
420-
self.root_app.command("set-take", rich_help_panel=HELP_PANELS["ROOT"]["DELEGATION"])(self.root_set_take)
421-
self.root_app.command("delegate-stake", rich_help_panel=HELP_PANELS["ROOT"]["DELEGATION"])(self.root_delegate_stake)
422-
self.root_app.command("undelegate-stake", rich_help_panel=HELP_PANELS["ROOT"]["DELEGATION"])(self.root_undelegate_stake)
423-
self.root_app.command("my-delegates", rich_help_panel=HELP_PANELS["ROOT"]["DELEGATION"])(self.root_my_delegates)
424-
self.root_app.command("list-delegates", rich_help_panel=HELP_PANELS["ROOT"]["DELEGATION"])(self.root_list_delegates)
425-
self.root_app.command("nominate", rich_help_panel=HELP_PANELS["ROOT"]["GOVERNANCE"])(self.root_nominate)
465+
self.root_app.command(
466+
"proposals", rich_help_panel=HELP_PANELS["ROOT"]["GOVERNANCE"]
467+
)(self.root_proposals)
468+
self.root_app.command(
469+
"set-take", rich_help_panel=HELP_PANELS["ROOT"]["DELEGATION"]
470+
)(self.root_set_take)
471+
self.root_app.command(
472+
"delegate-stake", rich_help_panel=HELP_PANELS["ROOT"]["DELEGATION"]
473+
)(self.root_delegate_stake)
474+
self.root_app.command(
475+
"undelegate-stake", rich_help_panel=HELP_PANELS["ROOT"]["DELEGATION"]
476+
)(self.root_undelegate_stake)
477+
self.root_app.command(
478+
"my-delegates", rich_help_panel=HELP_PANELS["ROOT"]["DELEGATION"]
479+
)(self.root_my_delegates)
480+
self.root_app.command(
481+
"list-delegates", rich_help_panel=HELP_PANELS["ROOT"]["DELEGATION"]
482+
)(self.root_list_delegates)
483+
self.root_app.command(
484+
"nominate", rich_help_panel=HELP_PANELS["ROOT"]["GOVERNANCE"]
485+
)(self.root_nominate)
426486

427487
# stake commands
428-
self.stake_app.command("show", rich_help_panel=HELP_PANELS["STAKE"]["STAKE_MGMT"])(self.stake_show)
429-
self.stake_app.command("add", rich_help_panel=HELP_PANELS["STAKE"]["STAKE_MGMT"])(self.stake_add)
430-
self.stake_app.command("remove", rich_help_panel=HELP_PANELS["STAKE"]["STAKE_MGMT"])(self.stake_remove)
488+
self.stake_app.command(
489+
"show", rich_help_panel=HELP_PANELS["STAKE"]["STAKE_MGMT"]
490+
)(self.stake_show)
491+
self.stake_app.command(
492+
"add", rich_help_panel=HELP_PANELS["STAKE"]["STAKE_MGMT"]
493+
)(self.stake_add)
494+
self.stake_app.command(
495+
"remove", rich_help_panel=HELP_PANELS["STAKE"]["STAKE_MGMT"]
496+
)(self.stake_remove)
431497

432498
# stake-children commands
433499
children_app = typer.Typer()
434500
self.stake_app.add_typer(
435501
children_app,
436502
name="child",
437503
short_help="Child Hotkey commands, alias: `children`",
438-
rich_help_panel=HELP_PANELS["STAKE"]["CHILD"]
439-
504+
rich_help_panel=HELP_PANELS["STAKE"]["CHILD"],
440505
)
441506
self.stake_app.add_typer(children_app, name="children", hidden=True)
442507
children_app.command("get")(self.stake_get_children)
@@ -445,21 +510,43 @@ def __init__(self):
445510
children_app.command("take")(self.stake_childkey_take)
446511

447512
# sudo commands
448-
self.sudo_app.command("set", rich_help_panel=HELP_PANELS["SUDO"]["CONFIG"])(self.sudo_set)
449-
self.sudo_app.command("get", rich_help_panel=HELP_PANELS["SUDO"]["CONFIG"])(self.sudo_get)
513+
self.sudo_app.command("set", rich_help_panel=HELP_PANELS["SUDO"]["CONFIG"])(
514+
self.sudo_set
515+
)
516+
self.sudo_app.command("get", rich_help_panel=HELP_PANELS["SUDO"]["CONFIG"])(
517+
self.sudo_get
518+
)
450519

451520
# subnets commands
452-
self.subnets_app.command("hyperparameters", rich_help_panel=HELP_PANELS["SUBNETS"]["INFO"])(self.sudo_get)
453-
self.subnets_app.command("list", rich_help_panel=HELP_PANELS["SUBNETS"]["INFO"])(self.subnets_list)
454-
self.subnets_app.command("lock-cost", rich_help_panel=HELP_PANELS["SUBNETS"]["CREATION"])(self.subnets_lock_cost)
455-
self.subnets_app.command("create", rich_help_panel=HELP_PANELS["SUBNETS"]["CREATION"])(self.subnets_create)
456-
self.subnets_app.command("pow-register", rich_help_panel=HELP_PANELS["SUBNETS"]["REGISTER"])(self.subnets_pow_register)
457-
self.subnets_app.command("register", rich_help_panel=HELP_PANELS["SUBNETS"]["REGISTER"])(self.subnets_register)
458-
self.subnets_app.command("metagraph", rich_help_panel=HELP_PANELS["SUBNETS"]["INFO"])(self.subnets_metagraph)
521+
self.subnets_app.command(
522+
"hyperparameters", rich_help_panel=HELP_PANELS["SUBNETS"]["INFO"]
523+
)(self.sudo_get)
524+
self.subnets_app.command(
525+
"list", rich_help_panel=HELP_PANELS["SUBNETS"]["INFO"]
526+
)(self.subnets_list)
527+
self.subnets_app.command(
528+
"lock-cost", rich_help_panel=HELP_PANELS["SUBNETS"]["CREATION"]
529+
)(self.subnets_lock_cost)
530+
self.subnets_app.command(
531+
"create", rich_help_panel=HELP_PANELS["SUBNETS"]["CREATION"]
532+
)(self.subnets_create)
533+
self.subnets_app.command(
534+
"pow-register", rich_help_panel=HELP_PANELS["SUBNETS"]["REGISTER"]
535+
)(self.subnets_pow_register)
536+
self.subnets_app.command(
537+
"register", rich_help_panel=HELP_PANELS["SUBNETS"]["REGISTER"]
538+
)(self.subnets_register)
539+
self.subnets_app.command(
540+
"metagraph", rich_help_panel=HELP_PANELS["SUBNETS"]["INFO"]
541+
)(self.subnets_metagraph)
459542

460543
# weights commands
461-
self.weights_app.command("reveal", rich_help_panel=HELP_PANELS["WEIGHTS"]["COMMIT_REVEAL"])(self.weights_reveal)
462-
self.weights_app.command("commit", rich_help_panel=HELP_PANELS["WEIGHTS"]["COMMIT_REVEAL"])(self.weights_commit)
544+
self.weights_app.command(
545+
"reveal", rich_help_panel=HELP_PANELS["WEIGHTS"]["COMMIT_REVEAL"]
546+
)(self.weights_reveal)
547+
self.weights_app.command(
548+
"commit", rich_help_panel=HELP_PANELS["WEIGHTS"]["COMMIT_REVEAL"]
549+
)(self.weights_commit)
463550

464551
def initialize_chain(
465552
self,

bittensor_cli/src/bittensor/extrinsics/transfer.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import asyncio
22

3+
from bittensor_wallet import Wallet
4+
from rich.prompt import Confirm
5+
36
from bittensor_cli.src import NETWORK_EXPLORER_MAP
47
from bittensor_cli.src.bittensor.balances import Balance
58
from bittensor_cli.src.subtensor_interface import SubtensorInterface
@@ -10,8 +13,6 @@
1013
get_explorer_url_for_network,
1114
is_valid_bittensor_address_or_public_key,
1215
)
13-
from bittensor_wallet import Wallet
14-
from rich.prompt import Confirm
1516

1617

1718
async def transfer_extrinsic(

bittensor_cli/src/commands/root.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22
import json
33
from typing import Optional, TypedDict, cast
44

5+
from bittensor_wallet import Wallet
56
import numpy as np
7+
from numpy.typing import NDArray
8+
from rich import box
9+
from rich.prompt import Confirm
10+
from rich.table import Column, Table
11+
from rich.text import Text
12+
from scalecodec import GenericCall, ScaleType
613
import typer
14+
715
from bittensor_cli.src import Constants, DelegatesDetails
816
from bittensor_cli.src.bittensor.balances import Balance
917
from bittensor_cli.src.bittensor.chain_data import DelegateInfo, NeuronInfoLite
@@ -28,14 +36,6 @@
2836
ss58_to_vec_u8,
2937
update_metadata_table,
3038
)
31-
from bittensor_wallet import Wallet
32-
from numpy.typing import NDArray
33-
from rich import box
34-
from rich.prompt import Confirm
35-
from rich.table import Column, Table
36-
from rich.text import Text
37-
from scalecodec import GenericCall, ScaleType
38-
from substrateinterface.exceptions import SubstrateRequestException
3939

4040
# helpers
4141

@@ -966,10 +966,8 @@ async def set_boost(
966966
):
967967
"""Boosts weight of a given netuid for root network."""
968968

969-
my_uid = (
970-
await subtensor.substrate.query(
971-
"SubtensorModule", "Uids", [0, wallet.hotkey.ss58_address]
972-
)
969+
my_uid = await subtensor.substrate.query(
970+
"SubtensorModule", "Uids", [0, wallet.hotkey.ss58_address]
973971
)
974972
if my_uid is None:
975973
err_console.print("Your hotkey is not registered to the root network")

bittensor_cli/src/commands/subnets.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
from textwrap import dedent
55
from typing import TYPE_CHECKING, Optional, cast
66

7+
from bittensor_wallet import Wallet
8+
from rich.prompt import Confirm
9+
from rich.table import Column, Table
10+
711
from bittensor_cli.src import Constants, DelegatesDetails
812
from bittensor_cli.src.bittensor.balances import Balance
913
from bittensor_cli.src.bittensor.chain_data import SubnetInfo
@@ -23,9 +27,6 @@
2327
render_table,
2428
update_metadata_table,
2529
)
26-
from bittensor_wallet import Wallet
27-
from rich.prompt import Confirm
28-
from rich.table import Column, Table
2930

3031
if TYPE_CHECKING:
3132
from bittensor_cli.src.subtensor_interface import SubtensorInterface

bittensor_cli/src/commands/sudo.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import asyncio
22
from typing import TYPE_CHECKING, Union
33

4-
from bittensor_cli.src import HYPERPARAMS
5-
from bittensor_cli.src.utils import console, err_console, normalize_hyperparameters
64
from bittensor_wallet import Wallet
75
from rich import box
86
from rich.table import Column, Table
97

8+
from bittensor_cli.src import HYPERPARAMS
9+
from bittensor_cli.src.utils import console, err_console, normalize_hyperparameters
10+
1011
if TYPE_CHECKING:
1112
from bittensor_cli.src.subtensor_interface import SubtensorInterface
1213

bittensor_cli/src/commands/wallets.py

+20-13
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,19 @@
77
from typing import Any, Collection, Generator, Optional
88

99
import aiohttp
10+
from bittensor_wallet import Wallet
11+
from bittensor_wallet.errors import KeyFileError
12+
from bittensor_wallet.keyfile import Keyfile
13+
from fuzzywuzzy import fuzz
14+
from rich import box
15+
from rich.align import Align
16+
from rich.prompt import Confirm, Prompt
17+
from rich.table import Column, Table
18+
from rich.tree import Tree
19+
from scalecodec import ScaleBytes
1020
import scalecodec
1121
import typer
22+
1223
from bittensor_cli.src import TYPE_REGISTRY, Constants, DelegatesDetails, utils
1324
from bittensor_cli.src.bittensor.balances import Balance
1425
from bittensor_cli.src.bittensor.chain_data import (
@@ -34,16 +45,6 @@
3445
get_delegates_details_from_github,
3546
get_hotkey_wallets_for_wallet,
3647
)
37-
from bittensor_wallet import Wallet
38-
from bittensor_wallet.errors import KeyFileError
39-
from bittensor_wallet.keyfile import Keyfile
40-
from fuzzywuzzy import fuzz
41-
from rich import box
42-
from rich.align import Align
43-
from rich.prompt import Confirm, Prompt
44-
from rich.table import Column, Table
45-
from rich.tree import Tree
46-
from scalecodec import ScaleBytes
4748

4849

4950
async def regen_coldkey(
@@ -71,7 +72,9 @@ async def regen_coldkey(
7172

7273

7374
async def regen_coldkey_pub(
74-
wallet: Wallet, ss58_address: str, public_key_hex: str,
75+
wallet: Wallet,
76+
ss58_address: str,
77+
public_key_hex: str,
7578
):
7679
"""Creates a new coldkeypub under this wallet."""
7780
wallet.regenerate_coldkeypub(
@@ -108,7 +111,9 @@ async def regen_hotkey(
108111

109112

110113
async def new_hotkey(
111-
wallet: Wallet, n_words: int, use_password: bool,
114+
wallet: Wallet,
115+
n_words: int,
116+
use_password: bool,
112117
):
113118
"""Creates a new hotkey under this wallet."""
114119
wallet.create_new_hotkey(
@@ -119,7 +124,9 @@ async def new_hotkey(
119124

120125

121126
async def new_coldkey(
122-
wallet: Wallet, n_words: int, use_password: bool,
127+
wallet: Wallet,
128+
n_words: int,
129+
use_password: bool,
123130
):
124131
"""Creates a new coldkey under this wallet."""
125132
wallet.create_new_coldkey(

0 commit comments

Comments
 (0)