From 4373978adbdc99586580cf34cf5e83c5e583347e Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sat, 31 Jan 2026 06:07:03 +0000 Subject: [PATCH] fix: resolve CI/CD issues - fixed linting and type errors --- shell_speak/library.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/shell_speak/library.py b/shell_speak/library.py index 092d9ad..16ae1ec 100644 --- a/shell_speak/library.py +++ b/shell_speak/library.py @@ -2,23 +2,22 @@ import json from pathlib import Path -from typing import Dict, List, Optional import yaml -from shell_speak.models import CommandPattern from shell_speak.config import get_data_dir +from shell_speak.models import CommandPattern class CommandLibraryLoader: """Loads and manages command pattern libraries.""" - def __init__(self): - self._patterns: List[CommandPattern] = [] - self._corrections: Dict[str, str] = {} + def __init__(self) -> None: + self._patterns: list[CommandPattern] = [] + self._corrections: dict[str, str] = {} self._loaded = False - def load_library(self, tool: Optional[str] = None) -> None: + def load_library(self, tool: str | None = None) -> None: """Load command patterns from library files.""" data_dir = get_data_dir() self._patterns = [] @@ -47,9 +46,9 @@ class CommandLibraryLoader: self._load_corrections() self._loaded = True - def _load_yaml_library(self, filepath: Path, tool: str) -> List[CommandPattern]: + def _load_yaml_library(self, filepath: Path, tool: str) -> list[CommandPattern]: """Load patterns from a YAML file.""" - with open(filepath, 'r') as f: + with open(filepath) as f: data = yaml.safe_load(f) or {} patterns = [] @@ -72,19 +71,19 @@ class CommandLibraryLoader: corrections_file = get_data_dir() / "corrections.json" if corrections_file.exists(): try: - with open(corrections_file, 'r') as f: + with open(corrections_file) as f: data = json.load(f) self._corrections = data.get("corrections", {}) except Exception: self._corrections = {} - def get_patterns(self) -> List[CommandPattern]: + def get_patterns(self) -> list[CommandPattern]: """Get all loaded patterns.""" if not self._loaded: self.load_library() return self._patterns - def get_corrections(self) -> Dict[str, str]: + def get_corrections(self) -> dict[str, str]: """Get all user corrections.""" if not self._loaded: self.load_library() @@ -121,7 +120,7 @@ class CommandLibraryLoader: self.load_library() -_loader: Optional[CommandLibraryLoader] = None +_loader: CommandLibraryLoader | None = None def get_loader() -> CommandLibraryLoader: