diff --git a/src/config/loader.py b/src/config/loader.py index 9d172a0..e453daa 100644 --- a/src/config/loader.py +++ b/src/config/loader.py @@ -1,13 +1,9 @@ -"""Configuration loader module.""" - +"""Configuration loader.""" from pathlib import Path from typing import List, Optional - import yaml - from ..models import Rule - class ConfigLoader: def __init__(self): self._config_paths = [ @@ -16,12 +12,12 @@ class ConfigLoader: ] self._default_config_path = Path(__file__).parent.parent.parent / "config" / "default_rules.yaml" - def load_default_rules(self) -> List[Rule]: + def load_default_rules(self): if self._default_config_path.exists(): return self.load_from_file(self._default_config_path) return [] - def load_from_file(self, path: Path) -> List[Rule]: + def load_from_file(self, path): rules = [] try: with open(path, "r") as f: @@ -34,14 +30,14 @@ class ConfigLoader: raise ValueError(f"Invalid YAML syntax: {e}") return rules - def load_user_rules(self) -> List[Rule]: + def load_user_rules(self): rules = [] for config_path in self._config_paths: if config_path.exists(): rules.extend(self.load_from_file(config_path)) return rules - def load_merged_rules(self, custom_rules: Optional[List[Rule]] = None) -> List[Rule]: + def load_merged_rules(self, custom_rules=None): rules = self.load_default_rules() user_rules = self.load_user_rules() rule_dict = {r.id: r for r in rules} @@ -49,8 +45,7 @@ class ConfigLoader: rule_dict[r.id] = r return list(rule_dict.values()) - -def load_rules(config_path: Optional[str] = None) -> List[Rule]: +def load_rules(config_path=None): loader = ConfigLoader() if config_path: return loader.load_from_file(Path(config_path))