From dd1c6ac2f70f6a5b2d57bec2584de7bc7c144508 Mon Sep 17 00:00:00 2001 From: James Clark Date: Tue, 6 Oct 2026 14:03:32 +0100 Subject: perf treport: Fix profile builder type narrowing in progress callback 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 Reviewed-by: Ian Rogers Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/python/treport.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tools/perf/python') 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: -- cgit v1.2.3