Coverage for  / home / runner / work / bijux-cli / bijux-cli / src / bijux_cli / core / contracts.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.13.2, created at 2026-01-26 17:59 +0000

1# SPDX-License-Identifier: Apache-2.0 

2# Copyright © 2025 Bijan Mousavi 

3 

4"""Core protocol contracts for Bijux CLI.""" 

5 

6from __future__ import annotations 

7 

8from typing import Any, Protocol, Self, runtime_checkable 

9 

10 

11@runtime_checkable 

12class ExecutionContext(Protocol): 

13 """Execution-scoped context carrier.""" 

14 

15 def set(self, key: str, value: Any) -> None: 

16 """Store a value in the context.""" 

17 ... 

18 

19 def get(self, key: str) -> Any: 

20 """Retrieve a value from the context.""" 

21 ... 

22 

23 def clear(self) -> None: 

24 """Clear all context data.""" 

25 ... 

26 

27 def __enter__(self) -> Self: 

28 """Enter the synchronous context manager.""" 

29 ... 

30 

31 def __exit__(self, _exc_type: Any, _exc_value: Any, traceback: Any) -> None: 

32 """Exit the synchronous context manager.""" 

33 ... 

34 

35 async def __aenter__(self) -> Self: 

36 """Enter the async context manager.""" 

37 ... 

38 

39 async def __aexit__(self, _exc_type: Any, _exc_value: Any, traceback: Any) -> None: 

40 """Exit the async context manager.""" 

41 ... 

42 

43 

44__all__ = [ 

45 "ExecutionContext", 

46]