(
row: Dict[str, Any],
column: Optional[str],
row_index: int,
)
| 116 | |
| 117 | |
| 118 | def _parse_json_list( |
| 119 | row: Dict[str, Any], |
| 120 | column: Optional[str], |
| 121 | row_index: int, |
| 122 | ) -> List[str]: |
| 123 | if not column: |
| 124 | return [] |
| 125 | raw_value = row.get(column) |
| 126 | if raw_value is None or (isinstance(raw_value, float) and pd.isna(raw_value)): |
| 127 | return [] |
| 128 | if isinstance(raw_value, list): |
| 129 | return _ensure_string_list(raw_value, row_index, "Attachments") |
| 130 | if isinstance(raw_value, str): |
| 131 | if not raw_value.strip(): |
| 132 | return [] |
| 133 | try: |
| 134 | parsed = json.loads(raw_value) |
| 135 | except json.JSONDecodeError as exc: |
| 136 | raise ValidationError( |
| 137 | f"Invalid JSON in Attachments: {exc}", |
| 138 | details={"row_index": row_index}, |
| 139 | ) |
| 140 | return _ensure_string_list(parsed, row_index, "Attachments") |
| 141 | raise ValidationError( |
| 142 | "Attachments must be a JSON list", |
| 143 | details={"row_index": row_index}, |
| 144 | ) |
| 145 | |
| 146 | |
| 147 | def _parse_json_dict( |
no test coverage detected