MCPcopy Create free account
hub / github.com/ChartGalaxy/ChartGalaxy / parse_to_list

Function parse_to_list

code_understanding/scoring.py:32–44  ·  view source on GitHub ↗

Parses text to a list of strings if possible; strips quotes and whitespace.

(text: str)

Source from the content-addressed store, hash-verified

30
31
32def parse_to_list(text: str) -> Optional[List[str]]:
33 """
34 Parses text to a list of strings if possible; strips quotes and whitespace.
35 """
36 if not isinstance(text, str):
37 return None
38 try:
39 parsed = ast.literal_eval(text)
40 except Exception:
41 return None
42 if isinstance(parsed, list):
43 return [str(x).strip(" '") for x in parsed]
44 return None
45
46
47def to_float(text: str) -> Optional[float]:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected