Coverage for fastblocks / adapters / style / _base.py: 100%
20 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-02 20:00 -0800
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-02 20:00 -0800
1"""Base classes and protocols for style adapters."""
3from contextlib import suppress
4from typing import Protocol
5from uuid import UUID
7# Oneiric imports
8from oneiric.core.config import OneiricSettings
9from oneiric.core.resolution import Resolver
11# Oneiric resolver for dependency injection
12depends = Resolver()
15class StyleBaseSettings(OneiricSettings):
16 """Base settings for style adapters using OneiricSettings."""
18 cdn_url: str | None = None
19 version: str = "latest"
20 additional_stylesheets: list[str] = []
22 def __init__(self, **data: dict) -> None:
23 super().__init__(**data)
26class StyleProtocol(Protocol):
27 """Protocol for style adapter implementations."""
29 def get_stylesheet_links(self) -> list[str]: ...
30 def get_component_class(self, component: str) -> str: ...
33class StyleBase:
34 """Base class for style adapters using Oneiric patterns."""
36 # Oneiric-compatible metadata
37 MODULE_ID: UUID = UUID("01937d86-4f2a-7b3c-8d9e-f3b4d3c2b1a2") # Static UUID7
38 MODULE_STATUS = "stable"
40 def __init__(self) -> None:
41 """Initialize style adapter."""
42 # Register with Oneiric resolver (fail gracefully if not supported)
43 with suppress(Exception):
44 depends.set(self)
46 def get_stylesheet_links(self) -> list[str]:
47 """Generate stylesheet link tags."""
48 raise NotImplementedError()
50 def get_component_class(self, component: str) -> str:
51 """Get style-specific class names for components."""
52 raise NotImplementedError()