* [PATCH 0/2] perf timechart/treport: Fix mypy errors
@ 2026-10-06 13:03 James Clark
2026-10-06 13:03 ` [PATCH 1/2] perf timechart: Fix task row type narrowing in goto_task() James Clark
2026-10-06 13:03 ` [PATCH 2/2] perf treport: Fix profile builder type narrowing in progress callback James Clark
0 siblings, 2 replies; 3+ messages in thread
From: James Clark @ 2026-10-06 13:03 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Alice Rogers
Cc: Arnaldo Carvalho de Melo, linux-perf-users, linux-kernel, James Clark
Two small adjustments to silence Mypy static checks.
Signed-off-by: James Clark <james.clark@linaro.org>
---
James Clark (2):
perf timechart: Fix task row type narrowing in goto_task()
perf treport: Fix profile builder type narrowing in progress callback
tools/perf/python/treport.py | 5 +++--
tools/perf/python/ttimechart.py | 5 ++---
2 files changed, 5 insertions(+), 5 deletions(-)
---
base-commit: 1dc462fc214907671600172280c2e79ef9fe6fcf
change-id: 20261006-james-perf-timechart-mypy-e0069393c0ef
Best regards,
--
James Clark <james.clark@linaro.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] perf timechart: Fix task row type narrowing in goto_task()
2026-10-06 13:03 [PATCH 0/2] perf timechart/treport: Fix mypy errors James Clark
@ 2026-10-06 13:03 ` James Clark
2026-10-06 13:03 ` [PATCH 2/2] perf treport: Fix profile builder type narrowing in progress callback James Clark
1 sibling, 0 replies; 3+ messages in thread
From: James Clark @ 2026-10-06 13:03 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Alice Rogers
Cc: Arnaldo Carvalho de Melo, linux-perf-users, linux-kernel, James Clark
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] perf treport: Fix profile builder type narrowing in progress callback
2026-10-06 13:03 [PATCH 0/2] perf timechart/treport: Fix mypy errors James Clark
2026-10-06 13:03 ` [PATCH 1/2] perf timechart: Fix task row type narrowing in goto_task() James Clark
@ 2026-10-06 13:03 ` James Clark
1 sibling, 0 replies; 3+ messages in thread
From: James Clark @ 2026-10-06 13:03 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Alice Rogers
Cc: Arnaldo Carvalho de Melo, linux-perf-users, linux-kernel, James Clark
Mypy does not retain the narrowing of an optional local variable inside
the nested progress callback, causing the perf build to fail with:
python/treport.py:649: error: Item "None" of "ProfileBuilder | None" has no attribute "cancelled" [union-attr]
Check the loading builder before assigning it to profile so the captured
variable is inferred as ProfileBuilder rather than
Optional[ProfileBuilder]. Keep the existing assertion and background
loading behavior.
Fixes: b379b70b7b7b ("perf treport: Show the profile while it loads")
Assisted-by: Codex:GPT-6.1-Sol
Signed-off-by: James Clark <james.clark@linaro.org>
---
tools/perf/python/treport.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/perf/python/treport.py b/tools/perf/python/treport.py
index e02121475370..fb583786b17a 100755
--- a/tools/perf/python/treport.py
+++ b/tools/perf/python/treport.py
@@ -638,8 +638,9 @@ class ReportApp(App):
@work(thread=True, exclusive=True)
def load_profile(self) -> None:
"""Build the profile in a thread so the UI stays responsive."""
- profile = self.loading
- assert profile is not None
+ loading = self.loading
+ assert loading is not None
+ profile = loading
def progress() -> None:
try:
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-06 13:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-06 13:03 [PATCH 0/2] perf timechart/treport: Fix mypy errors James Clark
2026-10-06 13:03 ` [PATCH 1/2] perf timechart: Fix task row type narrowing in goto_task() James Clark
2026-10-06 13:03 ` [PATCH 2/2] perf treport: Fix profile builder type narrowing in progress callback James Clark
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®