perf timechart: Fix task row type narrowing in goto_task()

Mypy cannot narrow Row to TaskRow or IoRow when the class passed to
isinstance() comes from a loop variable, causing the perf build to fail
with:

  python/ttimechart.py:1686: error: "Row" has no attribute "task" [attr-defined]

Check against TaskRow and IoRow explicitly so mypy can verify access to
the task attribute. The tasks and I/O views contain TaskRow and IoRow
instances respectively, so task navigation behaves as before.

Fixes: e7a72d6919 ("perf timechart: Add an interactive --tui mode")
Reviewed-by: Ian Rogers <irogers@google.com>
Assisted-by: Codex:GPT-6.1-Sol
Signed-off-by: James Clark <james.clark@linaro.org>
Cc: Alice Rogers <alice.mei.rogers@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
James Clark 2026-10-06 14:03:31 +01:00 committed by Arnaldo Carvalho de Melo
parent 1c90f0a3c8
commit 5927da0078

View File

@ -1676,14 +1676,13 @@ class TimechartApp(App):
def goto_task(self, tid: int, time: Optional[float]) -> None:
"""Select the task in the tasks or I/O view, optionally moving the cursor."""
for tab_id, view_id, row_type in (("tasks", "#tasks_view", TaskRow),
("io", "#io_view", IoRow)):
for tab_id, view_id in (("tasks", "#tasks_view"), ("io", "#io_view")):
views = self.query(view_id)
if not views:
continue
view = views.first(TimelineView)
for idx, row in enumerate(view.rows):
if isinstance(row, row_type) and row.task.tid == tid:
if isinstance(row, (TaskRow, IoRow)) and row.task.tid == tid:
self.query_one(TabbedContent).active = tab_id
if time is not None:
self.window = self.window.with_cursor(time)