Expand dotted paths into nested objects. Args: obj: Object with potentially dotted keys Returns: Expanded object
(obj: dict)
| 460 | |
| 461 | |
| 462 | def _expand_paths(obj: dict) -> dict: |
| 463 | """ |
| 464 | Expand dotted paths into nested objects. |
| 465 | |
| 466 | Args: |
| 467 | obj: Object with potentially dotted keys |
| 468 | |
| 469 | Returns: |
| 470 | Expanded object |
| 471 | """ |
| 472 | result = {} |
| 473 | |
| 474 | for key, value in obj.items(): |
| 475 | if '.' in key: |
| 476 | # Split path and create nested structure |
| 477 | parts = key.split('.') |
| 478 | current = result |
| 479 | |
| 480 | for i, part in enumerate(parts[:-1]): |
| 481 | if part not in current: |
| 482 | current[part] = {} |
| 483 | elif not isinstance(current[part], dict): |
| 484 | # Conflict - keep original |
| 485 | result[key] = value |
| 486 | break |
| 487 | current = current[part] |
| 488 | else: |
| 489 | # Set final value |
| 490 | current[parts[-1]] = value |
| 491 | else: |
| 492 | result[key] = value |
| 493 | |
| 494 | # Recursively expand nested objects |
| 495 | for key, value in result.items(): |
| 496 | if isinstance(value, dict): |
| 497 | result[key] = _expand_paths(value) |
| 498 | elif isinstance(value, list): |
| 499 | result[key] = [_expand_paths(item) if isinstance(item, dict) else item for item in value] |
| 500 | |
| 501 | return result |
no outgoing calls
no test coverage detected
searching dependent graphs…