Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _test_if_saturated(t: pydsdl.PrimitiveType) -> bool:
if isinstance(t, pydsdl.PrimitiveType):
return {
pydsdl.PrimitiveType.CastMode.SATURATED: True,
pydsdl.PrimitiveType.CastMode.TRUNCATED: False,
}[t.cast_mode]
else: # pragma: no cover
raise TypeError(f'Cast mode is not defined for {type(t).__name__}')