This rule raises an issue when an exception class is duplicated in an
except statement, or when an exception class has a parent class
in the same
Why is this an issue?
In Python it is possible to catch multiple types of exception in a single
except statement using a tuple of the exceptions.
Repeating an exception class in a single
except statement will not fail but it does not have any effect. Either the exception class is
not the one which should be caught, or it is duplicated code which should be removed.
Having a subclass and a parent class in the same
except statement does not provide any benefit either. It is enough to keep only the
Noncompliant code example
except (TypeError, TypeError): # Noncompliant: duplicated code or incorrect exception class.
except (NotImplementedError, RuntimeError): # Noncompliant: NotImplementedError inherits from RuntimeError.
except (TypeError, ValueError):