(src: str, pos: Pos, out: Output)
| 376 | |
| 377 | |
| 378 | def create_list_rule(src: str, pos: Pos, out: Output) -> tuple[Pos, Key]: |
| 379 | pos += 2 # Skip "[[" |
| 380 | pos = skip_chars(src, pos, TOML_WS) |
| 381 | pos, key = parse_key(src, pos) |
| 382 | |
| 383 | if out.flags.is_(key, Flags.FROZEN): |
| 384 | raise TOMLDecodeError(f"Cannot mutate immutable namespace {key}", src, pos) |
| 385 | # Free the namespace now that it points to another empty list item... |
| 386 | out.flags.unset_all(key) |
| 387 | # ...but this key precisely is still prohibited from table declaration |
| 388 | out.flags.set(key, Flags.EXPLICIT_NEST, recursive=False) |
| 389 | try: |
| 390 | out.data.append_nest_to_list(key) |
| 391 | except KeyError: |
| 392 | raise TOMLDecodeError("Cannot overwrite a value", src, pos) from None |
| 393 | |
| 394 | if not src.startswith("]]", pos): |
| 395 | raise TOMLDecodeError( |
| 396 | "Expected ']]' at the end of an array declaration", src, pos |
| 397 | ) |
| 398 | return pos + 2, key |
| 399 | |
| 400 | |
| 401 | def key_value_rule( |
no test coverage detected
searching dependent graphs…