schedr._model.types

Type descriptors: the type of a task’s output in DAG JSON.

Mirrors schedr-model (types.rs).

type schedr._model.types.JsonScalar = str | int | bool | None

A value allowed in a Literal[...] type.

schedr._model.types.ScalarName

The types without parameters.

alias of Literal[‘any’, ‘none’, ‘bool’, ‘int’, ‘float’, ‘str’, ‘datetime’, ‘date’, ‘timedelta’, ‘process_result’]

class schedr._model.types.ScalarType(name)

Bases: object

A type without parameters (int, str, datetime, ProcessResult, …).

Parameters:

name (Literal['any', 'none', 'bool', 'int', 'float', 'str', 'datetime', 'date', 'timedelta', 'process_result'])

name

Which type.

Type:

Literal[‘any’, ‘none’, ‘bool’, ‘int’, ‘float’, ‘str’, ‘datetime’, ‘date’, ‘timedelta’, ‘process_result’]

to_json()

The type as DAG JSON.

Returns:

{"type": name}.

Return type:

dict[str, Any]

class schedr._model.types.ListType(item)

Bases: object

list[T].

Parameters:

item (TypeDesc)

item

The element type.

Type:

schedr._model.types.TypeDesc

to_json()

The type as DAG JSON.

Returns:

{"type": "list", "item": ...}.

Return type:

dict[str, Any]

class schedr._model.types.TupleType(items)

Bases: object

tuple[A, B, ...].

Parameters:

items (Sequence[TypeDesc])

items

The element types, in order.

Type:

collections.abc.Sequence[schedr._model.types.TypeDesc]

to_json()

The type as DAG JSON.

Returns:

{"type": "tuple", "items": [...]}.

Return type:

dict[str, Any]

class schedr._model.types.DictType(value)

Bases: object

dict[str, T].

Parameters:

value (TypeDesc)

value

The value type (keys are always strings).

Type:

schedr._model.types.TypeDesc

to_json()

The type as DAG JSON.

Returns:

{"type": "dict", "value": ...}.

Return type:

dict[str, Any]

class schedr._model.types.LiteralType(values)

Bases: object

Literal[...].

Parameters:

values (Sequence[JsonScalar])

values

The allowed values.

Type:

collections.abc.Sequence[schedr._model.types.JsonScalar]

to_json()

The type as DAG JSON.

Returns:

{"type": "literal", "values": [...]}.

Return type:

dict[str, Any]

class schedr._model.types.UnionType(variants)

Bases: object

A union, including T | None.

Parameters:

variants (Sequence[TypeDesc])

variants

The member types.

Type:

collections.abc.Sequence[schedr._model.types.TypeDesc]

to_json()

The type as DAG JSON.

Returns:

{"type": "union", "variants": [...]}.

Return type:

dict[str, Any]

class schedr._model.types.Field(name, type, required=True)

Bases: object

A named field of a TypedDict or dataclass.

Parameters:
  • name (str)

  • type (TypeDesc)

  • required (bool)

name

The field or key name.

Type:

str

type

The field’s type.

Type:

schedr._model.types.TypeDesc

required

Whether it must be present (TypedDict) or has no default (dataclass).

Type:

bool

to_json()

The field as DAG JSON.

Returns:

{"name": ..., "type": ..., "required": ...}.

Return type:

dict[str, Any]

class schedr._model.types.TypedDictType(name, fields)

Bases: object

A TypedDict.

Parameters:
  • name (str)

  • fields (Sequence[Field])

name

The class name.

Type:

str

fields

The keys, in declaration order.

Type:

collections.abc.Sequence[schedr._model.types.Field]

to_json()

The type as DAG JSON.

Returns:

{"type": "typed_dict", "name": ..., "fields": [...]}.

Return type:

dict[str, Any]

class schedr._model.types.DataclassType(name, fields)

Bases: object

A dataclass.

Parameters:
  • name (str)

  • fields (Sequence[Field])

name

The class name (also the outcome name in outcome unions).

Type:

str

fields

The fields, in declaration order.

Type:

collections.abc.Sequence[schedr._model.types.Field]

to_json()

The type as DAG JSON.

Returns:

{"type": "dataclass", "name": ..., "fields": [...]}.

Return type:

dict[str, Any]

class schedr._model.types.ModelType(name, schema)

Bases: object

A Pydantic model, described by Pydantic’s JSON Schema of it (decision 59).

An output’s type holds the serialization schema (what model_dump(mode="json") writes), a parameter’s the validation schema (what model_validate accepts); a part of one (out.url) is a model type too, holding that part’s schema and the $defs its references need.

Parameters:
  • name (str)

  • schema (Mapping[str, Any])

name

The class name (also the outcome name in outcome unions), or the part’s path for a part (Remote.url).

Type:

str

schema

The JSON Schema.

Type:

collections.abc.Mapping[str, Any]

to_json()

The type as DAG JSON.

Returns:

{"type": "model", "name": ..., "schema": ...}.

Return type:

dict[str, Any]

type schedr._model.types.TypeDesc = ScalarType | ListType | TupleType | DictType | LiteralType | UnionType | TypedDictType | DataclassType | ModelType

Any type descriptor.