Coverage for src/endow/base.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.14.1, created at 2026-06-09 19:20 +0200

1"""Base injectable types used by the dependency graph runtime.""" 

2 

3from __future__ import annotations 

4 

5import typing as t 

6 

7 

8class Injectable: 

9 """Base class for objects that participate in endow graph wiring.""" 

10 

11 @classmethod 

12 def with_injected(cls, **kw: t.Any) -> t.Self: 

13 """Build an injectable instance using the runtime graph.""" 

14 from .runtime import build_graph 

15 

16 return build_graph(cls, kw) 

17 

18 @classmethod 

19 def build(cls, **kw: t.Any) -> t.Self: 

20 """Backward-compatible alias for building an injected instance.""" 

21 return cls.with_injected(**kw) 

22 

23 

24class Service(Injectable): 

25 """Infrastructure capability resolved by the runtime.""" 

26 

27 

28class Domain(Injectable): 

29 """Domain component resolved by the runtime."""