How to use the dacite.types.is_union function in dacite

To help you get started, we’ve selected a few dacite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github konradhalas / dacite / tests / test_types.py View on Github external
def test_is_union_with_non_union():
    assert not is_union(int)
github konradhalas / dacite / tests / test_types.py View on Github external
def test_is_union_with_union():
    assert is_union(Union[int, float])
github konradhalas / dacite / dacite / core.py View on Github external
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