Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
frankharkins committed Dec 2, 2024
1 parent fd671aa commit 1407d38
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions qiskit_ibm_runtime/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import argparse
import sys
from getpass import getpass
from typing import List, Literal, Callable
from typing import List, Literal, Callable, TypeVar

from ibm_cloud_sdk_core.api_exception import ApiException

Expand All @@ -28,6 +28,7 @@
from .accounts.exceptions import AccountAlreadyExistsError

Channel = Literal["ibm_quantum", "ibm_cloud"]
T = TypeVar("T")


def entry_point() -> None:
Expand Down Expand Up @@ -146,7 +147,7 @@ def get_instance(cls, service: QiskitRuntimeService) -> str:
return select_from_list(instances)

@classmethod
def save_to_disk(cls, account):
def save_to_disk(cls, account: dict) -> None:
"""
Save account details to disk, confirming if they'd like to overwrite if
one exists already. Display a warning that token is stored in plain
Expand Down Expand Up @@ -175,7 +176,7 @@ def save_to_disk(cls, account):
)


def user_input(message: str, is_valid: Callable[[str], bool]):
def user_input(message: str, is_valid: Callable[[str], bool]) -> str:
"""
Repeatedly ask user for input until they give us something that satisifies
`is_valid`.
Expand All @@ -189,7 +190,7 @@ def user_input(message: str, is_valid: Callable[[str], bool]):
print("Did not understand input, trying again... (type 'quit' to quit)")


def select_from_list(options: List[str]) -> str:
def select_from_list(options: List[T]) -> T:
"""
Prompt user to select from a list of options by entering a number.
"""
Expand All @@ -203,7 +204,7 @@ def select_from_list(options: List[str]) -> str:
and int(response) in range(1, len(options) + 1),
)
choice = options[int(response) - 1]
print(f"Selected {Format.greenbold(choice)}")
print(f"Selected {Format.greenbold(str(choice))}")
return choice


Expand Down

0 comments on commit 1407d38

Please sign in to comment.