|
120 | 120 | int, |
121 | 121 | list[t.Union[str, int]], |
122 | 122 | dict[str, list[t.Union[str, int]]], |
123 | | - "SparseArray[str]", |
| 123 | + SparseArray[t.Union[str, int]], |
124 | 124 | ] |
125 | 125 | ], |
126 | 126 | ] |
@@ -381,7 +381,7 @@ def explode_arrays( |
381 | 381 | """ |
382 | 382 | options: dict[str, t.Any] = {} |
383 | 383 | for key, val in _dict.items(): |
384 | | - Default: type[dict[t.Any, t.Any] | SparseArray[str]] = ( |
| 384 | + Default: type[dict[t.Any, t.Any] | SparseArray[str | int | bool | None]] = ( |
385 | 385 | dict if isinstance(key, str) and key == "terminal-features" else SparseArray |
386 | 386 | ) |
387 | 387 | if "[" not in key: |
@@ -1084,13 +1084,20 @@ def _show_option( |
1084 | 1084 | ), |
1085 | 1085 | ) |
1086 | 1086 |
|
1087 | | - if not isinstance(output_exploded, dict): |
1088 | | - return output_exploded |
| 1087 | + if not isinstance(output_exploded, (dict, SparseArray)): |
| 1088 | + return t.cast("ConvertedValue", output_exploded) |
1089 | 1089 |
|
1090 | | - if option not in output_exploded: |
| 1090 | + if isinstance(output_exploded, dict) and option not in output_exploded: |
1091 | 1091 | return None |
1092 | 1092 |
|
1093 | | - return t.cast("t.Optional[ConvertedValue]", output_exploded[option]) |
| 1093 | + if isinstance(output_exploded, SparseArray): |
| 1094 | + try: |
| 1095 | + index = int(option) |
| 1096 | + return t.cast("ConvertedValue", output_exploded[index]) |
| 1097 | + except (ValueError, KeyError): |
| 1098 | + return None |
| 1099 | + |
| 1100 | + return t.cast("ConvertedValue", output_exploded[option]) |
1094 | 1101 |
|
1095 | 1102 | def show_option( |
1096 | 1103 | self, |
|
0 commit comments