8000 Update prompt.py · TheCompuGuru/botbuilder-python@e455fbb · GitHub
[go: up one dir, main page]

Skip to content

Commit e455fbb

Browse files
author
Michael Miele
committed
Update prompt.py
Fixed style
1 parent 11f398b commit e455fbb

File tree

1 file changed

+33
-25
lines changed
  • libraries/botbuilder-dialogs/botbuilder/dialogs/prompts

1 file changed

+33
-25
lines changed

libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/prompt.py

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@
2424

2525
class Prompt(Dialog):
2626
"""
27+
2728
Defines the core behavior of prompt dialogs. Extends the :class:`Dialog` base class.
2829
2930
.. remarks::
31+
3032
When the prompt ends, it returns an object that represents the value it was prompted for.
31-
Use :meth:`DialogSet.add()` or :meth:`ComponentDialog.add_dialog()` to add a prompt to a dialog set or
32-
component dialog, respectively.
33+
Use :meth:`DialogSet.add()` or :meth:`ComponentDialog.add_dialog()` to add a prompt to
34+
a dialog set or component dialog, respectively.
3335
Use :meth:`DialogContext.prompt()` or :meth:`DialogContext.begin_dialog()` to start the prompt.
34-
If you start a prompt from a :class:`WaterfallStep` in a :class:`WaterfallDialog`, then the prompt result
35-
will be available in the next step of the waterfall.
36+
If you start a prompt from a :class:`WaterfallStep` in a :class:`WaterfallDialog`, then the
37+
prompt result will be available in the next step of the waterfall.
38+
3639
"""
3740

3841
ATTEMPT_COUNT_KEY = "AttemptCount"
@@ -63,13 +66,13 @@ async def begin_dialog(
6366
:param dialog_context: The dialog context for the current turn of the conversation
6467
:type dialog_context: :class:`DialogContext`
6568
:param options: Optional, additional information to pass to the prompt being started
66-
:type options: Object
69+
:type options: object
6770
:return: The dialog turn result
6871
:rtype: :class:`DialogTurnResult`
6972
7073
.. note::
71-
If the task is successful, the result indicates whether the prompt is still active
72-
after the turn has been processed.
74+
75+
If the task is successful, the result indicates whether the prompt is still active after the turn has been processed.
7376
"""
7477
if not dialog_context:
7578
raise TypeError("Prompt(): dc cannot be None.")
@@ -111,6 +114,7 @@ async def continue_dialog(self, dialog_context: DialogContext):
111114
active after the turn has been processed by the dialog.
112115
The prompt generally continues to receive the user's replies until it accepts the
113116
user's reply as valid input for the prompt.
117+
114118
"""
115119
if not dialog_context:
116120
raise TypeError("Prompt(): dc cannot be None.")
@@ -150,26 +154,29 @@ async def resume_dialog(
150154
self, dialog_context: DialogContext, reason: DialogReason, result: object
151155
) -> DialogTurnResult:
152156
"""
153-
Resumes a dialog. C
157+
Resumes a dialog.
158+
154159
:param dialog_context: The dialog context for the current turn of the conversation.
155-
:type dialog_context: :class:DialogContext
160+
:type dialog_context: :class:`DialogContext`
156161
:param reason: An enum indicating why the dialog resumed.
157-
:type reason: :class:DialogReason
162+
:type reason: :class:`DialogReason`
158163
:param result: Optional, value returned from the previous dialog on the stack.
159164
The type of the value returned is dependent on the previous dialog.
160165
:type result: object
161166
:return: The dialog turn result
162167
:rtype: :class:`DialogTurnResult`
163168
164169
.. remarks::
170+
165171
Called when a prompt dialog resumes being the active dialog on the dialog stack,
166172
such as when the previous active dialog on the stack completes.
167173
If the task is successful, the result indicates whether the dialog is still
168174
active after the turn has been processed by the dialog.
169175
Prompts are typically leaf nodes on the stack but the dev is free to push other dialogs
170176
on top of the stack which will result in the prompt receiving an unexpected call to
171177
:meth:resume_dialog() when the pushed on dialog ends.
172-
To avoid the prompt prematurely ending we need to simply re-prompt the user.
178+
Simply re-prompt the user to avoid that the prompt ends prematurely.
179+
173180
"""
174181
await self.reprompt_dialog(dialog_context.context, dialog_context.active_dialog)
175182
return Dialog.end_of_turn
@@ -179,11 +186,11 @@ async def reprompt_dialog(self, context: TurnContext, instance: DialogInstance):
179186
Reprompts user for input. Called when a prompt dialog has been requested to re-prompt the user for input.
180187
181188
:param context: Context for the current turn of conversation with the user
182-
:type context: :class:TurnContext
189+
:type context: :class:`botbuilder.core.TurnContext`
183190
:param instance: The instance of the dialog on the stack
184-
:type instance: :class:DialogInstance
185-
:return: A :class:Task representing the asynchronous operation
186-
:rtype: :class:Task
191+
:type instance: :class:`DialogInstance`
192+
:return: A task representing the asynchronous operation
193+
187194
"""
188195
state = instance.state[self.persisted_state]
189196
options = instance.state[self.persisted_options]
@@ -203,16 +210,16 @@ async def on_prompt(
203210
:param turn_context: Context for the current turn of conversation with the user
204211
:type turn_context: :class:`botbuilder.core.TurnContext`
205212
:param state: Contains state for the current instance of the prompt on the dialog stack
206-
:type state: :class:Dict
213+
:type state: :class:`Dict`
207214
:param options: A prompt options object constructed from the options initially provided
208-
in the call :meth:`DialogContext.prompt(self, dialog_id: str, options)`
215+
in the call :meth:`DialogContext.prompt()`
209216
:type options: :class:`PromptOptions`
210217
:param is_retry: true if this is the first time this prompt dialog instance on the stack is prompting
211218
the user for input; otherwise, false
212219
:type is_retry: bool
213220
214-
:return: A :class:Task representing the asynchronous operation.
215-
:rtype: :class:Task
221+
:return: A task representing the asynchronous operation.
222+
216223
"""
217224

218225
@abstractmethod
@@ -228,13 +235,13 @@ async def on_recognize(
228235
:param turn_context: Context for the current turn of conversation with the user
229236
:type turn_context: :class:`botbuilder.core.TurnContext`
230237
:param state: Contains state for the current instance of the prompt on the dialog stack
231-
:type state: :class:Dict
238+
:type state: :class:`Dict`
232239
:param options: A prompt options object constructed from the options initially provided
233-
in the call :meth:`DialogContext.prompt(self, dialog_id: str, options)`
234-
:type options: :class:PromptOptions
240+
in the call to :meth:`DialogContext.prompt()`
241+
:type options: :class:`PromptOptions`
235242
236243
:return: A task representing the asynchronous operation.
237-
:rtype: :class:Task
244+
238245
"""
239246

240247
def append_choices(
@@ -258,14 +265,15 @@ def append_choices(
258265
:type style: :class:`ListStyle`
259266
:param: options: Optional formatting options to use when presenting the choices
260267
:type style: :class:`ChoiceFactoryOptions`
261-
:return: A :class:Task representing the asynchronous operation
262-
:rtype: :class:Task
268+
269+
:return: A task representing the asynchronous operation
263270
264271
.. remarks::
265272
If the task is successful, the result contains the updated activity.
266273
When overridden in a derived class, appends choices to the activity when the user
267274
is prompted for input. This is an helper function to compose an output activity
268275
containing a set of choices.
276+
269277
"""
270278
# Get base prompt text (if any)
271279
text = prompt.text if prompt is not None and prompt.text else ""

0 commit comments

Comments
 (0)
0