(
row: Dict[str, Any],
column: Optional[str],
row_index: int,
)
| 145 | |
| 146 | |
| 147 | def _parse_json_dict( |
| 148 | row: Dict[str, Any], |
| 149 | column: Optional[str], |
| 150 | row_index: int, |
| 151 | ) -> Dict[str, Any]: |
| 152 | if not column: |
| 153 | return {} |
| 154 | raw_value = row.get(column) |
| 155 | if raw_value is None or (isinstance(raw_value, float) and pd.isna(raw_value)): |
| 156 | return {} |
| 157 | if isinstance(raw_value, dict): |
| 158 | return raw_value |
| 159 | if isinstance(raw_value, str): |
| 160 | if not raw_value.strip(): |
| 161 | return {} |
| 162 | try: |
| 163 | parsed = json.loads(raw_value) |
| 164 | except json.JSONDecodeError as exc: |
| 165 | raise ValidationError( |
| 166 | f"Invalid JSON in Vars: {exc}", |
| 167 | details={"row_index": row_index}, |
| 168 | ) |
| 169 | if not isinstance(parsed, dict): |
| 170 | raise ValidationError( |
| 171 | "Vars must be a JSON object", |
| 172 | details={"row_index": row_index}, |
| 173 | ) |
| 174 | return parsed |
| 175 | raise ValidationError( |
| 176 | "Vars must be a JSON object", |
| 177 | details={"row_index": row_index}, |
| 178 | ) |
| 179 | |
| 180 | |
| 181 | def _ensure_string_list(value: Any, row_index: int, field: str) -> List[str]: |
no test coverage detected