fix: resolve CI/CD issues - fixed linting and type errors
Some checks failed
CI / test (push) Has been cancelled
CI / build (push) Has been cancelled

This commit is contained in:
2026-01-31 06:07:03 +00:00
parent fcf10670e3
commit 4373978adb

View File

@@ -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: