Skip to content

Commit 54214e1

Browse files
author
opendansor
committed
lint
1 parent c97a777 commit 54214e1

File tree

3 files changed

+56
-35
lines changed

3 files changed

+56
-35
lines changed

bittensor/commands/stake.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ def run(cli: "bittensor.cli"):
609609
@staticmethod
610610
def _run(cli: "bittensor.cli", subtensor: "bittensor.subtensor"):
611611
wallet = bittensor.wallet(config=cli.config)
612-
612+
613613
# Get values if not set.
614614
if not cli.config.is_set("netuid"):
615615
cli.config.netuid = int(Prompt.ask("Enter netuid"))
@@ -618,7 +618,12 @@ def _run(cli: "bittensor.cli", subtensor: "bittensor.subtensor"):
618618
cli.config.hotkey = Prompt.ask("Enter parent hotkey (ss58)")
619619

620620
# display children
621-
GetChildrenCommand.retrieve_children(subtensor=subtensor, hotkey=cli.config.hotkey, netuid=cli.config.netuid, render_table=True)
621+
GetChildrenCommand.retrieve_children(
622+
subtensor=subtensor,
623+
hotkey=cli.config.hotkey,
624+
netuid=cli.config.netuid,
625+
render_table=True,
626+
)
622627

623628
if not cli.config.is_set("children"):
624629
cli.config.children = Prompt.ask(
@@ -663,8 +668,12 @@ def _run(cli: "bittensor.cli", subtensor: "bittensor.subtensor"):
663668

664669
# Result
665670
if success:
666-
GetChildrenCommand.retrieve_children(subtensor=subtensor, hotkey=cli.config.hotkey,
667-
netuid=cli.config.netuid, render_table=True)
671+
GetChildrenCommand.retrieve_children(
672+
subtensor=subtensor,
673+
hotkey=cli.config.hotkey,
674+
netuid=cli.config.netuid,
675+
render_table=True,
676+
)
668677
console.print(
669678
":white_heavy_check_mark: [green]Set children hotkeys.[/green]"
670679
)
@@ -780,9 +789,11 @@ def _run(cli: "bittensor.cli", subtensor: "bittensor.subtensor"):
780789
GetChildrenCommand.render_table(subtensor, hotkey, children, netuid, True)
781790

782791
return children
783-
792+
784793
@staticmethod
785-
def retrieve_children(subtensor: "bittensor.subtensor", hotkey: str, netuid: int, render_table: bool):
794+
def retrieve_children(
795+
subtensor: "bittensor.subtensor", hotkey: str, netuid: int, render_table: bool
796+
):
786797
children = subtensor.get_children(hotkey, netuid)
787798
if render_table:
788799
GetChildrenCommand.render_table(subtensor, hotkey, children, netuid, False)
@@ -834,15 +845,19 @@ def render_table(
834845

835846
if not children:
836847
console.print(table)
837-
console.print(f"There are currently no child hotkeys on subnet {netuid} with ParentHotKey {hotkey}.")
848+
console.print(
849+
f"There are currently no child hotkeys on subnet {netuid} with ParentHotKey {hotkey}."
850+
)
838851
if prompt:
839852
command = f"btcli stake set_children --children <child_hotkey> --hotkey <parent_hotkey> --netuid {netuid} --proportion <float>"
840-
console.print(f"To add a child hotkey you can run the command: [white]{command}[/white]")
853+
console.print(
854+
f"To add a child hotkey you can run the command: [white]{command}[/white]"
855+
)
841856
return
842857

843858
console.print("ParentHotKey:", style="cyan", no_wrap=True)
844859
console.print(hotkey)
845-
860+
846861
# calculate totals
847862
total_proportion = 0
848863
total_stake = 0
@@ -867,7 +882,9 @@ def render_table(
867882

868883
# add the children info to the table
869884
for i, (proportion, hotkey, stake) in enumerate(children_info, 1):
870-
proportion_str = Text(str(proportion), style="red" if proportion == 0 else "")
885+
proportion_str = Text(
886+
str(proportion), style="red" if proportion == 0 else ""
887+
)
871888
hotkey = Text(hotkey, style="red" if proportion == 0 else "")
872889
table.add_row(
873890
str(i),
@@ -879,4 +896,3 @@ def render_table(
879896
# add totals row
880897
table.add_row("", "Total", str(total_proportion), str(total_stake), "")
881898
console.print(table)
882-

bittensor/commands/unstake.py

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,21 @@ def check_config(cls, config: "bittensor.config"):
6565
config.wallet.name = str(wallet_name)
6666

6767
if (
68-
not config.get("hotkey_ss58address", d=None)
69-
and not config.is_set("wallet.hotkey")
70-
and not config.no_prompt
71-
and not config.get("all_hotkeys")
72-
and not config.get("hotkeys")
68+
not config.get("hotkey_ss58address", d=None)
69+
and not config.is_set("wallet.hotkey")
70+
and not config.no_prompt
71+
and not config.get("all_hotkeys")
72+
and not config.get("hotkeys")
7373
):
7474
hotkey = Prompt.ask("Enter hotkey name", default=defaults.wallet.hotkey)
7575
config.wallet.hotkey = str(hotkey)
7676

7777
# Get amount.
7878
if (
79-
not config.get("hotkey_ss58address")
80-
and not config.get("amount")
81-
and not config.get("unstake_all")
82-
and not config.get("max_stake")
79+
not config.get("hotkey_ss58address")
80+
and not config.get("amount")
81+
and not config.get("unstake_all")
82+
and not config.get("max_stake")
8383
):
8484
hotkeys: str = ""
8585
if config.get("all_hotkeys"):
@@ -270,13 +270,13 @@ def _run(cli: "bittensor.cli", subtensor: "bittensor.subtensor"):
270270
# Ask to unstake
271271
if not cli.config.no_prompt:
272272
if not Confirm.ask(
273-
f"Do you want to unstake from the following keys to {wallet.name}:\n"
274-
+ "".join(
275-
[
276-
f" [bold white]- {hotkey[0] + ':' if hotkey[0] else ''}{hotkey[1]}: {f'{amount} {bittensor.__tao_symbol__}' if amount else 'All'}[/bold white]\n"
277-
for hotkey, amount in zip(final_hotkeys, final_amounts)
278-
]
279-
)
273+
f"Do you want to unstake from the following keys to {wallet.name}:\n"
274+
+ "".join(
275+
[
276+
f" [bold white]- {hotkey[0] + ':' if hotkey[0] else ''}{hotkey[1]}: {f'{amount} {bittensor.__tao_symbol__}' if amount else 'All'}[/bold white]\n"
277+
for hotkey, amount in zip(final_hotkeys, final_amounts)
278+
]
279+
)
280280
):
281281
return None
282282

@@ -345,8 +345,12 @@ def _run(cli: "bittensor.cli", subtensor: "bittensor.subtensor"):
345345
cli.config.hotkey = Prompt.ask("Enter parent hotkey (ss58)")
346346

347347
# Get and display current children information
348-
current_children = GetChildrenCommand.retrieve_children(subtensor=subtensor, hotkey=cli.config.hotkey,
349-
netuid=cli.config.netuid, render_table=False)
348+
current_children = GetChildrenCommand.retrieve_children(
349+
subtensor=subtensor,
350+
hotkey=cli.config.hotkey,
351+
netuid=cli.config.netuid,
352+
render_table=False,
353+
)
350354

351355
# Parse from strings
352356
netuid = cli.config.netuid
@@ -367,9 +371,12 @@ def _run(cli: "bittensor.cli", subtensor: "bittensor.subtensor"):
367371
# Result
368372
if success:
369373
if cli.config.wait_for_finalization and cli.config.wait_for_inclusion:
370-
GetChildrenCommand.retrieve_children(subtensor=subtensor, hotkey=cli.config.hotkey,
371-
netuid=cli.config.netuid,
372-
render_table=True)
374+
GetChildrenCommand.retrieve_children(
375+
subtensor=subtensor,
376+
hotkey=cli.config.hotkey,
377+
netuid=cli.config.netuid,
378+
render_table=True,
379+
)
373380
console.print(
374381
":white_heavy_check_mark: [green]Revoked all children hotkeys.[/green]"
375382
)

bittensor/subtensor.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3253,9 +3253,7 @@ def query_runtime_api(
32533253
"""
32543254
call_definition = bittensor.__type_registry__["runtime_api"][runtime_api][ # type: ignore
32553255
"methods" # type: ignore
3256-
][
3257-
method
3258-
] # type: ignore
3256+
][method] # type: ignore
32593257

32603258
json_result = self.state_call(
32613259
method=f"{runtime_api}_{method}",

0 commit comments

Comments
 (0)