def test_str_to_list(): data = """ A # 1 b c b """ assert str_to_list(data) == ["A # 1", "b", "c", "b"] assert str_to_list(data, lower=True, remove_comments=True, unique=True) == ["a", "b", "c"]
def parse_nodes(value: Union[list[str], str]) -> list[str]: if isinstance(value, list): return pydash.union(value) elif isinstance(value, str): return str_to_list(value, unique=True) else: raise ValueError(f"wrong nodes type: {type(value)}")
def to_list(cls, v): if v is None: return [] if isinstance(v, str): return str_to_list(v, unique=True, remove_comments=True) return v
def list_validator(cls, v): if isinstance(v, str): return str_to_list(v, unique=True) return v