concepts.dsl.dsl_types.ObjectType#

class ObjectType[source]#

Bases: TypeBase

The ObjectType corresponds to the type of “real-world” objects.

Methods

downcast_compatible(other[, ...])

Check if the type is downcast-compatible with the other type; that is, if this type is a subtype of the other type.

iter_parent_types()

Iterate over all parent types.

long_str()

Return the long string representation of the type.

short_str()

Return the short string representation of the type.

Attributes

alias

An optional alias of the type.

is_list_type

Return whether the type is a list type.

parent_type

The parent type of the type.

parent_typename

Return the typename of the parent type.

typename

The (full) typename of the type.

parent_types

The parent types of the object type.

__init__(typename, parent_types=None, alias=None)[source]#

Initialize the object type.

Parameters:
  • typename (str) – The name of the object type.

  • alias (str | None) – The alias of the object type.

  • parent_types (Sequence[ObjectType] | None) –

__new__(**kwargs)#
downcast_compatible(other, allow_self_list=False, allow_list=False)#

Check if the type is downcast-compatible with the other type; that is, if this type is a subtype of the other type.

Parameters:
  • other (TypeBase) – the other type.

  • allow_self_list (bool) – if True, this type can be a list type derived from the other type.

  • allow_list (bool) – if True, the other type can be a list type derived from the type.

Return type:

bool

iter_parent_types()[source]#

Iterate over all parent types.

Yields:

the parent types following the inheritance order.

Return type:

Iterable[ObjectType]

long_str()[source]#

Return the long string representation of the type.

Return type:

str

short_str()#

Return the short string representation of the type.

Return type:

str

property alias: str | None#

An optional alias of the type.

property is_list_type#

Return whether the type is a list type.

property parent_type: TypeBase | None#

The parent type of the type.

property parent_typename#

Return the typename of the parent type.

parent_types: Tuple[ObjectType, ...]#

The parent types of the object type.

property typename: str#

The (full) typename of the type.