fix: resolve CI/CD issues - fixed linting and type errors
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user