(src: str, pos: Pos, out: Output)
| 356 | |
| 357 | |
| 358 | def create_dict_rule(src: str, pos: Pos, out: Output) -> tuple[Pos, Key]: |
| 359 | pos += 1 # Skip "[" |
| 360 | pos = skip_chars(src, pos, TOML_WS) |
| 361 | pos, key = parse_key(src, pos) |
| 362 | |
| 363 | if out.flags.is_(key, Flags.EXPLICIT_NEST) or out.flags.is_(key, Flags.FROZEN): |
| 364 | raise TOMLDecodeError(f"Cannot declare {key} twice", src, pos) |
| 365 | out.flags.set(key, Flags.EXPLICIT_NEST, recursive=False) |
| 366 | try: |
| 367 | out.data.get_or_create_nest(key) |
| 368 | except KeyError: |
| 369 | raise TOMLDecodeError("Cannot overwrite a value", src, pos) from None |
| 370 | |
| 371 | if not src.startswith("]", pos): |
| 372 | raise TOMLDecodeError( |
| 373 | "Expected ']' at the end of a table declaration", src, pos |
| 374 | ) |
| 375 | return pos + 1, key |
| 376 | |
| 377 | |
| 378 | def create_list_rule(src: str, pos: Pos, out: Output) -> tuple[Pos, Key]: |
no test coverage detected
searching dependent graphs…