refactor: add static source provider seam

This commit is contained in:
lda
2026-06-12 09:59:39 +07:00 Verified
parent dee95c89d2
commit bad3dbae0c
9 changed files with 148 additions and 17 deletions
+7 -1
View File
@@ -1,9 +1,15 @@
from __future__ import annotations
from .loader import PythonSourceConfigLike, load_python_source, python_capability_source
from .loader import (
PythonSourceConfigLike,
PythonSourceProvider,
load_python_source,
python_capability_source,
)
__all__ = [
"PythonSourceConfigLike",
"PythonSourceProvider",
"load_python_source",
"python_capability_source",
]
+11
View File
@@ -2,6 +2,7 @@ from __future__ import annotations
import sys
from collections.abc import Mapping, Sequence
from dataclasses import dataclass
from importlib import import_module
from pathlib import Path
from typing import Any, Protocol
@@ -23,6 +24,16 @@ class PythonSourceConfigLike(Protocol):
enabled: bool
@dataclass(frozen=True, slots=True)
class PythonSourceProvider:
"""Static source provider for trusted Python source config entries."""
configs: Sequence[PythonSourceConfigLike]
def load_sources(self) -> Mapping[str, CapabilitySource]:
return {config.id: python_capability_source(config) for config in self.configs}
def load_python_source(
*,
source_id: str,