---
name: Python Bot Type Hints (Tavus Tool Forwarder)
status: closed
created: 2025-10-13T11:02:21Z
updated: 2025-10-13T19:48:42Z
github: https://github.com/BuzzTrail/video-extension/issues/134
depends_on: []
parallel: true
conflicts_with: [006]
---

# Task: Python Bot Type Hints (Tavus Tool Forwarder)

## Description

Add complete type hints to the Tavus tool forwarder bot codebase, set up Python virtual environment with `uv`, configure mypy for type checking, and fix all type errors. Target 100% type hint coverage for all function signatures.

## Acceptance Criteria

- [ ] Python environment set up with `uv venv` and activated
- [ ] mypy and type stubs installed via `uv pip install`
- [ ] Type hints added to all functions in tavus-tool-forwarder modules
- [ ] `pyproject.toml` created with mypy configuration
- [ ] mypy passes with 0 errors: `mypy .`
- [ ] Bot runs without errors after type hint addition
- [ ] Existing tests continue to pass (if any)

## Technical Details

**Phase 1: Environment Setup**
```bash
cd apps/slide-system/bots/tavus-tool-forwarder

# Create virtual environment with uv
uv venv

# Activate environment
source .venv/bin/activate

# Install mypy and type stubs
uv pip install mypy types-aiohttp types-requests
```

**Phase 2: Create mypy Configuration**

Create `apps/slide-system/bots/tavus-tool-forwarder/pyproject.toml`:
```toml
[tool.mypy]
python_version = "3.11"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
ignore_missing_imports = false
show_error_codes = true
```

**Phase 3: Add Type Hints**

Files to update (based on tool forwarder architecture):
- `bot.py` - Main bot entry point
- Motia endpoint handlers
- API client integrations
- Supporting utility modules

Example patterns:
```python
from typing import Dict, Optional, Any, List, Literal
from motiadev.core import MotiaRequest, EmitFn

# Before
def handler(req, emit):
    ...

# After
def handler(req: MotiaRequest, emit: EmitFn) -> Dict[str, Any]:
    """Handle tool forwarding request."""
    ...

# Before
async def forward_tool_call(tool_name, args):
    ...

# After
async def forward_tool_call(
    tool_name: str,
    args: Dict[str, Any]
) -> Dict[str, Any]:
    """Forward tool call to appropriate handler."""
    ...
```

**Phase 4: Run mypy and Fix Errors**
```bash
# Run mypy
mypy bot.py

# Fix errors iteratively
# Re-run until 0 errors
```

**Phase 5: Validate**
```bash
# Run tests if available
pytest

# Start bot to verify runtime behavior
python bot.py --test
```

**Testing**:
- All existing tests must pass (if any)
- Manual smoke test: verify bot can forward tool calls
- Check Motia endpoint integration
- Verify Tavus API integration still works

## Dependencies

- [ ] No external dependencies - can start immediately
- [ ] Can run in parallel with Task 006 (different bot)

## Effort Estimate

- **Size**: M
- **Hours**: 4 hours
- **Parallel**: true (independent of Task 006)

## Definition of Done

- [ ] 100% function type hint coverage
- [ ] mypy passes with 0 errors
- [ ] All existing tests pass
- [ ] Bot runs without runtime errors
- [ ] Type hints documented in module docstrings
- [ ] Code review completed
- [ ] `.venv` added to `.gitignore` (if not already)
