Skip to content

Commit 334f188

Browse files
authored
Merge pull request #653 from opentensor/fix/thewhaleking/type-annotations-fixes
2 parents fdf3cca + 33e6dcd commit 334f188

File tree

8 files changed

+28
-22
lines changed

8 files changed

+28
-22
lines changed

bittensor_cli/cli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3658,7 +3658,6 @@ def get_auto_stake(
36583658
self.initialize_chain(network),
36593659
coldkey_ss58=coldkey_ss58,
36603660
json_output=json_output,
3661-
verbose=verbose,
36623661
)
36633662
)
36643663

bittensor_cli/src/commands/liquidity/liquidity.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ async def show_liquidity_list(
458458
wallet: "Wallet",
459459
netuid: int,
460460
json_output: bool = False,
461-
):
461+
) -> None:
462462
current_price_, (success, err_msg, positions) = await asyncio.gather(
463463
subtensor.subnet(netuid=netuid), get_liquidity_list(subtensor, wallet, netuid)
464464
)
@@ -467,10 +467,10 @@ async def show_liquidity_list(
467467
json_console.print(
468468
json.dumps({"success": success, "err_msg": err_msg, "positions": []})
469469
)
470-
return False
470+
return
471471
else:
472472
err_console.print(f"Error: {err_msg}")
473-
return False
473+
return
474474
liquidity_table = Table(
475475
Column("ID", justify="center"),
476476
Column("Liquidity", justify="center"),
@@ -535,10 +535,10 @@ async def remove_liquidity(
535535
prompt: Optional[bool] = None,
536536
all_liquidity_ids: Optional[bool] = None,
537537
json_output: bool = False,
538-
) -> tuple[bool, str]:
538+
) -> None:
539539
"""Remove liquidity position from provided subnet."""
540540
if not await subtensor.subnet_exists(netuid=netuid):
541-
return False, f"Subnet with netuid: {netuid} does not exist in {subtensor}."
541+
return None
542542

543543
if all_liquidity_ids:
544544
success, msg, positions = await get_liquidity_list(subtensor, wallet, netuid)
@@ -549,7 +549,7 @@ async def remove_liquidity(
549549
)
550550
else:
551551
return err_console.print(f"Error: {msg}")
552-
return False, msg
552+
return None
553553
else:
554554
position_ids = [p.id for p in positions]
555555
else:
@@ -563,7 +563,7 @@ async def remove_liquidity(
563563
console.print(f"\tPosition id: {pos}")
564564

565565
if not Confirm.ask("Would you like to continue?"):
566-
return False, "User cancelled operation."
566+
return None
567567

568568
results = await asyncio.gather(
569569
*[
@@ -593,6 +593,7 @@ async def remove_liquidity(
593593
"extrinsic_identifier": await ext_receipt.get_extrinsic_identifier(),
594594
}
595595
json_console.print_json(data=json_table)
596+
return None
596597

597598

598599
async def modify_liquidity(

bittensor_cli/src/commands/liquidity/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,5 @@ def prompt_position_id() -> int:
198198
return position_id
199199
except ValueError:
200200
console.print("[red]Please enter a valid number[/red].")
201+
# will never return this, but fixes the type checker
202+
return 0

bittensor_cli/src/commands/stake/add.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import asyncio
2-
import json
32
from collections import defaultdict
43
from functools import partial
54

@@ -349,7 +348,7 @@ async def stake_extrinsic(
349348
f"[red]Not enough stake[/red]:[bold white]\n wallet balance:{remaining_wallet_balance} < "
350349
f"staking amount: {amount_to_stake}[/bold white]"
351350
)
352-
return False
351+
return
353352
remaining_wallet_balance -= amount_to_stake
354353

355354
# Calculate slippage
@@ -432,9 +431,9 @@ async def stake_extrinsic(
432431

433432
if prompt:
434433
if not Confirm.ask("Would you like to continue?"):
435-
return False
434+
return
436435
if not unlock_key(wallet).success:
437-
return False
436+
return
438437

439438
if safe_staking:
440439
stake_coroutines = {}
@@ -537,6 +536,8 @@ def _prompt_stake_amount(
537536
return Balance.from_tao(amount), False
538537
except ValueError:
539538
console.print("[red]Please enter a valid number or 'all'[/red]")
539+
# will never return this, but fixes the type checker
540+
return Balance(0), False
540541

541542

542543
def _get_hotkeys_to_stake_to(

bittensor_cli/src/commands/stake/auto_staking.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ async def show_auto_stake_destinations(
2828
subtensor: "SubtensorInterface",
2929
coldkey_ss58: Optional[str] = None,
3030
json_output: bool = False,
31-
verbose: bool = False,
3231
) -> Optional[dict[int, dict[str, Optional[str]]]]:
3332
"""Display auto-stake destinations for the supplied wallet."""
3433

bittensor_cli/src/commands/stake/move.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ def prompt_stake_amount(
201201
return Balance.from_tao(amount), False
202202
except ValueError:
203203
console.print("[red]Please enter a valid number or 'all'[/red]")
204+
# can never return this, but fixes the type checker
205+
return Balance(0), False
204206

205207

206208
async def stake_move_transfer_selection(
@@ -818,14 +820,16 @@ async def swap_stake(
818820
wait_for_finalization (bool): If true, waits for the transaction to be finalized.
819821
820822
Returns:
821-
bool: True if the swap was successful, False otherwise.
823+
(success, extrinsic_identifier):
824+
success is True if the swap was successful, False otherwise.
825+
extrinsic_identifier if the extrinsic was successfully included
822826
"""
823827
hotkey_ss58 = get_hotkey_pub_ss58(wallet)
824828
if interactive_selection:
825829
try:
826830
selection = await stake_swap_selection(subtensor, wallet)
827831
except ValueError:
828-
return False
832+
return False, ""
829833
origin_netuid = selection["origin_netuid"]
830834
amount = selection["amount"]
831835
destination_netuid = selection["destination_netuid"]

bittensor_cli/src/commands/stake/remove.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ async def unstake_all(
370370
era: int = 3,
371371
prompt: bool = True,
372372
json_output: bool = False,
373-
) -> bool:
373+
) -> None:
374374
"""Unstakes all stakes from all hotkeys in all subnets."""
375375
include_hotkeys = include_hotkeys or []
376376
exclude_hotkeys = exclude_hotkeys or []
@@ -419,7 +419,7 @@ async def unstake_all(
419419

420420
if not stake_info:
421421
console.print("[red]No stakes found to unstake[/red]")
422-
return False
422+
return
423423

424424
all_sn_dynamic_info = {info.netuid: info for info in all_sn_dynamic_info_}
425425

@@ -531,10 +531,10 @@ async def unstake_all(
531531
if prompt and not Confirm.ask(
532532
"\nDo you want to proceed with unstaking everything?"
533533
):
534-
return False
534+
return
535535

536536
if not unlock_key(wallet).success:
537-
return False
537+
return
538538
successes = {}
539539
with console.status("Unstaking all stakes...") as status:
540540
for hotkey_ss58 in hotkey_ss58s:
@@ -553,7 +553,7 @@ async def unstake_all(
553553
"extrinsic_identifier": ext_id,
554554
}
555555
if json_output:
556-
return json_console.print(json.dumps({"success": successes}))
556+
json_console.print(json.dumps({"success": successes}))
557557

558558

559559
# Extrinsics

bittensor_cli/src/commands/wallets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,8 @@ async def wallet_balance(
594594
subtensor.get_total_stake_for_coldkey(*coldkeys, block_hash=block_hash),
595595
)
596596

597-
total_free_balance = sum(free_balances.values())
598-
total_staked_balance = sum(stake[0] for stake in staked_balances.values())
597+
total_free_balance: Balance = sum(free_balances.values())
598+
total_staked_balance: Balance = sum(stake[0] for stake in staked_balances.values())
599599

600600
balances = {
601601
name: (

0 commit comments

Comments
 (0)