I want to convert this existing code to use pattern matching:
if isinstance(x, int):
pass
elif isinstance(x, str):
x = int(x)
elif isinstance(x, (float, Decimal)):
x = round(x)
else:
raise TypeError('Unsupported type')
How do you write isinstance
checks with pattern matching, and how do you test against multiple possible types like (float, Decimal)
at the same time?