Textualize/textual · error · UnknownModeError

No such mode {mode!r}

Error message

No such mode {mode!r}

What it means

Error "No such mode {mode!r}" thrown in Textualize/textual.

Source

Thrown at src/textual/app.py:2938

            raise TypeError(
                f"push_screen requires a Screen instance or str; not {screen!r}"
            )

        try:
            loop = asyncio.get_running_loop()
        except RuntimeError:
            # Mainly for testing, when push_screen isn't called in an async context
            future: asyncio.Future[ScreenResultType] = asyncio.Future()
        else:
            future = loop.create_future()

        if mode is None:
            mode = self._current_mode

        try:
            screen_stack = self._screen_stacks[mode]
        except KeyError:
            raise UnknownModeError(f"No such mode {mode!r}")

        if screen_stack and screen_stack[-1].is_active:
            self.app.capture_mouse(None)
            mode_screen = screen_stack[-1]
            mode_screen.post_message(events.ScreenSuspend())
            mode_screen.refresh()
        next_screen, await_mount = self._get_screen(screen)
        try:
            message_pump = active_message_pump.get()
        except LookupError:
            message_pump = self.app

        next_screen._push_result_callback(message_pump, callback, future)
        self._load_screen_css(next_screen)
        next_screen._update_auto_focus()
        screen_stack.append(next_screen)
        if next_screen.is_active:
            next_screen.post_message(events.ScreenResume())

View on GitHub (pinned to 06dbeef4bb)

When it happens

Trigger: Thrown at src/textual/app.py:2938 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Textualize/textual@06dbeef4bb (2026-08-27). Data as JSON: /api/errors/b7b8ef897e5e9bc7. Report an issue: GitHub.