Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ ignore_missing_imports = true
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
testpaths = ["tests"]
filterwarnings = ["error"]

[tool.ruff]
exclude = [
Expand Down
4 changes: 4 additions & 0 deletions python/rustac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,7 @@ class ItemCollection(TypedDict):
__doc__ = rustac.__doc__
if hasattr(rustac, "__all__"):
__all__ = rustac.__all__
else:
__all__ = []

__all__.append("store")
9 changes: 6 additions & 3 deletions python/rustac/rustac.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ from pathlib import Path
from typing import Any, Literal

import arro3.core
from obstore.store import ObjectStore as ObstoreObjectStore

from rustac import Catalog, Collection, Item, ItemCollection
from rustac.store import ObjectStore

AnyObjectStore = ObjectStore | ObstoreObjectStore

class RustacError(Exception):
"""A package-specific exception."""

Expand Down Expand Up @@ -212,7 +215,7 @@ async def read(
href: str,
*,
format: str | None = None,
store: ObjectStore | None = None,
store: AnyObjectStore | None = None,
set_self_link: bool = True,
) -> dict[str, Any]:
"""
Expand Down Expand Up @@ -347,7 +350,7 @@ async def search_to(
filter: str | dict[str, Any] | None = None,
query: dict[str, Any] | None = None,
format: str | None = None,
store: ObjectStore | None = None,
store: AnyObjectStore | None = None,
use_duckdb: bool | None = None,
) -> int:
"""
Expand Down Expand Up @@ -425,7 +428,7 @@ async def write(
value: dict[str, Any] | Sequence[dict[str, Any]],
*,
format: str | None = None,
store: ObjectStore | None = None,
store: AnyObjectStore | None = None,
) -> dict[str, str] | None:
"""
Writes STAC to a href.
Expand Down
11 changes: 11 additions & 0 deletions tests/test_read.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from pathlib import Path
from typing import Any

import pytest
import rustac
from obstore.store import LocalStore as ObstoreLocalStore
from pystac import Item
from rustac.store import LocalStore

Expand Down Expand Up @@ -33,3 +35,12 @@ async def test_read_proj_geometry(
async def test_read_store(examples: Path) -> None:
store = LocalStore(prefix=str(examples))
await rustac.read("simple-item.json", store=store)


async def test_read_external_store(examples: Path) -> None:
store = ObstoreLocalStore(prefix=str(examples))
with pytest.warns(
RuntimeWarning,
match="Successfully reconstructed a store defined in another Python module. Connection pooling will not be shared across store instances.",
):
await rustac.read("simple-item.json", store=store)