Skip to content

exceptions: call super().__init__() in APIError#1040

Open
prashantbytesyntax wants to merge 1 commit into
masterfrom
fix/apierror-super-init
Open

exceptions: call super().__init__() in APIError#1040
prashantbytesyntax wants to merge 1 commit into
masterfrom
fix/apierror-super-init

Conversation

@prashantbytesyntax
Copy link
Copy Markdown
Contributor

Summary

APIError.__init__ never calls super().__init__(), so the base Exception machinery is left uninitialized — most importantly self.args, which breaks repr(e), pickling, and any code that inspects e.args (including some logging configurations and multiprocessing propagation).

This PR:

  • Forwards message to super().__init__(message) so the standard Exception state is populated.
  • Tightens the full_data parameter annotation from dict = None to Optional[Dict[str, Any]] so it actually matches the default value and what the call sites pass (a parsed JSON response dict, see gprofiler/client.py).

No behavior change for the existing call sites in client.pystr(e) still returns self.message, and e.full_data is unchanged. The only observable difference is that e.args is now populated and repr(e) works as expected.

Before / after

>>> e = APIError("boom")
# before: repr(e) == 'APIError()'  and e.args == ()
# after:  repr(e) == \"APIError('boom')\"  and e.args == ('boom',)

Test plan

  • Existing tests pass (./tests/test.sh)
  • ./lint.sh is clean
  • Manual sanity: construct APIError("msg") / APIError("msg", {"k": 1}) and confirm str(e), repr(e), and e.full_data behave as expected

Made with Cursor

`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 <cursoragent@cursor.com>
@prashantbytesyntax prashantbytesyntax marked this pull request as ready for review May 13, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant