Generate structure template for an array.
(
schema: List[Any],
level: int,
delimiter: str,
indent_size: int,
key: Optional[str] = None
)
| 101 | |
| 102 | |
| 103 | def _generate_array_structure( |
| 104 | schema: List[Any], |
| 105 | level: int, |
| 106 | delimiter: str, |
| 107 | indent_size: int, |
| 108 | key: Optional[str] = None |
| 109 | ) -> str: |
| 110 | """Generate structure template for an array.""" |
| 111 | if not schema: |
| 112 | return "[]" |
| 113 | |
| 114 | indent = get_indent(level, indent_size) |
| 115 | |
| 116 | # Check if it's an array of objects (tabular format) |
| 117 | if isinstance(schema[0], dict): |
| 118 | return _generate_tabular_array_structure( |
| 119 | schema[0], level, delimiter, indent_size, key |
| 120 | ) |
| 121 | elif isinstance(schema[0], str): |
| 122 | # Array of primitive descriptions |
| 123 | if key: |
| 124 | return f'{indent}{key}{COLON} [<{schema[0]}>,...]' |
| 125 | else: |
| 126 | return f'[<{schema[0]}>,...]' |
| 127 | else: |
| 128 | # Generic array |
| 129 | if key: |
| 130 | return f'{indent}{key}{COLON} [...]' |
| 131 | else: |
| 132 | return '[...]' |
| 133 | |
| 134 | |
| 135 | def _generate_tabular_array_structure( |
no test coverage detected
searching dependent graphs…