diff options
| author | Ian Rogers <irogers@google.com> | 2026-09-25 23:19:30 -0700 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2026-09-26 20:49:27 +0200 |
| commit | 2dfe9eaec5c28f8f885c17d5b643299f685451b7 (patch) | |
| tree | c00122e3cbb9ed8d161b7558f0fa46e08b1c971a /tools/perf/python | |
| parent | 514ecdfd0073686e2a61681fe6f9e08870d9a89a (diff) | |
| download | linux-next-2dfe9eaec5c28f8f885c17d5b643299f685451b7.tar.gz linux-next-2dfe9eaec5c28f8f885c17d5b643299f685451b7.zip | |
perf python: Clean up pylint warnings in ilist.py
Replace bare 'except:' clauses (pylint W0702: bare-except) in ilist.py
with specific exception tuples (OSError, ValueError, RuntimeError,
TypeError, KeyError) and use a safe '.get("name", "")' sort key in
IListApp.compose() so that ilist.py passes pylint without warning
suppression comments and handles unnamed PMU events gracefully.
Assisted-by: Antigravity:gemini-3.1-pro
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/python')
| -rwxr-xr-x | tools/perf/python/ilist.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/perf/python/ilist.py b/tools/perf/python/ilist.py index ebff0a843b7a..86bd65452e6e 100755 --- a/tools/perf/python/ilist.py +++ b/tools/perf/python/ilist.py @@ -82,7 +82,7 @@ class Metric(TreeValue): try: val = evlist.compute_metric(self.metric_name, cpu, thread) return 0 if math.isnan(val) else val - except: + except (OSError, ValueError, RuntimeError, TypeError): # Be tolerant of failures to compute metrics on particular CPUs/threads. return 0 @@ -419,7 +419,7 @@ class IListApp(App): if self.evlist: self.evlist.open() self.evlist.enable() - except: + except (OSError, ValueError, RuntimeError): self.evlist = None if not self.evlist: @@ -450,7 +450,7 @@ class IListApp(App): pmu_name = pmu.name().lower() pmu_node = pmus.add(pmu_name) try: - for event in sorted(pmu.events(), key=lambda x: x["name"]): + for event in sorted(pmu.events(), key=lambda x: x.get("name", "")): if "deprecated" in event: continue if "name" in event: @@ -460,7 +460,7 @@ class IListApp(App): data=PmuEvent(pmu_name, e)) else: pmu_node.add_leaf(e, data=PmuEvent(pmu_name, e)) - except: + except (OSError, ValueError, RuntimeError, KeyError, TypeError): # Reading events may fail with EPERM, ignore. pass metrics = tree.root.add("Metrics") |
