|
7 | 7 | import asyncio |
8 | 8 | import argparse |
9 | 9 | import traceback |
10 | | -from contextlib import contextmanager |
| 10 | +from contextlib import contextmanager, nullcontext |
11 | 11 | from pathlib import Path |
| 12 | +from contextlib import AbstractContextManager as ContextManager |
12 | 13 | from typing import TYPE_CHECKING, Any, Callable, Coroutine, Iterator |
13 | 14 | from concurrent.futures import ThreadPoolExecutor |
14 | 15 |
|
@@ -83,15 +84,15 @@ def thread_target( |
83 | 84 | console: Console = console_callback() |
84 | 85 |
|
85 | 86 | if app_config.input_file is not None: |
86 | | - console_input_context = console_input_from_file_context( |
87 | | - console, term, app_config.input_file, app_config.skip_inputs |
| 87 | + console_input_context: ContextManager[BaseInputGetter] = ( |
| 88 | + console_input_from_file_context( |
| 89 | + console, term, app_config.input_file, app_config.skip_inputs |
| 90 | + ) |
88 | 91 | ) |
89 | 92 | elif input_state is not None: |
90 | | - input_getter = TelnetInputGetter(console, term, input_state) |
91 | | - console_input_context = contextmanager(lambda: (yield input_getter))() |
| 93 | + console_input_context = nullcontext(TelnetInputGetter(console, term, input_state)) |
92 | 94 | else: |
93 | | - input_getter = NoInputGetter(console, term) |
94 | | - console_input_context = contextmanager(lambda: (yield input_getter))() |
| 95 | + console_input_context = nullcontext(NoInputGetter(console, term)) |
95 | 96 |
|
96 | 97 | with console_input_context as get_console_input: |
97 | 98 | try: |
|
0 commit comments