diff --git a/pyproject.toml b/pyproject.toml index 42c10153..a123475e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ mypy = "^1.2.0" pylint = "^2.0.0" ruff = "^0.4.4" toml-sort = "^0.23.0" +types-PyYAML = "^6.0.0" types-requests = "^2.28.11.17" [tool.poetry.group.sphinx-deps.dependencies] diff --git a/src/groundlight/edge/config.py b/src/groundlight/edge/config.py index bf6339ac..3d476bb1 100644 --- a/src/groundlight/edge/config.py +++ b/src/groundlight/edge/config.py @@ -6,7 +6,7 @@ from typing_extensions import Self -class GlobalConfig(BaseModel): +class GlobalConfig(BaseModel): # pylint: disable=too-few-public-methods """Global runtime settings for edge-endpoint behavior.""" model_config = ConfigDict(extra="forbid") @@ -21,7 +21,7 @@ class GlobalConfig(BaseModel): ) -class InferenceConfig(BaseModel): +class InferenceConfig(BaseModel): # pylint: disable=too-few-public-methods """ Configuration for edge inference on a specific detector. """ @@ -71,7 +71,7 @@ def validate_configuration(self) -> Self: return self -class DetectorConfig(BaseModel): +class DetectorConfig(BaseModel): # pylint: disable=too-few-public-methods """ Configuration for a specific detector. """ @@ -93,15 +93,15 @@ class ConfigBase(BaseModel): @field_validator("edge_inference_configs", mode="before") @classmethod def hydrate_inference_config_names( - cls, value: dict[str, InferenceConfig | dict[str, Any]] | None - ) -> dict[str, InferenceConfig | dict[str, Any]]: + cls, value: Optional[dict[str, Union[InferenceConfig, dict[str, Any]]]] + ) -> dict[str, Union[InferenceConfig, dict[str, Any]]]: """Hydrate InferenceConfig.name from payload mapping keys.""" if value is None: return {} if not isinstance(value, dict): return value - hydrated_configs: dict[str, InferenceConfig | dict[str, Any]] = {} + hydrated_configs: dict[str, Union[InferenceConfig, dict[str, Any]]] = {} for name, config in value.items(): if isinstance(config, InferenceConfig): hydrated_configs[name] = config @@ -187,7 +187,7 @@ def from_yaml( if filename is not None: if not filename.strip(): raise ValueError("filename must be a non-empty path when provided.") - with open(filename, "r") as f: + with open(filename, "r", encoding="utf-8") as f: yaml_str = f.read() yaml_text = yaml_str or ""