Skip to content

Commit 3d5bbb8

Browse files
DYung26christianchimezie
authored andcommitted
refactor(codebase): resolve all 134 flake8 violations and reduce cyclomatic complexity
Eliminated all flake8 linting violations across the codebase: * W293 (87 violations): Removed trailing whitespace from blank lines in registry_loader.py, provider_manager.py, explanations.py, and utils.py * W391 (13 violations): Removed trailing blank lines at end of file in provider implementations and strategy files * F401 (4 violations): Removed unused datetime imports from registry_loader.py and builtins imports from utils.py and suggestions.py * E302 (4 violations): Added missing blank lines before top-level class definitions in strategy.py, enums, base.py, and utils.py * E261 (6 violations): Fixed inline comment spacing (single→double space before #) in ollama_openai.py and explanations.py * E305 (1 violation): Added blank line between _query_model method and module-level comment in explanations.py * E303 (1 violation): Removed extra blank line between methods in provider_manager.py * E501 (1 violation): Broke long function signature in ai_interface.py._query_parallel() across multiple lines * E251 (1 violation): Removed spaces around keyword parameter equals in explanations.py * F841 (1 violation): Removed unused 'link' variable in provider_manager.py._init_providers() Refactored 8 high-complexity functions to reduce cyclomatic complexity: * AIModelInterface.query_model (12→6): Extracted _route_vendor_query() for vendor routing logic * AIModelInterface.get_model_weights (12→4): Extracted _calculate_base_weight() helper * AIModelInterface._build_messages (11→4): Extracted 5 vendor-specific message builders * ProviderManager._init_providers (11→7): Extracted _init_provider_variants() for variant loop * RegistryLoader._validate_registry (12→5): Extracted validation helper methods * SmartPlotGenerator._create_scatter (14→8): Extracted dimension and title helpers * plotgen (12→6): Extracted _extract_and_override_variables() to eliminate duplication * VisualizationRecommender._apply_ensemble_scoring (13→4): Extracted recommendation collection helpers
1 parent 6c2c2f0 commit 3d5bbb8

24 files changed

Lines changed: 1114 additions & 1651 deletions

.coverage

24 KB
Binary file not shown.

plotsense/core/ai_interface.py

Lines changed: 237 additions & 257 deletions
Large diffs are not rendered by default.

plotsense/core/enums/strategy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from enum import Enum
22

3+
34
class StrategyName(str, Enum):
45
ROUND_ROBIN = "round_robin"
56
COST_OPTIMIZED = "cost_optimized"
67
PERFORMANCE = "performance"
78
FALLBACK_CHAIN = "fallback"
8-

plotsense/core/providers/anthropic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class AnthropicProvider(LLMProvider):
88
"""Provider integration for Anthropic's Claude models."""
9-
9+
1010
LINK = "👉 https://console.anthropic.com/account/keys 👈"
1111

1212
def __init__(self, api_key: str):
@@ -67,4 +67,3 @@ def validate_key(self) -> bool:
6767
return True
6868
except Exception:
6969
return False
70-

plotsense/core/providers/azure_openai.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,3 @@ def validate_key(self) -> bool:
8888
except Exception as e:
8989
print(f"⚠️ Azure OpenAI API key validation failed: {e}")
9090
return False
91-

plotsense/core/providers/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from abc import ABC, abstractmethod
22
from typing import List
33

4+
45
class LLMProvider(ABC):
56
"""Abstract base class for LLM providers."""
67

@@ -22,4 +23,3 @@ def list_models(self) -> List[str]:
2223
@abstractmethod
2324
def validate_key(self) -> bool:
2425
pass
25-

plotsense/core/providers/gemini.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def query(
4747
]
4848
else:
4949
# Text-only
50-
contents = prompt
50+
contents = prompt
5151

5252
self._init_client()
5353
if not self.client:

plotsense/core/providers/groq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class GroqProvider(LLMProvider):
99
"""Provider integration for Groq's fast inference API."""
10-
10+
1111
LINK = "👉 https://console.groq.com/keys 👈"
1212

1313
def __init__(self, api_key: str):

plotsense/core/providers/groq_openai.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class GroqOpenAIProvider(LLMProvider):
99
"""Provider for Groq models using the OpenAI-compatible SDK interface.
10-
10+
1111
This variant uses Groq's OpenAI-compatible API endpoint, allowing use
1212
of the OpenAI SDK with Groq's infrastructure.
1313
"""
@@ -74,4 +74,3 @@ def validate_key(self) -> bool:
7474
return bool(response)
7575
except Exception:
7676
return False
77-

plotsense/core/providers/ollama_openai.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def _init_client(self):
2323
if not self.client:
2424
# Default local Ollama endpoint
2525
self.client = OpenAI(
26-
base_url="http://localhost:11434/v1", # Ollama’s OpenAI-compatible API
27-
api_key=self.api_key or "ollama", # Dummy key for OpenAI client compatibility
26+
base_url="http://localhost:11434/v1", # Ollama’s OpenAI-compatible API
27+
api_key=self.api_key or "ollama", # Dummy key for OpenAI client compatibility
2828
)
2929

3030
def query(self, prompt: str, model: str, **kwargs) -> str:
@@ -73,4 +73,3 @@ def validate_key(self) -> bool:
7373
return bool(response)
7474
except Exception:
7575
return False
76-

0 commit comments

Comments
 (0)