pg.typing.ListKey

Accessible via pg.typing.ListKey.

class ListKey(min_value=0, max_value=None)[source]

Bases: pg.typing.NonConstKey

Class that represents key specification for a list.

Example:

# Create a key spec that specifies list items from 1 to 5 (zero-based).
key = pg.typing.ListKey(min_value=1, max_value=5)

assert key.match(1)
assert key.match(5)
assert not key.match(0)

Methods:

extend(base)

Extend current key spec on top of base spec.

format(**kwargs)

Format this object.

match(key)

Returns whether this key spec can match against input key.

to_json(**kwargs)

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

Attributes:

max_value

Returns max value of acceptable list index value.

min_value

Returns min value of acceptable list index value.

extend(base)[source]

Extend current key spec on top of base spec.

Return type:

pg.typing.ListKey

format(**kwargs)[source]

Format this object.

match(key)[source]

Returns whether this key spec can match against input key.

Return type:

bool

property max_value: int | None[source]

Returns max value of acceptable list index value.

property min_value: int[source]

Returns min value of acceptable list index value.

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.