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_is_union_with_non_union():
assert not is_union(int)
def test_is_union_with_union():
assert is_union(Union[int, float])
def _build_value(type_: Type, data: Any, config: Config) -> Any:
if is_union(type_):
return _build_value_for_union(union=type_, data=data, config=config)
elif is_generic_collection(type_) and is_instance(data, extract_origin_collection(type_)):
return _build_value_for_collection(collection=type_, data=data, config=config)
elif is_dataclass(type_) and is_instance(data, Data):
return from_dict(data_class=type_, data=data, config=config)
return data