no-or-in-except

Require tuples instead of or-expressions when catching multiple exception types.

Message

Avoid using ‘or’ in an except block. For example:’except ValueError or TypeError’ only catches ‘ValueError’. Instead, use parentheses, ‘except (ValueError, TypeError)’

References

Valid examples

try:
    print()
except (ValueError, TypeError) as err:
    pass

Invalid examples

try:
    print()
except ValueError or TypeError:
    pass