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

Function create_dict_rule

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

Source from the content-addressed store, hash-verified

356
357
358def 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
378def create_list_rule(src: str, pos: Pos, out: Output) -> tuple[Pos, Key]:

Callers 1

loadsFunction · 0.85

Calls 7

skip_charsFunction · 0.85
parse_keyFunction · 0.85
TOMLDecodeErrorClass · 0.85
is_Method · 0.80
get_or_create_nestMethod · 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…