pg.typing.TupleKey

Accessible via pg.typing.TupleKey.

class TupleKey(index=None)[source]

Bases: pg.typing.NonConstKey

Class that represents a key specification for tuple.

Example:

# Create a key spec that specifies item 0 of a tuple.
key = pg.typing.TupleKey(0)

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

Methods:

extend(base)

Extends this key spec on top of a 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:

index

Returns the index of tuple field that the key applies to.

extend(base)[source]

Extends this key spec on top of a base spec.

Return type:

pg.typing.TupleKey

format(**kwargs)[source]

Format this object.

property index: int | None[source]

Returns the index of tuple field that the key applies to.

match(key)[source]

Returns whether this key spec can match against input key.

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.