Skip to content

Narrow bare dict/list annotations to parameterized types#15

Merged
alexkroman merged 1 commit into
mainfrom
claude/type-narrowing-opportunities-FNZOl
Jun 5, 2026
Merged

Narrow bare dict/list annotations to parameterized types#15
alexkroman merged 1 commit into
mainfrom
claude/type-narrowing-opportunities-FNZOl

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

Replace bare dict/list[dict] annotations with parameterized forms,
pinning keys to str (which catches non-string key access) and narrowing
values from implicit Any to object wherever the body only stringifies
or compares them — a strictly stronger guarantee that mypy now verifies.

  • audit/sessions render helpers: dict[str, object] (values only str()'d)
  • account render helpers, transcribe step renderer: dict[str, Any] (nested
    indexing/iteration still needs Any)
  • agent VoiceAgentSession event handlers + dispatch table: dict[str, Any]
    (dynamic JSON: b64decode, .get-by-key, etc.)
  • config._dump: dict[str, Any], matching _load's return type

Left deliberately broad: SDK/transcript getattr helpers, **-unpacked config
dicts, audio/stream handles, and dynamic _nested() — narrowing those would
require casts or misrepresent runtime shapes.

Replace bare `dict`/`list[dict]` annotations with parameterized forms,
pinning keys to `str` (which catches non-string key access) and narrowing
values from implicit `Any` to `object` wherever the body only stringifies
or compares them — a strictly stronger guarantee that mypy now verifies.

- audit/sessions render helpers: dict[str, object] (values only str()'d)
- account render helpers, transcribe step renderer: dict[str, Any] (nested
  indexing/iteration still needs Any)
- agent VoiceAgentSession event handlers + dispatch table: dict[str, Any]
  (dynamic JSON: b64decode, .get-by-key, etc.)
- config._dump: dict[str, Any], matching _load's return type

Left deliberately broad: SDK/transcript getattr helpers, **-unpacked config
dicts, audio/stream handles, and dynamic _nested() — narrowing those would
require casts or misrepresent runtime shapes.
@alexkroman alexkroman merged commit 72564da into main Jun 5, 2026
13 checks passed
@alexkroman alexkroman deleted the claude/type-narrowing-opportunities-FNZOl branch June 5, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants