NodeMetadata¶
- class hugr.metadata.NodeMetadata(metadata: dict[str, JsonType] | None = None)[source]¶
Bases:
objectKey-value record of metadata for a HUGR node.
Methods
Return the underlying raw metadata dictionary.
Return a metadata value, or a default if the key is missing.
Return an iterable over the raw metadata key-value pairs.
- get(key: type[Metadata[Meta]], default: Meta) Meta[source]¶
- get(key: type[Metadata[Meta]], default: None = None) Meta | None
- get(key: str, default: JsonType | None = None) JsonType | None
Return a metadata value, or a default if the key is missing.
When key is a string, it is looked up directly in the raw metadata dictionary. When key is a typed Metadata class, the metadata is looked up using key.KEY first, then each entry in key.ALIASES in order.
Typed values are deserialized with key.from_json before being returned.