Skip to content

[BUG] App-level is_mounted guards in the TUI are dead code (always truthy) #894

Description

@MBemera

Describe the bug

App.is_mounted is a method taking a widget, not the Widget.is_mounted
property:

# textual/app.py
def is_mounted(self, widget: Widget) -> bool:
    return widget in self._registry

StrixTUIApp subclasses App, so a bare self.is_mounted is a bound method
object, always truthy, and not self.is_mounted is always False. All 13 guards
using it never fire: lines 870, 942, 957, 989, 1113, 1470, 1545, 1682, 1702,
1751, 1769, 1785, 1944. (widget.is_mounted at 1931 is on a Widget and is
correct.)

Worst case is app.py:950 — the dead guard lets query_one run against a missing
screen, raise, and get caught by an except that re-schedules via
call_after_refresh, looping instead of returning.

To Reproduce

  1. uv run mypy strix/Function "is_mounted" could always be true in boolean context, plus Statement is unreachable after 7.
  2. uv run pyright strix/ → 13 × reportUnnecessaryComparison.

Expected behavior

if not <guard>: return should return when the app isn't up. App.is_running
is the property these guards want.

System Information:

  • OS: environment-independent (static logic bug)
  • Strix Version or Commit: 1.3.1 / 27f9750
  • Python Version: 3.12+
  • LLM Used: n/a
  • textual: 6.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions