Shared types

The cross-cutting typing primitives reused across lairs: the recursive JsonValue alias for JSON-shaped data, and the type variables for generic helpers. Polymorphism elsewhere is expressed through these aliases, concrete unions, generics, and protocols rather than Any or object.

lairs._types

Shared type aliases and type variables for lairs.

This module defines the small set of cross-cutting typing primitives that the rest of lairs reuses, most importantly the recursive JsonValue alias used for JSON-shaped data such as lexicon documents and XRPC payloads. Nothing in lairs ever annotates with Any or object; polymorphism is expressed through these aliases, concrete unions, generics, and protocols.

T module-attribute

T = TypeVar('T')

An invariant type variable for generic helpers.

T_co module-attribute

T_co = TypeVar('T_co', covariant=True)

A covariant type variable for producer-shaped generics (for example exporters).

T_contra module-attribute

T_contra = TypeVar('T_contra', contravariant=True)

A contravariant type variable for consumer-shaped generics.

JsonValue

JsonValue = (
    str
    | int
    | float
    | bool
    | None
    | list[JsonValue]
    | dict[str, JsonValue]
)

A recursive alias for any JSON-serialisable value.

This is the single shared shape for JSON documents (lexicons) and XRPC request and response payloads. It is used in place of Any wherever lairs handles arbitrary-but-JSON-shaped data.