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

16 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"""Defines the contract for the application configuration service.""" 

5 

6from __future__ import annotations 

7 

8from pathlib import Path 

9from typing import Any, Protocol, runtime_checkable 

10 

11 

12@runtime_checkable 

13class ConfigProtocol(Protocol): 

14 """Defines the contract for application configuration management.""" 

15 

16 def load(self, path: str | Path | None = None) -> None: 

17 """Load configuration from a file path.""" 

18 ... 

19 

20 def reload(self) -> None: 

21 """Reload configuration from the last loaded path.""" 

22 ... 

23 

24 def get(self, key: str, default: Any = None) -> Any: 

25 """Retrieve a configuration value.""" 

26 ... 

27 

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

29 """Set a configuration value.""" 

30 ... 

31 

32 def unset(self, key: str) -> None: 

33 """Remove a configuration key.""" 

34 ... 

35 

36 def clear(self) -> None: 

37 """Clear all configuration values.""" 

38 ... 

39 

40 def all(self) -> dict[str, str]: 

41 """Return all configuration values.""" 

42 ... 

43 

44 def list_keys(self) -> list[str]: 

45 """List configuration keys.""" 

46 ... 

47 

48 def export(self, path: str | Path, out_format: str | None = None) -> None: 

49 """Export configuration to a target path.""" 

50 ... 

51 

52 def save(self) -> None: 

53 """Persist configuration to disk.""" 

54 ... 

55 

56 

57__all__ = ["ConfigProtocol"]