pg.typing.Any

Accessible via pg.typing.Any.

class Any(default=MISSING_VALUE, annotation=MISSING_VALUE, transform=None, frozen=False)[source]

Bases: ValueSpecBase

Value spec for any type.

Examples:

# A required value of any type.
pg.typing.Any()

# An optional value of any type, with None as its default value.
pg.typing.Any().noneable()

# A required value of any type, with 1 as its default value.
pg.typing.Any(default=1)

Note

While Any type is very flexible and useful to pass though data between components, we should minimize its usage since minimal validation is performed on this type.

Methods:

annotate(annotation)

Set external type annotation.

format(*[, markdown])

Format this object.

is_compatible(other)

Any is compatible with any ValueSpec.

to_json(**kwargs)

Returns a plain Python value as a representation for this object.

Attributes:

annotation

Returns type annotation.

annotate(annotation)[source]

Set external type annotation.

Return type:

pg.typing.Any

property annotation: Any[source]

Returns type annotation.

format(*, markdown=False, **kwargs)[source]

Format this object.

Return type:

str

is_compatible(other)[source]

Any is compatible with any ValueSpec.

Return type:

bool

to_json(**kwargs)[source]

Returns a plain Python value as a representation for this object.

A plain Python value are basic python types that can be serialized into JSON, e.g: bool, int, float, str, dict (with string keys), list, tuple where the container types should have plain Python values as their values.

Return type:

Dict[str, Any]

Parameters:

**kwargs – Keyword arguments as flags to control JSON conversion.

Returns:

A plain Python value.