|
5 | 5 | database provider based on configuration. |
6 | 6 | """ |
7 | 7 |
|
8 | | -from typing import ClassVar |
| 8 | +from typing import Any, ClassVar, cast |
9 | 9 |
|
10 | 10 | from mcp_as_a_judge.db.db_config import Config, get_database_provider_from_url |
11 | 11 | from mcp_as_a_judge.db.interface import ConversationHistoryDB |
|
15 | 15 | class DatabaseFactory: |
16 | 16 | """Factory for creating database providers.""" |
17 | 17 |
|
18 | | - _providers: ClassVar[dict[str, type[ConversationHistoryDB]]] = { |
| 18 | + _providers: ClassVar[dict[str, Any]] = { |
19 | 19 | "in_memory": SQLiteProvider, # SQLModel SQLite in-memory (:memory: or empty URL) |
20 | 20 | "sqlite": SQLiteProvider, # SQLModel SQLite file-based storage |
21 | 21 | # Future providers can be added here: |
@@ -50,19 +50,15 @@ def create_provider(cls, config: Config) -> ConversationHistoryDB: |
50 | 50 |
|
51 | 51 | provider_class = cls._providers[provider_name] |
52 | 52 |
|
53 | | - # Create provider instance based on provider type |
54 | | - if provider_name in ["in_memory", "sqlite"]: |
55 | | - # SQLite-based providers (both SQLModel and legacy) |
56 | | - return provider_class( |
| 53 | + # Create provider instance - call concrete implementation constructor |
| 54 | + # All current providers accept max_session_records and url parameters |
| 55 | + return cast( |
| 56 | + ConversationHistoryDB, |
| 57 | + provider_class( |
57 | 58 | max_session_records=config.database.max_session_records, |
58 | 59 | url=config.database.url, |
59 | | - ) |
60 | | - else: |
61 | | - # For future network database providers (PostgreSQL, MySQL, etc.) |
62 | | - return provider_class( |
63 | | - url=config.database.url, |
64 | | - max_session_records=config.database.max_session_records, |
65 | | - ) |
| 60 | + ), |
| 61 | + ) |
66 | 62 |
|
67 | 63 | @classmethod |
68 | 64 | def get_available_providers(cls) -> list[str]: |
|
0 commit comments