From 41e8505e5619fe78c7c99532cacfa896fa2666a1 Mon Sep 17 00:00:00 2001 From: prashantbytesyntax Date: Wed, 13 May 2026 22:09:19 +0000 Subject: [PATCH] exceptions: call super().__init__() in APIError MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `APIError.__init__` previously skipped `super().__init__()`, leaving the base `Exception` machinery uninitialized — most notably `self.args`, which breaks `repr(e)`, pickling, and any code that inspects `e.args`. Forward `message` to `super().__init__(message)` so the standard Exception state is populated. Also tighten the `full_data` annotation from `dict = None` to `Optional[Dict[str, Any]]` so it actually matches the default value and the data being passed (a JSON response dict). No behavior change for existing call sites in `client.py`; this just makes the exception behave correctly when introspected. Co-authored-by: Cursor --- gprofiler/exceptions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gprofiler/exceptions.py b/gprofiler/exceptions.py index 254ac1854..e1e4876d6 100644 --- a/gprofiler/exceptions.py +++ b/gprofiler/exceptions.py @@ -15,7 +15,7 @@ # import signal import subprocess -from typing import List, Union +from typing import Any, Dict, List, Optional, Union class PerfNoSupportedEvent(Exception): @@ -85,7 +85,8 @@ def __init__(self, program: str): class APIError(Exception): - def __init__(self, message: str, full_data: dict = None): + def __init__(self, message: str, full_data: Optional[Dict[str, Any]] = None): + super().__init__(message) self.message = message self.full_data = full_data