fix: resolve CI/CD issues - fixed linting and type errors
This commit is contained in:
@@ -1,20 +1,19 @@
|
||||
"""Pattern matching engine for shell commands."""
|
||||
|
||||
import re
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from shell_speak.library import get_loader
|
||||
from shell_speak.models import CommandPattern, CommandMatch
|
||||
from shell_speak.nlp import normalize_text, extract_keywords, calculate_similarity, tokenize
|
||||
from shell_speak.models import CommandMatch, CommandPattern
|
||||
from shell_speak.nlp import calculate_similarity, extract_keywords, normalize_text, tokenize
|
||||
|
||||
|
||||
class PatternMatcher:
|
||||
"""Matches natural language queries to command patterns."""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
self._loader = get_loader()
|
||||
|
||||
def match(self, query: str, tool: Optional[str] = None) -> Optional[CommandMatch]:
|
||||
def match(self, query: str, tool: str | None = None) -> CommandMatch | None:
|
||||
"""Match a query to the best command pattern."""
|
||||
normalized_query = normalize_text(query)
|
||||
self._loader.load_library(tool)
|
||||
@@ -84,7 +83,7 @@ class PatternMatcher:
|
||||
combined_score = (keyword_score * 0.6) + (best_similarity * 0.4)
|
||||
return min(combined_score, 1.0)
|
||||
|
||||
def _substitute_template(self, query: str, pattern: CommandPattern) -> Optional[str]:
|
||||
def _substitute_template(self, query: str, pattern: CommandPattern) -> str | None:
|
||||
"""Substitute variables in the template based on query."""
|
||||
template = pattern.template
|
||||
|
||||
@@ -96,7 +95,7 @@ class PatternMatcher:
|
||||
diff_tokens = query_tokens - pattern_tokens
|
||||
|
||||
variables = re.findall(r'\{(\w+)\}', template)
|
||||
var_values = {}
|
||||
var_values: dict[str, str] = {}
|
||||
|
||||
for var in variables:
|
||||
lower_var = var.lower()
|
||||
|
||||
Reference in New Issue
Block a user