diff --git a/src/models/config.py b/src/models/config.py index c4efa404..44395e6f 100644 --- a/src/models/config.py +++ b/src/models/config.py @@ -145,8 +145,8 @@ class ServiceConfiguration(ConfigurationBase): workers: PositiveInt = 1 color_log: bool = True access_log: bool = True - tls_config: TLSConfiguration = TLSConfiguration() - cors: CORSConfiguration = CORSConfiguration() + tls_config: TLSConfiguration = Field(default_factory=TLSConfiguration) + cors: CORSConfiguration = Field(default_factory=CORSConfiguration) @model_validator(mode="after") def check_service_configuration(self) -> Self: @@ -371,7 +371,7 @@ class JwkConfiguration(ConfigurationBase): """JWK configuration.""" url: AnyHttpUrl - jwt_configuration: JwtConfiguration = JwtConfiguration() + jwt_configuration: JwtConfiguration = Field(default_factory=JwtConfiguration) class AuthenticationConfiguration(ConfigurationBase): @@ -458,12 +458,14 @@ class Configuration(ConfigurationBase): service: ServiceConfiguration llama_stack: LlamaStackConfiguration user_data_collection: UserDataCollection - database: DatabaseConfiguration = DatabaseConfiguration() - mcp_servers: list[ModelContextProtocolServer] = [] - authentication: AuthenticationConfiguration = AuthenticationConfiguration() + database: DatabaseConfiguration = Field(default_factory=DatabaseConfiguration) + mcp_servers: list[ModelContextProtocolServer] = Field(default_factory=list) + authentication: AuthenticationConfiguration = Field( + default_factory=AuthenticationConfiguration + ) authorization: Optional[AuthorizationConfiguration] = None customization: Optional[Customization] = None - inference: InferenceConfiguration = InferenceConfiguration() + inference: InferenceConfiguration = Field(default_factory=InferenceConfiguration) def dump(self, filename: str = "configuration.json") -> None: """Dump actual configuration into JSON file.""" diff --git a/tests/unit/models/config/test_authentication_configuration.py b/tests/unit/models/config/test_authentication_configuration.py index 481a5712..8e37c687 100644 --- a/tests/unit/models/config/test_authentication_configuration.py +++ b/tests/unit/models/config/test_authentication_configuration.py @@ -142,6 +142,7 @@ def test_authentication_configuration_module_unsupported() -> None: def test_authentication_configuration_in_config() -> None: """Test the authentication configuration in main config.""" + # pylint: disable=no-member cfg = Configuration( name="test_name", service=ServiceConfiguration(), diff --git a/tests/unit/models/config/test_tls_configuration.py b/tests/unit/models/config/test_tls_configuration.py index aafe0389..63633f42 100644 --- a/tests/unit/models/config/test_tls_configuration.py +++ b/tests/unit/models/config/test_tls_configuration.py @@ -22,6 +22,7 @@ def test_tls_configuration() -> None: def test_tls_configuration_in_service_configuration() -> None: """Test the TLS configuration in service configuration.""" + # pylint: disable=no-member cfg = ServiceConfiguration( tls_config=TLSConfiguration( tls_certificate_path=Path("tests/configuration/server.crt"),