no-or-in-except¶
Require tuples instead of or-expressions when catching multiple exception types.
Message¶
Use except (ValueError, TypeError):; except ValueError or TypeError: catches only ValueError.
References¶
Valid examples¶
try:
print()
except (ValueError, TypeError) as err:
pass
Invalid examples¶
try:
print()
except ValueError or TypeError:
pass
Show more
try:
print()
except ValueError:
pass
except TypeError or OSError:
pass