Skip to content

Base Classes

Mostly used in the core.

base ¤

Ctx module-attribute ¤

Ctx = TypeVar('Ctx')

Type of the context for the service, a TypedDict

ApiRspRaw module-attribute ¤

ApiRspRaw = TypeVar('ApiRspRaw')

Type returned by the API, usually a TypedDict, e.g. fr24.types.flight_list.FlightList

HTTPClient ¤

HTTPClient(client: AsyncClient)

An HTTPX client for making requests to the API.

client instance-attribute ¤

client = client

auth instance-attribute ¤

auth: Authentication | None = None

__aenter__ async ¤

__aenter__() -> HTTPClient

__aexit__ async ¤

__aexit__(*args: Any) -> None

APIResponse ¤

APIResponse(ctx: Ctx, response: ApiRspRaw)

Bases: Generic[Ctx, ApiRspRaw]

Wraps an API response with context.

ctx instance-attribute ¤

ctx = ctx

data instance-attribute ¤

data = response

__repr__ ¤

__repr__() -> str

ArrowTable ¤

ArrowTable(ctx: Ctx, table: Table)

Bases: Generic[Ctx]

Manages storage and retrieval of an arrow table with context.

ctx instance-attribute ¤

ctx = ctx

data instance-attribute ¤

data = table

df property ¤

new classmethod ¤

new(ctx: Ctx, sch_expected: Schema | None = None) -> Self

from_file classmethod ¤

from_file(
    ctx: Ctx, fp: Path, sch_expected: Schema | None = None
) -> Self

Loads data from a parquet file, enforcing the schema if provided.

Raises:

Type Description
RuntimeError

when column names and/or types are unrecognised

concat ¤

concat(other: Self, inplace: bool = False) -> Self

save ¤

save(
    fp: Path | BinaryIO,
    fmt: Literal["parquet", "csv"] = "parquet",
) -> Self

Writes the table as the specified format, with the schema if defined.

Parameters:

Name Type Description Default
fp Path | BinaryIO

The path of file-like object to write to, e.g. sys.stdout.buffer

required

__repr__ ¤

__repr__() -> str

ServiceBase ¤

Bases: ABC

A service to handle the API and disk operations.

fetch abstractmethod async ¤

fetch(*args: Any, **kwargs: Any) -> APIResponse[Any, Any]

Fetches data from the API.

load abstractmethod ¤

load(*args: Any, **kwargs: Any) -> ArrowTable[Any]

Loads data from storage.