Skip to content

Add Complete Type Hints to Telemetry Module #7

@naji247

Description

@naji247

Overview

The telemetry module (src/mcpcat/modules/telemetry.py) and related exporter modules lack complete type hints. Adding proper type annotations would improve code maintainability, IDE support, and help prevent type-related bugs.

Current State

Several functions and methods in the telemetry system are missing type hints or have incomplete annotations. This makes it harder for developers to understand the expected types and for tools to provide accurate autocomplete and type checking.

Requirements

Add complete type hints to:

  1. TelemetryManager class - All methods and attributes
  2. Exporter base class - Interface definition
  3. Concrete exporters - OTLP, Datadog, Sentry implementations
  4. Helper functions - Any utility functions in the module

Why This Matters

  • Improves IDE autocomplete and suggestions
  • Catches type-related bugs during development
  • Makes the codebase more maintainable
  • Helps new contributors understand the code faster
  • Enables better static analysis with tools like mypy

Acceptance Criteria

  • All public methods have complete type hints
  • All function parameters have type annotations
  • All return types are specified
  • Complex types use appropriate typing imports (Dict, List, Optional, etc.)
  • Type hints pass mypy checks without errors
  • No runtime behavior changes

Getting Started

  1. Review Python typing best practices
  2. Look at existing type hints in other modules for consistency
  3. Start with the TelemetryManager class
  4. Use typing module imports as needed
  5. Test with mypy to ensure correctness

Notes

  • Use Optional[T] for nullable types
  • Consider using TypedDict for complex dictionary structures
  • Keep type hints readable and not overly complex
  • This is a great way to learn the telemetry system architecture

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions