Coverage for src/lexigram/admin/integrations/__init__.py: 0%

8 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-24 23:18 +0800

1"""Optional integration adapters for lexigram-* extension packages. 

2 

3Each submodule provides a ``*Integration`` class that consumes a protocol 

4from ``lexigram-contracts`` and either delegates to the real extension or 

5provides a graceful no-op when the extension is not installed. 

6 

7The module-level ``_registry`` dict is populated at boot time by 

8``AdminIntegrationsSubProvider.boot()`` so that consumers (e.g. 

9``ListRenderer``) can resolve integrations without deep constructor plumbing. 

10""" 

11 

12from __future__ import annotations 

13 

14from typing import Any 

15 

16_registry: dict[str, Any] = {} 

17 

18 

19def register(name: str, instance: Any) -> None: 

20 """Register an integration instance for lazy access by consumers.""" 

21 _registry[name] = instance 

22 

23 

24def get(name: str) -> Any: 

25 """Return a registered integration instance, or None.""" 

26 return _registry.get(name) 

27 

28 

29__all__ = [ 

30 "get", 

31 "register", 

32]