MCPcopy Index your code
hub / github.com/RustPython/RustPython / create_dict_rule

Function create_dict_rule

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

Source from the content-addressed store, hash-verified

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