e18851b172
- Sort __all__ in cleveragents/domain/contexts/__init__.py (RUF022) - Remove unused ScopeChainResolver import from examples/scope_resolvers/git_issue_resolver.py (F401) - Fix EntryPoints.get() type error in scope_chain_resolver.py by casting to dict before calling .get() (reportAttributeAccessIssue)
43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
"""Example scope chain resolver for Git issue references."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from cleveragents.domain.contexts import (
|
|
ScopeResolutionContext,
|
|
)
|
|
|
|
|
|
class GitIssueResolver:
|
|
"""Example resolver for Git issue scope references."""
|
|
|
|
def __init__(self, repo_path: str | None = None) -> None:
|
|
"""Initialize the resolver."""
|
|
self.repo_path = repo_path or "."
|
|
|
|
def resolve(
|
|
self,
|
|
scope: str,
|
|
context: ScopeResolutionContext,
|
|
) -> list[str]:
|
|
"""Resolve a Git issue scope reference."""
|
|
if not scope.startswith("issue:"):
|
|
return []
|
|
|
|
try:
|
|
issue_id = scope[6:]
|
|
if not issue_id:
|
|
return []
|
|
|
|
fragment_id = f"git_issue_{issue_id}"
|
|
return [fragment_id]
|
|
except Exception:
|
|
return []
|
|
|
|
|
|
def create_git_issue_resolver() -> GitIssueResolver:
|
|
"""Factory function for creating a GitIssueResolver instance."""
|
|
return GitIssueResolver()
|