[PATCH v1 04/49] perf python: Clean up pylint warnings in treport.py
From: Ian Rogers
Date: Sun Sep 20 2026 - 01:24:25 EST
Clean up pylint warnings in treport.py so that it passes pylint without
warning suppression comments:
- Replace broad 'except Exception:' clauses (W0718:
broad-exception-caught) with specific exception tuples.
- Pass both pid and sample_tid to session.find_thread() so guest and
process threads are resolved accurately.
- Rename parameter 'args' to 'pos_args' in FlameGraph.__init__() to
avoid shadowing the outer scope variable 'args' (W0621:
redefined-outer-name).
Assisted-by: Antigravity:gemini-3.1-pro
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/python/treport.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/perf/python/treport.py b/tools/perf/python/treport.py
index 786b852f471c..082f5ca4a7da 100755
--- a/tools/perf/python/treport.py
+++ b/tools/perf/python/treport.py
@@ -91,9 +91,9 @@ class ProfileNode:
pid = sample.sample_pid
try:
assert session
- thread = session.find_thread(sample.sample_tid)
+ thread = session.find_thread(pid, sample.sample_tid)
comm = (thread.comm() if thread else None) or f"unknown ({pid})"
- except Exception:
+ except (OSError, ValueError, KeyError, RuntimeError, TypeError, AttributeError):
comm = f"unknown ({pid})"
period = sample.sample_period
@@ -412,9 +412,9 @@ class FlameGraph(ScrollView):
}
"""
- def __init__(self, root: ProfileNode, *args, **kwargs):
+ def __init__(self, root: ProfileNode, *pos_args, **kwargs):
"""Initialize the FlameGraph widget."""
- super().__init__(*args, **kwargs)
+ super().__init__(*pos_args, **kwargs)
self.root = root
self.cursor = root
self.selected = root
@@ -549,7 +549,7 @@ if __name__ == "__main__":
profile = ProfileBuilder()
try:
session = perf.session(perf.data(input_file), sample=profile.process_event)
- except Exception as e:
+ except (OSError, ValueError, RuntimeError) as e:
print(f"Error opening session: {e}", file=sys.stderr)
sys.exit(1)
--
2.55.0.1082.g2b9226bbc0-goog