Skip to content

[type-safety] Dict[str, Any] defeats type checking in yaml_test_runner.py #26

@wody34

Description

@wody34

📁 Location

  • File: tests/python_runners/yaml_test_runner.py:36-52
  • Category: type-safety
  • Severity: medium
  • Hashes: 2597bc4af5e8, 542e22ff34ca

🔍 Problem

Dataclass fields use Dict[str, Any] which disables type checking for dictionary values. This allows invalid configurations to pass silently.

Affected Fields

  • ProcessConfig.communication: Dict[str, Any]
  • ProcessConfig.execution: Dict[str, Any]
  • TestConfig.environment: Dict[str, Any]
  • TestConfig.setup: Dict[str, Any]
  • TestConfig.validation: Dict[str, Any]
  • TestConfig.logging: Dict[str, Any]
  • TestConfig.test_matrix: Dict[str, Any]

💡 Fix

from typing import TypedDict, Literal

# Before
@dataclass
class ProcessConfig:
    communication: Dict[str, Any] = field(default_factory=dict)

# After
class CommunicationConfig(TypedDict, total=False):
    port_file: str
    protocol: Literal['mpi', 'file', 'socket']
    timeout: int
    buffer_size: int

@dataclass
class ProcessConfig:
    communication: CommunicationConfig = field(default_factory=dict)

🧪 TDD Evidence

Test file: tests/evidence/test_type_safety_yaml_runner.py

  • Demonstrates TypedDict pattern passes mypy --strict
  • Documents current broken state with Any
tests/evidence/test_type_safety_yaml_runner.py::TestTypeSafetyYamlRunner::test_process_config_communication_has_typed_dict PASSED
tests/evidence/test_type_safety_yaml_runner.py::TestTypeSafetyYamlRunner::test_test_config_environment_has_typed_dict PASSED

Run: 2026-02-05-1228 | Auto-generated by UltraQA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions