pygada_runtime.typing Module

Package containing the builtin Gada types.

class pygada_runtime.typing.Type[source]

Base for Gada types.

class pygada_runtime.typing.AnyType[source]

Represent any type.

>>> t = AnyType()
>>> repr(t)
'AnyType()'
>>> str(t)
'any'
>>>
class pygada_runtime.typing.BoolType[source]

Wrap the Python bool type.

>>> t = BoolType()
>>> repr(t)
'BoolType()'
>>> str(t)
'bool'
>>>
class pygada_runtime.typing.IntType[source]

Wrap the Python int type.

>>> t = IntType()
>>> repr(t)
'IntType()'
>>> str(t)
'int'
>>>
class pygada_runtime.typing.FloatType[source]

Wrap the Python float type.

>>> t = FloatType()
>>> repr(t)
'FloatType()'
>>> str(t)
'float'
>>>
class pygada_runtime.typing.StringType[source]

Wrap the Python str type.

>>> t = StringType()
>>> repr(t)
'StringType()'
>>> str(t)
'str'
>>>
class pygada_runtime.typing.ListType(item_type, /)[source]

Wrap the Python list type.

>>> t = ListType(IntType())
>>> repr(t)
'ListType(IntType())'
>>> str(t)
'[int]'
>>>
Parameters

item_type (Optional[Type]) – type of list items

class pygada_runtime.typing.VariableType(item_type, /)[source]

Represent one or multiple values of the same type.

>>> t = VariableType(IntType())
>>> repr(t)
'VariableType(IntType())'
>>> str(t)
'*int'
>>>
Parameters

item_type (Type) – type of items

class pygada_runtime.typing.TupleType(items_types, /)[source]

Wrap the Python tuple type.

>>> t = TupleType([IntType(), StringType()])
>>> repr(t)
'TupleType([IntType(), StringType()])'
>>> str(t)
'(int, str)'
>>>
Parameters

items_types – types of tuple items

class pygada_runtime.typing.UnionType(items_types, /)[source]

Represent an union of multiple types.

>>> t = UnionType([IntType(), StringType()])
>>> repr(t)
'UnionType([IntType(), StringType()])'
>>> str(t)
'int | str'
>>>
Parameters

items_types – possible types

pygada_runtime.typing.isinstance(type, /)[source]

Check if a Python object is an instance of a Gada type.

>>> from pygada_runtime import typing
>>>
>>> typing.isinstance(1, IntType())
True
>>> typing.isinstance("hello", IntType())
False
>>>
Parameters
  • value (Any) – Python object

  • type (Type) – type to check

Return type

bool

Returns

if value is an instance of type

pygada_runtime.typing.typeof()[source]

Get the Gada type of a Python object.

>>> from pygada_runtime import typing
>>>
>>> typing.typeof(True)
BoolType()
>>> typing.typeof(1)
IntType()
>>> typing.typeof("hello")
StringType()
>>> typing.typeof([[1]])
ListType(ListType(IntType()))
>>> typing.typeof((1, "hello"))
TupleType([IntType(), StringType()])
>>>
Parameters

value (Any) – Python object

Return type

Type

Returns

type of value