All of lore.kernel.org
 help / color / mirror / Atom feed
* [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
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ 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] 7+ 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:07   ` sashiko-bot
  2026-10-06 13:03 ` [PATCH 2/2] perf treport: Fix profile builder type narrowing in progress callback James Clark
  2026-10-14  4:21 ` [PATCH 0/2] perf timechart/treport: Fix mypy errors Ian Rogers
  2 siblings, 1 reply; 7+ 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 related	[flat|nested] 7+ 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
  2026-10-06 13:06   ` sashiko-bot
  2026-10-14  4:21 ` [PATCH 0/2] perf timechart/treport: Fix mypy errors Ian Rogers
  2 siblings, 1 reply; 7+ 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 related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] perf treport: Fix profile builder type narrowing in progress callback
  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
  0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-10-06 13:06 UTC (permalink / raw)
  To: James Clark; +Cc: linux-perf-users

> 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>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261006-james-perf-timechart-mypy-v1-0-e2c7edf4dd31@linaro.org?part=2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] perf timechart: Fix task row type narrowing in goto_task()
  2026-10-06 13:03 ` [PATCH 1/2] perf timechart: Fix task row type narrowing in goto_task() James Clark
@ 2026-10-06 13:07   ` sashiko-bot
  0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-10-06 13:07 UTC (permalink / raw)
  To: James Clark; +Cc: linux-perf-users

> 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>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261006-james-perf-timechart-mypy-v1-0-e2c7edf4dd31@linaro.org?part=1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] perf timechart/treport: Fix mypy errors
  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
@ 2026-10-14  4:21 ` Ian Rogers
  2026-10-19 12:19   ` Arnaldo Carvalho de Melo
  2 siblings, 1 reply; 7+ messages in thread
From: Ian Rogers @ 2026-10-14  4:21 UTC (permalink / raw)
  To: James Clark
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Adrian Hunter, Alice Rogers, Arnaldo Carvalho de Melo,
	linux-perf-users, linux-kernel

On Tue, Oct 6, 2026 at 6:03 AM James Clark <james.clark@linaro.org> wrote:
>
> Two small adjustments to silence Mypy static checks.
>
> Signed-off-by: James Clark <james.clark@linaro.org>

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks!
Ian

> ---
> 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] 7+ messages in thread

* Re: [PATCH 0/2] perf timechart/treport: Fix mypy errors
  2026-10-14  4:21 ` [PATCH 0/2] perf timechart/treport: Fix mypy errors Ian Rogers
@ 2026-10-19 12:19   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-10-19 12:19 UTC (permalink / raw)
  To: Ian Rogers
  Cc: James Clark, Peter Zijlstra, Ingo Molnar, Namhyung Kim,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
	Alice Rogers, Arnaldo Carvalho de Melo, linux-perf-users,
	linux-kernel

On Tue, Oct 13, 2026 at 09:21:12PM -0700, Ian Rogers wrote:
> On Tue, Oct 6, 2026 at 6:03 AM James Clark <james.clark@linaro.org> wrote:
> >
> > Two small adjustments to silence Mypy static checks.
> >
> > Signed-off-by: James Clark <james.clark@linaro.org>
> 
> Reviewed-by: Ian Rogers <irogers@google.com>

Thanks, applied to perf-tools-next, for v7.4.

- Arnaldo

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-19 12:19 UTC | newest]

Thread overview: 7+ 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:07   ` 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
2026-10-14  4:21 ` [PATCH 0/2] perf timechart/treport: Fix mypy errors Ian Rogers
2026-10-19 12:19   ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.