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
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,12 @@ repos:
pass_filenames: false
args:
- check

- id: stubtest
name: python stubtest
language: python
additional_dependencies:
- mypy
entry: python ./scripts/stubtest.py
pass_filenames: false
always_run: true
2 changes: 1 addition & 1 deletion python/natsrpy/_natsrpy_rs/js/consumers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class PushConsumerConfig:

@final
class MessagesIterator:
def __aiter__(self) -> MessagesIterator: ...
def __aiter__(self) -> Self: ...
async def __anext__(self) -> JetStreamMessage: ...
async def next(
self,
Expand Down
48 changes: 46 additions & 2 deletions python/natsrpy/_natsrpy_rs/js/object_store.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from datetime import timedelta
from typing import final
from datetime import datetime, timedelta
from typing import Any, final

from typing_extensions import Self, Writer

from .stream import Placement, StorageType

__all__ = [
"ObjectInfo",
"ObjectInfoIterator",
"ObjectLink",
"ObjectStore",
"ObjectStoreConfig",
]
Expand Down Expand Up @@ -33,6 +36,33 @@ class ObjectStoreConfig:
placement: Placement | None = None,
) -> Self: ...

@final
class ObjectLink:
name: str | None
bucket: str

@final
class ObjectInfo:
name: str
description: str | None
metadata: dict[str, str]
headers: dict[str, Any]
bucket: str
nuid: str
size: int
chunks: int
modified: datetime | None
digest: str | None
deleted: bool
link: ObjectLink | None
max_chunk_size: int | None

@final
class ObjectInfoIterator:
def __aiter__(self) -> Self: ...
async def __anext__(self) -> ObjectInfo: ...
async def next(self, timeout: float | timedelta | None = None) -> ObjectInfo: ...

@final
class ObjectStore:
async def get(
Expand All @@ -51,3 +81,17 @@ class ObjectStore:
metadata: dict[str, str] | None = None,
) -> None: ...
async def delete(self, name: str) -> None: ...
async def seal(self) -> None: ...
async def get_info(self, name: str) -> ObjectInfo: ...
async def watch(self, with_history: bool = False) -> ObjectInfoIterator: ...
async def list(self) -> ObjectInfoIterator: ...
async def link_bucket(self, src_bucket: str, dest: str) -> ObjectInfo: ...
async def link_object(self, src: str, dest: str) -> ObjectInfo: ...
async def update_metadata(
self,
name: str,
new_name: str | None = None,
description: str | None = None,
headers: dict[str, Any] | None = None,
metadata: dict[str, str] | None = None,
) -> ObjectInfo: ...
1 change: 1 addition & 0 deletions scripts/bump_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa
import re
import argparse
from pathlib import Path
Expand Down
15 changes: 15 additions & 0 deletions scripts/stubtest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ruff: noqa
import os
import subprocess
from pathlib import Path

ROOT_DIR = Path(__file__).parent.parent


def main():
subprocess.run(["maturin", "dev", "--uv"], cwd=ROOT_DIR, check=True)
os.execvpe("stubtest", ["--ignore-disjoint-bases", "natsrpy"], env=os.environ)


if __name__ == "__main__":
main()
14 changes: 14 additions & 0 deletions src/exceptions/rust_err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ pub enum NatsrpyError {
ObjectStorePutError(#[from] async_nats::jetstream::object_store::PutError),
#[error(transparent)]
ObjectStoreDeleteError(#[from] async_nats::jetstream::object_store::DeleteError),
#[error(transparent)]
ObjectStoreSealError(#[from] async_nats::jetstream::object_store::SealError),
#[error(transparent)]
ObjectStoreInfoError(#[from] async_nats::jetstream::object_store::InfoError),
#[error(transparent)]
ObjectStoreWatchError(#[from] async_nats::jetstream::object_store::WatchError),
#[error(transparent)]
ObjectStoreWatcherError(#[from] async_nats::jetstream::object_store::WatcherError),
#[error(transparent)]
ObjectStoreAddLinkError(#[from] async_nats::jetstream::object_store::AddLinkError),
#[error(transparent)]
ObjectStoreUpdateMetadataError(
#[from] async_nats::jetstream::object_store::UpdateMetadataError,
),
}

impl From<NatsrpyError> for pyo3::PyErr {
Expand Down
Loading
Loading