From 1ce3344ea3f4cc7fa20952dc92bcea446455da71 Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Fri, 8 Aug 2025 20:07:44 +0200 Subject: [PATCH] Better handles situations in which users may type something besides an int for the optional netuid. --- bittensor_cli/cli.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index c26defd6d..6fddc03dd 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -410,10 +410,15 @@ def get_optional_netuid(netuid: Optional[int], all_netuids: bool) -> Optional[in ) if answer is None: return None + answer = answer.strip() if answer.lower() == "all": return None else: - return int(answer) + try: + return int(answer) + except ValueError: + err_console.print(f"Invalid netuid: {answer}") + return get_optional_netuid(None, False) else: return netuid