Skip to content

Commit 6248965

Browse files
committed
Fix ChoiceField docs, add .default getter/setter
1 parent 71ca9eb commit 6248965

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

python/interaction.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,11 @@ class ChoiceField:
267267
``ChoiceField`` prompts the user to choose from the list of strings provided in ``choices``. Result is stored \
268268
in self.result as an index in to the choices array.
269269
270-
:attr str prompt: prompt to be presented to the user
271-
:attr list(str) choices: list of choices to choose from
270+
:param str prompt: Prompt to be presented to the user
271+
:param list(str) choices: List of choices to choose from
272+
:param Optional[int] default: Optional index into choices that will be selected by default
272273
"""
273-
def __init__(self, prompt: str, choices: List[str], default: Optional[str] = None):
274+
def __init__(self, prompt: str, choices: List[str], default: Optional[int] = None):
274275
self._prompt = prompt
275276
self._choices = choices
276277
self._default = default
@@ -295,27 +296,35 @@ def _get_result(self, value):
295296
self._result = value.indexResult
296297

297298
@property
298-
def prompt(self):
299+
def prompt(self) -> str:
299300
return self._prompt
300301

301302
@prompt.setter
302-
def prompt(self, value):
303+
def prompt(self, value: str):
303304
self._prompt = value
304305

305306
@property
306-
def choices(self):
307+
def choices(self) -> List[str]:
307308
return self._choices
308309

309310
@choices.setter
310-
def choices(self, value):
311+
def choices(self, value: List[str]):
311312
self._choices = value
312313

313314
@property
314-
def result(self):
315+
def default(self) -> Optional[int]:
316+
return self._default
317+
318+
@default.setter
319+
def default(self, value: Optional[int]):
320+
self._default = value
321+
322+
@property
323+
def result(self) -> Optional[int]:
315324
return self._result
316325

317326
@result.setter
318-
def result(self, value):
327+
def result(self, value: int):
319328
self._result = value
320329

321330

0 commit comments

Comments
 (0)