MCPcopy Index your code
hub / github.com/python/cpython / create_list_rule

Function create_list_rule

Lib/tomllib/_parser.py:378–398  ·  view source on GitHub ↗
(src: str, pos: Pos, out: Output)

Source from the content-addressed store, hash-verified

376
377
378def 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
401def key_value_rule(

Callers 1

loadsFunction · 0.85

Calls 8

skip_charsFunction · 0.85
parse_keyFunction · 0.85
TOMLDecodeErrorClass · 0.85
is_Method · 0.80
unset_allMethod · 0.80
append_nest_to_listMethod · 0.80
setMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…