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
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-19 09:31 -0400
1"""Base class for status information collectors."""
3from abc import ABC, abstractmethod
4from pathlib import Path
5from typing import Any
7from workstack.core.context import WorkstackContext
10class StatusCollector(ABC):
11 """Base class for status information collectors.
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.
17 Collectors should handle their own errors gracefully and return None
18 if information cannot be collected.
19 """
21 @property
22 @abstractmethod
23 def name(self) -> str:
24 """Name identifier for this collector."""
25 ...
27 @abstractmethod
28 def is_available(self, ctx: WorkstackContext, worktree_path: Path) -> bool:
29 """Check if this collector can run in the given worktree.
31 Args:
32 ctx: Workstack context with operations
33 worktree_path: Path to the worktree
35 Returns:
36 True if collector can gather information, False otherwise
37 """
38 ...
40 @abstractmethod
41 def collect(self, ctx: WorkstackContext, worktree_path: Path, repo_root: Path) -> Any:
42 """Collect status information from worktree.
44 Args:
45 ctx: Workstack context with operations
46 worktree_path: Path to the worktree
47 repo_root: Path to repository root
49 Returns:
50 Collected status data or None if collection fails
51 """
52 ...