Coverage for src/workstack/status/collectors/base.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-10-19 09:31 -0400

1"""Base class for status information collectors.""" 

2 

3from abc import ABC, abstractmethod 

4from pathlib import Path 

5from typing import Any 

6 

7from workstack.core.context import WorkstackContext 

8 

9 

10class StatusCollector(ABC): 

11 """Base class for status information collectors. 

12 

13 Each collector is responsible for gathering a specific type of status 

14 information (git, PR, dependencies, etc.) and returning it in a structured 

15 format. 

16 

17 Collectors should handle their own errors gracefully and return None 

18 if information cannot be collected. 

19 """ 

20 

21 @property 

22 @abstractmethod 

23 def name(self) -> str: 

24 """Name identifier for this collector.""" 

25 ... 

26 

27 @abstractmethod 

28 def is_available(self, ctx: WorkstackContext, worktree_path: Path) -> bool: 

29 """Check if this collector can run in the given worktree. 

30 

31 Args: 

32 ctx: Workstack context with operations 

33 worktree_path: Path to the worktree 

34 

35 Returns: 

36 True if collector can gather information, False otherwise 

37 """ 

38 ... 

39 

40 @abstractmethod 

41 def collect(self, ctx: WorkstackContext, worktree_path: Path, repo_root: Path) -> Any: 

42 """Collect status information from worktree. 

43 

44 Args: 

45 ctx: Workstack context with operations 

46 worktree_path: Path to the worktree 

47 repo_root: Path to repository root 

48 

49 Returns: 

50 Collected status data or None if collection fails 

51 """ 

52 ...