From e0195f644218e77e0a7da217eee531633c89a303 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sat, 31 Jan 2026 06:07:00 +0000 Subject: [PATCH] fix: resolve CI/CD issues - fixed linting and type errors --- shell_speak/history.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/shell_speak/history.py b/shell_speak/history.py index 1f0ae69..866d4b8 100644 --- a/shell_speak/history.py +++ b/shell_speak/history.py @@ -2,18 +2,16 @@ import json from datetime import datetime -from pathlib import Path -from typing import List, Optional -from shell_speak.config import get_history_file, ensure_data_dir +from shell_speak.config import ensure_data_dir, get_history_file from shell_speak.models import HistoryEntry class HistoryManager: """Manages command history storage and retrieval.""" - def __init__(self): - self._entries: List[HistoryEntry] = [] + def __init__(self) -> None: + self._entries: list[HistoryEntry] = [] self._loaded = False def load(self) -> None: @@ -25,7 +23,7 @@ class HistoryManager: return try: - with open(history_file, 'r') as f: + with open(history_file) as f: data = json.load(f) self._entries = [] for item in data.get("entries", []): @@ -83,19 +81,19 @@ class HistoryManager: self.save() - def get_all(self) -> List[HistoryEntry]: + def get_all(self) -> list[HistoryEntry]: """Get all history entries.""" if not self._loaded: self.load() return self._entries.copy() - def get_recent(self, limit: int = 20) -> List[HistoryEntry]: + def get_recent(self, limit: int = 20) -> list[HistoryEntry]: """Get recent history entries.""" if not self._loaded: self.load() return self._entries[-limit:] - def search(self, query: str, tool: Optional[str] = None) -> List[HistoryEntry]: + def search(self, query: str, tool: str | None = None) -> list[HistoryEntry]: """Search history entries.""" if not self._loaded: self.load() @@ -110,7 +108,7 @@ class HistoryManager: return results - def get_last_command(self, tool: Optional[str] = None) -> Optional[HistoryEntry]: + def get_last_command(self, tool: str | None = None) -> HistoryEntry | None: """Get the last command from history.""" if not self._loaded: self.load() @@ -127,7 +125,7 @@ class HistoryManager: self.save() -_history_manager: Optional[HistoryManager] = None +_history_manager: HistoryManager | None = None def get_history_manager() -> HistoryManager: