StructValue#
- class tierkreis.core.values.StructValue(values: dict[str, TierkreisValue])[source]#
Bases:
Generic
[RowStruct
],TierkreisValue
A composite structure of named fields.
Methods
Generate a StructValue from a python object using object member names as labels.
Parses a tierkreis type from its protobuf representation.
from_proto_dict
Converts a python value to a tierkreis value.
Converts a python value to a tierkreis value, given a target python Union type.
Generate a StructValue from a tuple using tuple member indices as labels.
to_proto
to_proto_dict
Converts a tierkreis value to a python value given the desired python type.
Converts a tierkreis value to a python value given the desired union type.
Try to automatically convert to a python type without specifying the target types.
String representation used in graph visualisation.
Attributes
values
- classmethod from_object(value: Any, type_: Type | None = None) StructValue [source]#
Generate a StructValue from a python object using object member names as labels.
- classmethod from_proto(value: Any) StructValue [source]#
Parses a tierkreis type from its protobuf representation.
- classmethod from_python(value: Any, type_: Type | None = None) TierkreisValue #
Converts a python value to a tierkreis value. If type_ is not provided, it is inferred from the value.
- classmethod from_python_union(value: Any, type_: UnionType) TierkreisValue #
Converts a python value to a tierkreis value, given a target python Union type.
- classmethod from_tuple(tup: tuple[Any, ...]) StructValue [source]#
Generate a StructValue from a tuple using tuple member indices as labels.
- to_python(type_: Type[T]) T #
Converts a tierkreis value to a python value given the desired python type.
When the specified python type is a type variable, the original TierkreisValue is returned unchanged. This allows us to write generic functions in which values of unknown type are passed on as they are.
- to_python_union(type_: UnionType) Any #
Converts a tierkreis value to a python value given the desired union type.
- try_autopython() Any | None #
Try to automatically convert to a python type without specifying the target types. Returns None if unsuccessful. Expected to be successful for “simple” or “leaf” types, that are not made up component types.
- return:
Python value if successful, None if not.
- rtype:
Optional[Any]