pylint-errors

E0703 (bad-exception-context)

:x: Problematic code:

def foo(x, y):
    try:
        return x / y
    except int as e:
        raise ZeroDivisionError from e

:heavy_check_mark: Correct code:

def foo(x, y):
    try:
        return x / y
    except ZeroDivisionError as e:
        raise ValueError from e

Rationale:

Used when using the syntax raise ... from ..., where the exception context is not an exception, nor None. This message belongs to the exceptions checker.