Split a comma-separated string, handling JSON arrays too.
(value_str: str)
| 168 | |
| 169 | |
| 170 | def _split_list(value_str: str) -> list[str]: |
| 171 | """Split a comma-separated string, handling JSON arrays too.""" |
| 172 | value_str = value_str.strip() |
| 173 | if value_str.startswith("["): |
| 174 | try: |
| 175 | parsed = json.loads(value_str) |
| 176 | if isinstance(parsed, list): |
| 177 | return [json.dumps(item) if isinstance(item, (dict, list)) else str(item) for item in parsed] |
| 178 | except json.JSONDecodeError: |
| 179 | pass |
| 180 | return [item.strip() for item in value_str.split(",") if item.strip()] |
no test coverage detected