Back to Intellij Community

PyExceptionInheritInspection

python/python-psi-impl/resources/inspectionDescriptions/PyExceptionInheritInspection.html

2025.3-rc-2355 B
Original Source

Reports cases when a custom exception class is raised but does not inherit from the builtin Exception class.

Example:

class A:
    pass

def me_exception():
    raise A()

The proposed quick-fix changes the code to:

class A(Exception):
    pass

def me_exception():
    raise A()