MapType#

class tierkreis.core.types.MapType(key: TierkreisType, value: TierkreisType)[source]#

Bases: TierkreisType

A map from keys of one type to values of another. The key type must be hashable.

Methods

children

For composite types (e.g. Struct, Vec, Map), list the child types that define it concretely.

contained_vartypes

from_proto

Attempts to convert a protobuf type to a TierkreisType subclass.

from_python

Create a TierkreisType from a corresponding Python type.

from_python_union

Create a TierkreisType from a Union type.

register_alternative

Register an alternative type that can be used to convert to/from TierkreisType.

to_proto

Converts a tierkreis type to its protobuf representation.

Attributes

key

value

children() list[TierkreisType][source]#

For composite types (e.g. Struct, Vec, Map), list the child types that define it concretely.

classmethod from_proto(type_: Type) TierkreisType#

Attempts to convert a protobuf type to a TierkreisType subclass.

classmethod from_python(type_: Type, visited_types: dict[Type, TierkreisType] | None = None) TierkreisType#

Create a TierkreisType from a corresponding Python type.

Parameters:
  • type – The Python type.

  • visited_types – An optional map from previously visited Python types

  • TierkreisType (to)

  • recursively. (used when converting)

Raises:
Returns:

TierkreisType

classmethod from_python_union(type_: UnionType, visited_types: dict[Type, TierkreisType] | None = None) TierkreisType#

Create a TierkreisType from a Union type.

classmethod register_alternative(type_: Type, alternative: Type[SerializeAs])#

Register an alternative type that can be used to convert to/from TierkreisType.

to_proto() Type[source]#

Converts a tierkreis type to its protobuf representation.