Coverage for src/qdrant_loader/config/base.py: 86%
14 statements
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-04 05:50 +0000
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-04 05:50 +0000
1"""Base configuration interfaces and protocols.
3This module defines the base interfaces and protocols for all configuration types
4in the application. These serve as contracts that concrete configuration classes
5must implement.
6"""
8from typing import Any, Protocol
10from pydantic import BaseModel, ConfigDict
13class ConfigProtocol(Protocol):
14 """Protocol for configuration objects.
16 This protocol defines the minimum interface that all configuration classes
17 must implement. It serves as a contract for configuration objects.
18 """
20 def to_dict(self) -> dict[str, Any]:
21 """Convert the configuration to a dictionary.
23 Returns:
24 Dict[str, Any]: The configuration as a dictionary.
25 """
26 ...
29class SourceConfigProtocol(Protocol):
30 """Protocol for source-specific configurations.
32 This protocol defines the interface for configurations specific to data sources
33 like Git, Confluence, or Jira.
34 """
36 def validate(self) -> None:
37 """Validate the configuration.
39 Raises:
40 ValueError: If the configuration is invalid.
41 """
42 ...
45class BaseConfig(BaseModel):
46 """Base class for all configuration types.
48 This class serves as the base for all configuration classes in the application.
49 It provides common functionality and implements the ConfigProtocol.
50 """
52 model_config = ConfigDict(arbitrary_types_allowed=True, extra="allow")
54 def to_dict(self) -> dict[str, Any]:
55 """Convert the configuration to a dictionary.
57 Returns:
58 Dict[str, Any]: The configuration as a dictionary.
59 """
60 return self.model_dump()
63class BaseSourceConfig(BaseConfig):
64 """Base class for source-specific configurations.
66 This class serves as the base for all source-specific configuration classes.
67 It provides common functionality and implements the SourceConfigProtocol.
68 """
70 def validate(self) -> None:
71 """Validate the configuration.
73 This method should be overridden by subclasses to implement
74 source-specific validation logic.
75 """