Test Python Package / unit-tests (pull_request) Successful in 12s
Code Quality Pipeline / code-quality (pull_request) Successful in 19s
PR Title Check / check-title (pull_request) Successful in 31s
Test Python Package / integration-tests (pull_request) Successful in 23s
Test Python Package / coverage-report (pull_request) Successful in 10s
Route Python hooks through uv run with versions pinned in uv.lock, add explicit Ruff settings, and extend the dependency bot to run pre-commit autoupdate. Co-authored-by: Cursor <[email protected]>
40 lines
1020 B
Python
40 lines
1020 B
Python
"""Definition of JsonRepositoryInterface abstract base class."""
|
|
|
|
from abc import ABC, abstractmethod
|
|
from collections.abc import Iterator
|
|
from typing import Any
|
|
|
|
|
|
class JsonRepositoryInterface(ABC):
|
|
"""Interface that defines JSON document CRUD methods."""
|
|
|
|
@abstractmethod
|
|
def get(self, key: str) -> dict[str, Any] | None:
|
|
"""Get a JSON object by key."""
|
|
...
|
|
|
|
@abstractmethod
|
|
def set(self, key: str, data: dict[str, Any]) -> None:
|
|
"""Set a JSON object by key."""
|
|
...
|
|
|
|
@abstractmethod
|
|
def delete(self, key: str) -> None:
|
|
"""Delete a JSON object by key."""
|
|
...
|
|
|
|
@abstractmethod
|
|
def list_keys(self, pattern: str) -> list[str]:
|
|
"""List keys matching a glob pattern."""
|
|
...
|
|
|
|
def scan_keys(
|
|
self,
|
|
pattern: str,
|
|
*,
|
|
count: int | None = None,
|
|
) -> Iterator[str]:
|
|
"""Yield keys matching a glob pattern incrementally."""
|
|
del count
|
|
yield from self.list_keys(pattern)
|