Why This Happens
When subclassing, you must call the parent __init__ with required arguments. If the parent expects parameters but you call super().__init__() without them, Python raises TypeError.
The Problem
class AppError(Exception):
def __init__(self, code):
super().__init__()
self.code = codeThe Fix
class AppError(Exception):
def __init__(self, message, code):
super().__init__(message)
self.code = code
raise AppError('Something failed', 500)Step-by-Step Fix
- 1
Check parent __init__
Look at what arguments the parent class expects.
- 2
Pass required arguments
Forward all necessary arguments to super().__init__().
- 3
Document the interface
Make it clear what arguments your subclass constructor expects.
Got the actual stack trace?
Paste it into our free AI explainer to get the cause and the fix for your specific case — no signup, nothing to install.
Explain my errorBugsly catches this automatically
Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.
Try Bugsly free