Skip to content

Commit 305527f

Browse files
More type annotations.
1 parent 33be12f commit 305527f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1386
-923
lines changed

examples/dialogs/button_dialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def main():
1616
('No', False),
1717
('Maybe...', None),
1818
],
19-
)
19+
).run()
2020

2121
print('Result = {}'.format(result))
2222

examples/dialogs/input_dialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
def main():
1111
result = input_dialog(
1212
title='Input dialog example',
13-
text='Please type your name:')
13+
text='Please type your name:').run()
1414

1515
print('Result = {}'.format(result))
1616

examples/dialogs/messagebox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
def main():
1111
message_dialog(
1212
title='Example dialog window',
13-
text='Do you want to continue?\nPress ENTER to quit.')
13+
text='Do you want to continue?\nPress ENTER to quit.').run()
1414

1515

1616
if __name__ == '__main__':

examples/dialogs/password_dialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def main():
1111
result = input_dialog(
1212
title='Password dialog example',
1313
text='Please type your password:',
14-
password=True)
14+
password=True).run()
1515

1616
print('Result = {}'.format(result))
1717

examples/dialogs/progress_dialog.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,14 @@ def worker(set_percentage, log_text):
3434
# Show 100% for a second, before quitting.
3535
set_percentage(100)
3636
time.sleep(1)
37-
return
3837

3938

4039
def main():
4140
progress_dialog(
4241
title='Progress dialog example',
4342
text='As an examples, we walk through the filesystem and print '
4443
'all directories',
45-
run_callback=worker)
44+
run_callback=worker).run()
4645

4746

4847
if __name__ == '__main__':

examples/dialogs/radio_dialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def main():
3030
('orange', HTML('<style bg="orange" fg="white">Orange</style>')),
3131
],
3232
title=HTML('Radiolist dialog example <reverse>with colors</reverse>'),
33-
text='Please select a color:')
33+
text='Please select a color:').run()
3434

3535
print('Result = {}'.format(result))
3636

examples/dialogs/styled_messagebox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def main():
2727
title=HTML('<style bg="blue" fg="white">Styled</style> '
2828
'<style fg="ansired">dialog</style> window'),
2929
text='Do you want to continue?\nPress ENTER to quit.',
30-
style=example_style)
30+
style=example_style).run()
3131

3232

3333
if __name__ == '__main__':

examples/dialogs/yes_no_dialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
def main():
1111
result = yes_no_dialog(
1212
title='Yes/No dialog example',
13-
text='Do you want to confirm?')
13+
text='Do you want to confirm?').run()
1414

1515
print('Result = {}'.format(result))
1616

examples/full-screen/text-editor.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
from __future__ import unicode_literals
66

77
import datetime
8+
from asyncio import Future, ensure_future
89

910
from prompt_toolkit.application import Application
1011
from prompt_toolkit.application.current import get_app
1112
from prompt_toolkit.completion import PathCompleter
12-
from prompt_toolkit.eventloop import From, Future, Return, ensure_future
1313
from prompt_toolkit.filters import Condition
1414
from prompt_toolkit.key_binding import KeyBindings
1515
from prompt_toolkit.layout.containers import (
@@ -159,14 +159,14 @@ def _(event):
159159
#
160160

161161
def do_open_file():
162-
def coroutine():
162+
async def coroutine():
163163
global current_path
164164
open_dialog = TextInputDialog(
165165
title='Open file',
166166
label_text='Enter the path of a file:',
167167
completer=PathCompleter())
168168

169-
path = yield From(show_dialog_as_float(open_dialog))
169+
path = await show_dialog_as_float(open_dialog)
170170
current_path = path
171171

172172
if path is not None:
@@ -184,9 +184,9 @@ def do_about():
184184

185185

186186
def show_message(title, text):
187-
def coroutine():
187+
async def coroutine():
188188
dialog = MessageDialog(title, text)
189-
yield From(show_dialog_as_float(dialog))
189+
await show_dialog_as_float(dialog)
190190

191191
ensure_future(coroutine())
192192

@@ -206,7 +206,7 @@ def show_dialog_as_float(dialog):
206206
if float_ in root_container.floats:
207207
root_container.floats.remove(float_)
208208

209-
raise Return(result)
209+
return result
210210

211211

212212
def do_new_file():
@@ -223,12 +223,12 @@ def do_time_date():
223223

224224

225225
def do_go_to():
226-
def coroutine():
226+
async def coroutine():
227227
dialog = TextInputDialog(
228228
title='Go to line',
229229
label_text='Line number:')
230230

231-
line_number = yield From(show_dialog_as_float(dialog))
231+
line_number = await show_dialog_as_float(dialog)
232232

233233
try:
234234
line_number = int(line_number)

prompt_toolkit/application/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
from .application import Application
2-
from .current import NoRunningApplicationError, get_app, set_app
2+
from .current import (
3+
NoRunningApplicationError,
4+
get_app,
5+
get_app_or_exception,
6+
get_app_or_none,
7+
set_app,
8+
)
39
from .dummy import DummyApplication
410
from .run_in_terminal import in_terminal, run_in_terminal
511

@@ -9,6 +15,8 @@
915

1016
# Current.
1117
'get_app',
18+
'get_app_or_none',
19+
'get_app_or_exception',
1220
'set_app',
1321
'NoRunningApplicationError',
1422

0 commit comments

Comments
 (0)