yggdrasil.data.types.parser¶
parser ¶
ParsedDataType
dataclass
¶
ParsedDataType(
type_id: DataTypeId,
metadata: "DataTypeMetadata" = (lambda: _EMPTY_METADATA)(),
name: str | None = None,
children: tuple["ParsedDataType", ...] = (),
)
from_
classmethod
¶
Parse a DataType string.
On parse failure the dispatch is driven by default:
default = ...(the sentinel default) — re-raise the underlying :class:ValueError. Use this when the caller treats parse failure as a programming error.defaultis a :class:ParsedDataType— return it as-is.defaultis a :class:DataTypeId— wrap into a bare :class:ParsedDataTypewith no metadata.- Anything else (including
None) — collapse to :data:DataTypeId.OBJECT, the "I don't know what this is, treat it as opaque" type. Strings used to land here too; OBJECT keeps the value untouched whereas STRING would have coerced throughstr()on cast.
Successful parses are memoized via :func:_parse_cached so a
schema that mentions map<string, struct<...>> a million
times only walks the AST once. Failures are not cached — each
call re-raises so a fix in the input doesn't get masked.
parse_data_type ¶
Module-level alias for :meth:ParsedDataType.from_.
See that method for the default semantics — passing
:data:... raises on failure, anything else is a fallback.