diff --git a/arro3-core/python/arro3/core/_rust.pyi b/arro3-core/python/arro3/core/_rust.pyi new file mode 100644 index 0000000..02f945f --- /dev/null +++ b/arro3-core/python/arro3/core/_rust.pyi @@ -0,0 +1,54 @@ +from typing import Self +from numpy.typing import NDArray + +from .types import ArrowArrayExportable, ArrowSchemaExportable, ArrowStreamExportable + +class Array: + def __array__(self) -> NDArray: ... + def __arrow_c_array__(self, requested_schema) -> object: ... + def __eq__(self) -> bool: ... + def __len__(self) -> bool: ... + @classmethod + def from_arrow(cls, input: ArrowArrayExportable) -> Self: ... + def to_numpy(self) -> NDArray: ... + +class ChunkedArray: + def __array__(self) -> NDArray: ... + def __arrow_c_stream__(self, requested_schema) -> object: ... + def __eq__(self) -> bool: ... + def __len__(self) -> bool: ... + @classmethod + def from_arrow(cls, input: ArrowStreamExportable) -> Self: ... + def to_numpy(self) -> NDArray: ... + +class Field: + def __arrow_c_schema__(self) -> object: ... + def __eq__(self) -> bool: ... + @classmethod + def from_arrow(cls, input: ArrowSchemaExportable) -> Self: ... + +class RecordBatch: + def __arrow_c_array__(self, requested_schema) -> object: ... + def __eq__(self) -> bool: ... + @classmethod + def from_arrow(cls, input: ArrowArrayExportable) -> Self: ... + +class RecordBatchReader: + def __arrow_c_stream__(self, requested_schema) -> object: ... + @classmethod + def from_arrow(cls, input: ArrowStreamExportable) -> Self: ... + def schema(self) -> Schema: ... + +class Schema: + def __arrow_c_schema__(self) -> object: ... + def __eq__(self) -> bool: ... + @classmethod + def from_arrow(cls, input: ArrowSchemaExportable) -> Self: ... + +class Table: + def __arrow_c_stream__(self, requested_schema) -> object: ... + def __eq__(self) -> bool: ... + def __len__(self) -> bool: ... + @classmethod + def from_arrow(cls, input: ArrowStreamExportable) -> Self: ... + def schema(self) -> Schema: ... diff --git a/arro3-core/python/arro3/core/py.typed b/arro3-core/python/arro3/core/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/arro3-core/python/arro3/core/types.py b/arro3-core/python/arro3/core/types.py new file mode 100644 index 0000000..1ed9a51 --- /dev/null +++ b/arro3-core/python/arro3/core/types.py @@ -0,0 +1,23 @@ +from __future__ import annotations + +from typing import Protocol, Tuple + + +class ArrowSchemaExportable(Protocol): + """An Arrow or GeoArrow schema or field.""" + + def __arrow_c_schema__(self) -> object: ... + + +class ArrowArrayExportable(Protocol): + """An Arrow or GeoArrow array or RecordBatch.""" + + def __arrow_c_array__( + self, requested_schema: object | None = None + ) -> Tuple[object, object]: ... + + +class ArrowStreamExportable(Protocol): + """An Arrow or GeoArrow ChunkedArray or Table.""" + + def __arrow_c_stream__(self, requested_schema: object | None = None) -> object: ...