Coverage for src / lexigram / contracts / data / graph / __init__.py: 0%
15 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-15 18:57 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-15 18:57 +0800
1"""Graph store contracts — protocols, types, and filter primitives."""
3from __future__ import annotations
5from typing import TYPE_CHECKING, Any
7if TYPE_CHECKING:
8 from lexigram.contracts.data.graph.enums import (
9 ConstraintKind,
10 EdgeDirection,
11 IndexKind,
12 MergeAction,
13 ReturnType,
14 )
15 from lexigram.contracts.data.graph.filters import (
16 Prop,
17 PropertyCondition,
18 PropertyConditionGroup,
19 PropertyFilter,
20 PropertyOperator,
21 )
22 from lexigram.contracts.data.graph.protocols import (
23 GraphProtocol,
24 GraphStoreProtocol,
25 )
26 from lexigram.contracts.data.graph.tenancy import (
27 GraphTenancyStrategy,
28 )
29 from lexigram.contracts.data.graph.types import (
30 BulkEdgeResult,
31 BulkNodeResult,
32 ConstraintSpec,
33 EdgeResult,
34 EdgeSpec,
35 GraphEdge,
36 GraphInfo,
37 GraphNode,
38 GraphPath,
39 IndexSpec,
40 NodeResult,
41 NodeSpec,
42 StartSpec,
43 TraversalQuery,
44 TraversalStep,
45 )
46 from lexigram.contracts.data.types import LogicalOperator
48_LAZY_IMPORTS: dict[str, tuple[str, str]] = {
49 # --- Protocols ---
50 "GraphStoreProtocol": (
51 "lexigram.contracts.data.graph.protocols",
52 "GraphStoreProtocol",
53 ),
54 "GraphProtocol": (
55 "lexigram.contracts.data.graph.protocols",
56 "GraphProtocol",
57 ),
58 # --- Types ---
59 "GraphNode": ("lexigram.contracts.data.graph.types", "GraphNode"),
60 "GraphEdge": ("lexigram.contracts.data.graph.types", "GraphEdge"),
61 "GraphPath": ("lexigram.contracts.data.graph.types", "GraphPath"),
62 "NodeSpec": ("lexigram.contracts.data.graph.types", "NodeSpec"),
63 "EdgeSpec": ("lexigram.contracts.data.graph.types", "EdgeSpec"),
64 "NodeResult": ("lexigram.contracts.data.graph.types", "NodeResult"),
65 "EdgeResult": ("lexigram.contracts.data.graph.types", "EdgeResult"),
66 "BulkNodeResult": ("lexigram.contracts.data.graph.types", "BulkNodeResult"),
67 "BulkEdgeResult": ("lexigram.contracts.data.graph.types", "BulkEdgeResult"),
68 "GraphInfo": ("lexigram.contracts.data.graph.types", "GraphInfo"),
69 "StartSpec": ("lexigram.contracts.data.graph.types", "StartSpec"),
70 "TraversalStep": ("lexigram.contracts.data.graph.types", "TraversalStep"),
71 "TraversalQuery": ("lexigram.contracts.data.graph.types", "TraversalQuery"),
72 "IndexSpec": ("lexigram.contracts.data.graph.types", "IndexSpec"),
73 "ConstraintSpec": ("lexigram.contracts.data.graph.types", "ConstraintSpec"),
74 # --- Enums ---
75 "EdgeDirection": ("lexigram.contracts.data.graph.enums", "EdgeDirection"),
76 "ReturnType": ("lexigram.contracts.data.graph.enums", "ReturnType"),
77 "IndexKind": ("lexigram.contracts.data.graph.enums", "IndexKind"),
78 "ConstraintKind": ("lexigram.contracts.data.graph.enums", "ConstraintKind"),
79 "MergeAction": ("lexigram.contracts.data.graph.enums", "MergeAction"),
80 # --- Tenancy ---
81 "GraphTenancyStrategy": (
82 "lexigram.contracts.data.graph.tenancy",
83 "GraphTenancyStrategy",
84 ),
85 # --- Filters ---
86 "Prop": ("lexigram.contracts.data.graph.filters", "Prop"),
87 "PropertyFilter": ("lexigram.contracts.data.graph.filters", "PropertyFilter"),
88 "PropertyCondition": ("lexigram.contracts.data.graph.filters", "PropertyCondition"),
89 "PropertyConditionGroup": (
90 "lexigram.contracts.data.graph.filters",
91 "PropertyConditionGroup",
92 ),
93 "PropertyOperator": ("lexigram.contracts.data.graph.filters", "PropertyOperator"),
94 "LogicalOperator": ("lexigram.contracts.data.types", "LogicalOperator"),
95}
98def __getattr__(name: str) -> Any:
99 """Lazy-load symbols on first access."""
100 if name in _LAZY_IMPORTS:
101 import importlib
103 module_path, attr_name = _LAZY_IMPORTS[name]
104 module = importlib.import_module(module_path)
105 value = getattr(module, attr_name)
106 globals()[name] = value
107 return value
108 raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
111def __dir__() -> list[str]:
112 """Enumerate available attributes for IDE support."""
113 return sorted(set(__all__) | set(_LAZY_IMPORTS.keys()))
116__all__ = [
117 "BulkEdgeResult",
118 "BulkNodeResult",
119 "ConstraintKind",
120 "ConstraintSpec",
121 "EdgeDirection",
122 "EdgeResult",
123 "EdgeSpec",
124 "GraphEdge",
125 "GraphInfo",
126 "GraphNode",
127 "GraphPath",
128 "GraphProtocol",
129 "GraphStoreProtocol",
130 "GraphTenancyStrategy",
131 "IndexKind",
132 "IndexSpec",
133 "LogicalOperator",
134 "MergeAction",
135 "NodeResult",
136 "NodeSpec",
137 "Prop",
138 "PropertyCondition",
139 "PropertyConditionGroup",
140 "PropertyFilter",
141 "PropertyOperator",
142 "ReturnType",
143 "StartSpec",
144 "TraversalQuery",
145 "TraversalStep",
146]