# Resolve four mypy contract violations with source-level typing fixes

> No shims, no fallback branches, and no cast-based suppression were introduced.

- Skill: `tools-only/resolve-four-mypy-contract-violations-with-source-level` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add tools-only/resolve-four-mypy-contract-violations-with-source-level`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tools-only/resolve-four-mypy-contract-violations-with-source-level/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tools-only (https://skillmd.com/u/tools-only)
- Updated: 2026-09-29
- Page: https://skillmd.com/skills/tools-only/resolve-four-mypy-contract-violations-with-source-level

---


# Resolve four mypy contract violations with source-level typing fixes

## Summary

Fixed the reported mypy errors by tightening type contracts at their source:

1. `editor.py`: added explicit Rich style narrowing so `Text.stylize()` always receives `StyleType`.
2. `web_fetch.py`: marked `_handle_http_error()` as `NoReturn` because it always raises.
3. `compaction/types.py`: made compaction status constants literal-typed (`Final[Literal[...]]`) and defined `CompactionStatus` as a type alias.
4. `shell_runner.py`: unpacked `render_bash()` tool render tuple and returned only the renderable content as required by `RenderableType`.

No shims, no fallback branches, and no cast-based suppression were introduced.

## Files changed

- `src/tunacode/ui/widgets/editor.py`
- `src/tunacode/tools/web_fetch.py`
- `src/tunacode/core/compaction/types.py`
- `src/tunacode/ui/shell_runner.py`

## Verification

- `uv run mypy src/tunacode/ui/widgets/editor.py src/tunacode/tools/web_fetch.py src/tunacode/core/compaction/controller.py src/tunacode/ui/shell_runner.py src/tunacode/core/compaction/types.py` ✅
- `uv run ruff check src/tunacode/ui/widgets/editor.py src/tunacode/tools/web_fetch.py src/tunacode/core/compaction/types.py src/tunacode/ui/shell_runner.py` ✅

