t = ZeroDivisionError | ValueError # Python 3.10 syntax for types.UnionType
assert isinstance(ZeroDivisionError(), t) # isinstance and issubclass work
try:
1/0
except ZeroDivisionError | ValueError as e: # but this fails!
print(e)
Traceback (most recent call last):
File "demo.py", line 5, in <module>
1/0
ZeroDivisionError: division by zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "demo.py", line 6, in <module>
except ZeroDivisionError | ValueError as e:
TypeError: catching classes that do not inherit from BaseException is not allowed
I think we should have a lint warning for this, since I've seen it bite in the wild and it will remain an error going forward.