TierkreisValue#
- class tierkreis.core.values.TierkreisValue[source]#
Bases:
ABC
Abstract base class for all Tierkreis compatible values.
Methods
Parses a tierkreis type from its protobuf representation.
Converts a python value to a tierkreis value.
Converts a python value to a tierkreis value, given a target python Union type.
to_proto
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.
- classmethod from_proto(value: Any) TierkreisValue [source]#
Parses a tierkreis type from its protobuf representation.
- classmethod from_python(value: Any, type_: Type | None = None) TierkreisValue [source]#
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 [source]#
Converts a python value to a tierkreis value, given a target python Union type.
- to_python(type_: Type[T]) T [source]#
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 [source]#
Converts a tierkreis value to a python value given the desired union type.
- try_autopython() Any | None [source]#
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]