Coverage for src / lexigram / contracts / data / nosql / __init__.py: 93%
15 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-19 05:41 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-19 05:41 +0800
1"""NoSQL data contracts."""
3from __future__ import annotations
5from typing import TYPE_CHECKING, Any
7if TYPE_CHECKING:
8 from lexigram.contracts.data.nosql.nosql import (
9 BulkWriteResult,
10 CollectionProtocol,
11 DocumentResult,
12 DocumentStoreProtocol,
13 )
14 from lexigram.contracts.data.nosql.nosql_repository import (
15 DocumentRepositoryProtocol,
16 )
18_LAZY_IMPORTS: dict[str, tuple[str, str]] = {
19 "BulkWriteResult": (
20 "lexigram.contracts.data.nosql.nosql",
21 "BulkWriteResult",
22 ),
23 "CollectionProtocol": (
24 "lexigram.contracts.data.nosql.nosql",
25 "CollectionProtocol",
26 ),
27 "DocumentRepositoryProtocol": (
28 "lexigram.contracts.data.nosql.nosql_repository",
29 "DocumentRepositoryProtocol",
30 ),
31 "DocumentResult": (
32 "lexigram.contracts.data.nosql.nosql",
33 "DocumentResult",
34 ),
35 "DocumentStoreProtocol": (
36 "lexigram.contracts.data.nosql.nosql",
37 "DocumentStoreProtocol",
38 ),
39}
42def __getattr__(name: str) -> Any:
43 """Lazy-load symbols on first access."""
44 if name in _LAZY_IMPORTS:
45 import importlib
47 module_path, attr_name = _LAZY_IMPORTS[name]
48 module = importlib.import_module(module_path)
49 value = getattr(module, attr_name)
50 globals()[name] = value
51 return value
52 raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
55def __dir__() -> list[str]:
56 """Enumerate available attributes for IDE support."""
57 return sorted(set(__all__) | set(_LAZY_IMPORTS.keys()))
60__all__ = [
61 "BulkWriteResult",
62 "CollectionProtocol",
63 "DocumentRepositoryProtocol",
64 "DocumentResult",
65 "DocumentStoreProtocol",
66]