1from typing import Callable, Optional 2 3from prompt_toolkit.formatted_text import AnyFormattedText 4from prompt_toolkit.input import DummyInput 5from prompt_toolkit.output import DummyOutput 6 7from .application import Application 8 9__all__ = [ 10 "DummyApplication", 11] 12 13 14class DummyApplication(Application[None]): 15 """ 16 When no :class:`.Application` is running, 17 :func:`.get_app` will run an instance of this :class:`.DummyApplication` instead. 18 """ 19 20 def __init__(self) -> None: 21 super().__init__(output=DummyOutput(), input=DummyInput()) 22 23 def run( 24 self, 25 pre_run: Optional[Callable[[], None]] = None, 26 set_exception_handler: bool = True, 27 in_thread: bool = False, 28 ) -> None: 29 raise NotImplementedError("A DummyApplication is not supposed to run.") 30 31 async def run_async( 32 self, 33 pre_run: Optional[Callable[[], None]] = None, 34 set_exception_handler: bool = True, 35 ) -> None: 36 raise NotImplementedError("A DummyApplication is not supposed to run.") 37 38 async def run_system_command( 39 self, 40 command: str, 41 wait_for_enter: bool = True, 42 display_before_text: AnyFormattedText = "", 43 wait_text: str = "", 44 ) -> None: 45 raise NotImplementedError 46 47 def suspend_to_background(self, suspend_group: bool = True) -> None: 48 raise NotImplementedError 49