def _can_distinguish_unambiguously()

in lm_human_preferences/utils/hyperparams.py [0:0]


def _can_distinguish_unambiguously(type_set):
    """Whether it's always possible to tell which type in type_set a certain value is supposed to be"""
    if len(type_set) == 1:
        return True
    if type(None) in type_set:
        return True
    if str in type_set:
        return False
    if int in type_set and float in type_set:
        return False
    if any(_is_union_type(ty) for ty in type_set):
        # Nested unions *might* be unambiguous, but don't support for now
        return False
    return True