summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJosh Ferrell <josh@vector35.com>2025-05-23 17:26:11 -0400
committerJosh Ferrell <josh@vector35.com>2025-05-23 17:26:11 -0400
commit6248965db87082e5f27a5f222a63d8eddeafe6fc (patch)
tree19bcba611eea6e5bea1ccdf5619a72b0564a0151 /python
parent71ca9eb697f58b44023ddac06659d46e37e37361 (diff)
Fix ChoiceField docs, add .default getter/setter
Diffstat (limited to 'python')
-rw-r--r--python/interaction.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/python/interaction.py b/python/interaction.py
index 6fa41e6a..c1c55095 100644
--- a/python/interaction.py
+++ b/python/interaction.py
@@ -267,10 +267,11 @@ class ChoiceField:
``ChoiceField`` prompts the user to choose from the list of strings provided in ``choices``. Result is stored \
in self.result as an index in to the choices array.
- :attr str prompt: prompt to be presented to the user
- :attr list(str) choices: list of choices to choose from
+ :param str prompt: Prompt to be presented to the user
+ :param list(str) choices: List of choices to choose from
+ :param Optional[int] default: Optional index into choices that will be selected by default
"""
- def __init__(self, prompt: str, choices: List[str], default: Optional[str] = None):
+ def __init__(self, prompt: str, choices: List[str], default: Optional[int] = None):
self._prompt = prompt
self._choices = choices
self._default = default
@@ -295,27 +296,35 @@ class ChoiceField:
self._result = value.indexResult
@property
- def prompt(self):
+ def prompt(self) -> str:
return self._prompt
@prompt.setter
- def prompt(self, value):
+ def prompt(self, value: str):
self._prompt = value
@property
- def choices(self):
+ def choices(self) -> List[str]:
return self._choices
@choices.setter
- def choices(self, value):
+ def choices(self, value: List[str]):
self._choices = value
@property
- def result(self):
+ def default(self) -> Optional[int]:
+ return self._default
+
+ @default.setter
+ def default(self, value: Optional[int]):
+ self._default = value
+
+ @property
+ def result(self) -> Optional[int]:
return self._result
@result.setter
- def result(self, value):
+ def result(self, value: int):
self._result = value