concepts.dsl.dsl_types.UnionType#

class UnionType[source]#

Bases: TypeBase

The UnionType is a type that is the union of multiple types.

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.

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.

types

The underlying types of the union type.

__init__(*types, alias=None)[source]#

Initialize the union type.

Parameters:
  • types (TypeBase) – The types in the union.

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

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

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

long_str()[source]#

Return the long string representation of the type.

Return type:

str

short_str()[source]#

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.

property typename: str#

The (full) typename of the type.

types: Tuple[TypeBase, ...]#

The underlying types of the union type.