Skip to content

Enable --strict mypy: eliminate Any-typed fields and implicit returns #100

@bradjin8

Description

@bradjin8

Problem

The cppa-cursor-browser codebase has no type annotations on any function signatures. All structured data flows through untyped dicts with .get() chains and no TypedDict, dataclass, or mypy configuration. The baseline eval explicitly calls this out: "For a tool whose primary value is export fidelity — preserving the structure of AI conversations — the absence of a typed data model increases the risk of silent data corruption during format changes." The "bubble" concept has three different dict shapes across code paths with no type enforcement to catch shape mismatches at development time.

Acceptance Criteria

  • mypy is added to project dependencies with a [tool.mypy] config section
  • --strict mode is enabled (or strict = true in config)
  • Core data models are defined as TypedDict or dataclass (at minimum: Bubble, Workspace, Conversation, SearchResult)
  • All API route handler functions have complete type annotations (parameters and return types)
  • All utils/ module functions have complete type annotations
  • mypy passes with zero errors on the annotated modules (use per-module overrides for scripts/export.py if needed)
  • Tests pass in CI (if applicable)
  • PR approved by at least 1 reviewer

Implementation Notes

This is a large typing effort — prioritize the data model layer first, then route handlers. Create a models.py (or types.py) at the project root or under utils/ that defines TypedDict classes for the core shapes: BubbleDict (with metadata, tool, thinking fields), WorkspaceEntry, ConversationSummary, SearchHit. Replace dict annotations with these throughout api/workspaces.py, api/composers.py, api/search.py, and utils/. For functions that currently return implicit None (missing return statements on error paths), add explicit -> Optional[X] annotations and handle the None case. Add mypy to the CI workflow (.github/workflows/tests.yml if it exists). The three bubble shapes identified in the eval (workspace tabs shape, export shape, CLI reader shape) should converge on a single TypedDict or use a union type with discriminator.

References

  • Eval finding: Test 6, cluster "type-safety"
  • Related files: api/workspaces.py, api/composers.py, api/search.py, api/export_api.py, utils/cli_chat_reader.py, app.py, requirements.txt

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions