From: James Clark <james.clark@linaro.org>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Alice Rogers <alice.mei.rogers@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
James Clark <james.clark@linaro.org>
Subject: [PATCH 1/2] perf timechart: Fix task row type narrowing in goto_task()
Date: Tue, 06 Oct 2026 14:03:31 +0100 [thread overview]
Message-ID: <20261006-james-perf-timechart-mypy-v1-1-e2c7edf4dd31@linaro.org> (raw)
In-Reply-To: <20261006-james-perf-timechart-mypy-v1-0-e2c7edf4dd31@linaro.org>
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: e7a72d691980 ("perf timechart: Add an interactive --tui mode")
Assisted-by: Codex:GPT-6.1-Sol
Signed-off-by: James Clark <james.clark@linaro.org>
---
tools/perf/python/ttimechart.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tools/perf/python/ttimechart.py b/tools/perf/python/ttimechart.py
index 34ecf84e68c1..d7ba0276a9fb 100755
--- a/tools/perf/python/ttimechart.py
+++ b/tools/perf/python/ttimechart.py
@@ -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)
--
2.43.0
next prev parent reply other threads:[~2026-10-06 13:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 13:03 [PATCH 0/2] perf timechart/treport: Fix mypy errors James Clark
2026-10-06 13:03 ` James Clark [this message]
2026-10-06 13:07 ` [PATCH 1/2] perf timechart: Fix task row type narrowing in goto_task() sashiko-bot
2026-10-06 13:03 ` [PATCH 2/2] perf treport: Fix profile builder type narrowing in progress callback James Clark
2026-10-06 13:06 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261006-james-perf-timechart-mypy-v1-1-e2c7edf4dd31@linaro.org \
--to=james.clark@linaro.org \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=alice.mei.rogers@gmail.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox