Skip to content

[JULES] refactor(types): Replace Any type abuse with proper types - TYPE-001 #8

@JuanCS-Dev

Description

@JuanCS-Dev

Task Type

refactor - Type safety improvement

Component

Multiple modules

Problem Description

15+ instances of Any type used where specific types should be defined. This defeats the purpose of type hints and allows type errors at runtime.

Files to Modify (Top Priority)

  • vertice_cli/core/resilience.py - Multiple Any returns
  • vertice_cli/core/metrics.py - Dict[str, Any] overuse
  • vertice_cli/handlers/tool_execution_handler.py - Any parameters
  • vertice_tui/core/llm_client.py - Response typing

Current Code (Problematic)

# Common patterns to fix:
def process(self, data: Any) -> Any:  # What is data? What is returned?
    ...

config: Dict[str, Any] = {}  # What keys? What value types?

Expected Code (Fix)

from typing import TypedDict, Union
from dataclasses import dataclass

# Option 1: TypedDict for structured dicts
class MetricsConfig(TypedDict):
    enabled: bool
    interval: float
    exporters: list[str]

config: MetricsConfig = {"enabled": True, "interval": 60.0, "exporters": []}

# Option 2: Dataclass for complex types
@dataclass
class ProcessResult:
    success: bool
    data: str
    errors: list[str]

def process(self, data: InputData) -> ProcessResult:
    ...

# Option 3: Union for known variants
ResponseType = Union[TextResponse, StreamResponse, ErrorResponse]

Validation Commands

# Run mypy to check types
mypy vertice_cli/core/resilience.py --ignore-missing-imports

# Count remaining Any usage (should decrease)
grep -rn ": Any" vertice_cli/ --include="*.py" | wc -l

# Run tests
pytest tests/unit/ -v

Priority

medium

References

  • Python typing best practices
  • Audit ID: TYPE-001

Metadata

Metadata

Assignees

No one assigned

    Labels

    julesTask for Jules AImediumMedium priorityrefactorCode refactoring

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions