Repository navigation
chore: remove remaining mypy exclusions across the repo - #214
Conversation
Walk-the-list sweep across the mypy exclude list. Removes 26 files
with small-to-medium error counts, leaving 128 files excluded. Every
fix is a real type-safety improvement — none are shims.
Per-file fixes, grouped by theme:
Enum/Literal coercions at call sites:
- sources/parsers/chatgpt.py: str → ContentBlockType.{TEXT,THINKING,IMAGE}
- sources/parsers/codex.py: same + candidates list typed as datetime
- sources/parsers/claude_ai_parser.py: same + drop duplicate var annotations
that triggered no-redef across try/except branches
- sources/parsers/drive_support_blocks.py: same + type Any for
block parameter, narrow metadata via local bind
- sources/parsers/drive_support_text.py: candidates list typed as
datetime so .sort(key=...) sees a comparable type
- showcase/generators.py: pass ExerciseIOMode.READ enum literal, not
the string "read"
- schemas/relational_inference_strings.py: wrap length_stats lookups
in int() for StringLengthProfile's int fields
None/Optional narrowing:
- schemas/extraction.py: bind paths.get(key) to a local, guard
truthiness there so mypy narrows across the use
- sources/emitter.py: gate _restore_stream_start on
`stream_start is not None`; drop two unused type:ignore markers
- storage/backends/queries/message_query_stats.py: handle None from
fetchone() before indexing
Concrete types replacing object/Any:
- lib/provider_semantics.py: normalize `provider: Provider | str`
into Provider via isinstance/from_string before constructing
ReasoningTrace / ToolCall which require Provider | None
- lib/attribution.py: guard iteration over
`provider_meta.get("working_directories")` with
isinstance(list|tuple) since provider_meta values are object
- mcp/server_prompts.py: use MessageCollection.to_list()[:3] so mypy
sees list[Message] rather than the Message|list[Message] union
from __getitem__
- mcp/server_maintenance_tools.py: isinstance-narrow
status_info.get(...) before passing to MCPMutationStatusPayload
- storage/action_event_rows.py: `content_blocks: Sequence[object]` →
`Sequence[ContentBlockRecord]`; all callers already pass that
- storage/backends/queries/conversations_reads.py: fetchone None check
- storage/backends/queries/conversations_identity.py: list(fetchall())
so len() and indexing see Sized
- storage/backends/queries/message_query_reads.py: same list() wrap
- storage/session_product_timeline_rows.py: cast str → ConversationId
NewType; use explicit 2-tuple for message_range instead of tuple(...)
Async / context-manager annotations:
- sources/drive_source_client.py: cast NamedTemporaryFile handle to
BinaryIO for DriveServiceGateway.download_file
- site/index_pages.py: `write_stream: Callable[..., object]` →
`Callable[..., Awaitable[None]]`, so awaits type-check
- storage/backends/async_sqlite.py: annotate connection(),
read_connection(), _get_read_connection(), bulk_connection() as
AbstractAsyncContextManager[...]. File stays in exclude (other
errors remain), but the annotations unblock callers
Property / attribute declarations:
- lib/projection_transform_mixin.py: declare `_limit: int | None`,
`_offset: int`, `_reverse: bool` at class scope so
ProjectionTransformMixin matches the `int | None` annotation on
the ConversationProjection subclass (lib/projections.py:47)
Signature tightening:
- cli/machine_main.py: normalize `click.BadParameter.param_hint`
(Sequence[str] | str | None) to str | None via ternary
- pipeline/run_planning.py: tuple(stage_sequence) at forwarding site
so PlanningService.build_plan(list[str] | tuple[str, ...]) sees
the right type
- pipeline/services/acquisition.py: isinstance-narrow
cursor_state["error_count"] before `+ 1`; storage-backend
connection() annotation unblocks `bulk_connection()` call
- pipeline/prepare_models.py: storage-backend connection()
annotation unblocks `connection()` call
- storage/search_providers/fts5.py: convert MessageRecord list to
(message_id, conversation_id, text) tuples so it matches the
Sequence[tuple[str, str, str | None]] variant of
replace_fts_rows_for_messages_sync
Builtin-name / dead-code:
- lib/raw_payload_sampling_extract.py: rename inner `selected` →
`stratified_selected` to avoid no-redef across the earlier
unstratified branch; annotate Counter[str]; widen the
stream binding to IO[Any]
- rendering/core_formatter.py: already in previous PR
- ui/__init__.py: make _call_prompt generic via TypeVar instead of
object → object, so confirm()/choose()/input() preserve their
return types through the wrapper
- sync_bridge.py: keep Awaitable[T] parameter for existing callers,
cast to Coroutine at the asyncio.run call sites
- schemas/operator_inference.py: type audit_schemas(request) with
SchemaAuditRequest / AuditReport (stays in exclude due to an
unrelated dict[Provider,...] overload at line 233)
- lib/conversation_runtime.py: annotate Conversation.project() →
ConversationProjection, deferred-imported under TYPE_CHECKING
- schemas/unified_models.py: _missing_role() → NoReturn so
HarmonizedMessage.role construction sees `Role`, not `Role | str`
Gate grows from 410 → 436 files.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughThis PR improves type safety across the codebase by: adding explicit return type annotations to methods and parameters, replacing string literal type indicators with enum values ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 757c137d2d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
polylogue/storage/backends/async_sqlite.py (1)
407-427: 🧹 Nitpick | 🔵 TrivialConsider annotating similar context manager methods for consistency.
The methods
read_pool()(line 407),_get_connection()(line 411), andtransaction()(line 425) follow the same pattern as the methods annotated in this PR—they return the result of calling@asynccontextmanager-decorated functions—but lack explicit return type annotations:
read_pool()→_read_pool()at line 276 should be annotated-> AbstractAsyncContextManager[None]_get_connection()→_get_connection()at line 302 should be annotated-> AbstractAsyncContextManager[aiosqlite.Connection]transaction()→_backend_transaction()at line 135 should be annotated-> AbstractAsyncContextManager[None]Since the PR summary mentions "file remains excluded for other errors," these may be the remaining gaps.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@polylogue/storage/backends/async_sqlite.py` around lines 407 - 427, Add explicit return type annotations to match the `@asynccontextmanager-decorated` helpers: annotate read_pool(self, size: int = 4) as -> AbstractAsyncContextManager[None], annotate _get_connection(self) as -> AbstractAsyncContextManager[aiosqlite.Connection], and annotate transaction(self) as -> AbstractAsyncContextManager[None]; ensure AbstractAsyncContextManager is imported from typing (or typing_extensions) and aiosqlite.Connection is referenced so the annotations resolve.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@polylogue/mcp/server_maintenance_tools.py`:
- Around line 30-31: The code currently defaults index_exists to False and
indexed_messages to 0, which masks unknown state and misinterprets booleans as
ints; update the assignment to use None for unknown/missing values and prevent
bools being treated as ints: set index_exists = index_exists_value if
isinstance(index_exists_value, bool) else None, and set indexed_messages =
indexed_messages_value if isinstance(indexed_messages_value, int) and not
isinstance(indexed_messages_value, bool) else None so MCPMutationStatusPayload
reflects bool | None and int | None correctly.
In `@polylogue/mcp/server_prompts.py`:
- Line 177: The current code materializes the entire message list via
conv.messages.to_list() before slicing; change it to iterate only the first
three items (e.g., use itertools.islice) so you avoid an O(n) copy: replace
conv.messages.to_list()[:3] with an iterator-limited form such as
itertools.islice(conv.messages, 3) and keep the rest of the comprehension
(m.text[:150] for m ... if m.text) intact; ensure you import itertools.islice
and update the expression where first_msgs is constructed.
In `@polylogue/sources/parsers/drive_support_blocks.py`:
- Line 12: Define a lightweight Protocol (e.g., ContentBlockProtocol) that
declares the attributes accessed by viewport_block_payload — type, text,
language, mime_type, raw, and url — and import Protocol from typing; then change
the viewport_block_payload signature from block: Any to block:
ContentBlockProtocol (or Optional[ContentBlockProtocol] if nullable) so static
checkers can verify usage while keeping structural flexibility, and update any
related imports/annotations accordingly.
In `@polylogue/storage/session_product_timeline_rows.py`:
- Around line 302-304: The message_range hydration currently assumes
payload.get("message_range") is a two-item sequence and directly indexes [0] and
[1]; update the code that builds message_range to first retrieve msg_range =
payload.get("message_range"), validate it's a sequence (list/tuple) with at
least two items, and safely coerce each element to int with try/except/TypeError
fallback to record.start_index and record.end_index as defaults; if msg_range is
missing, not a sequence, or elements are invalid, use (record.start_index,
record.end_index). Ensure you reference payload, message_range, and
record.start_index/record.end_index when replacing the existing two-index
construction.
---
Outside diff comments:
In `@polylogue/storage/backends/async_sqlite.py`:
- Around line 407-427: Add explicit return type annotations to match the
`@asynccontextmanager-decorated` helpers: annotate read_pool(self, size: int = 4)
as -> AbstractAsyncContextManager[None], annotate _get_connection(self) as ->
AbstractAsyncContextManager[aiosqlite.Connection], and annotate
transaction(self) as -> AbstractAsyncContextManager[None]; ensure
AbstractAsyncContextManager is imported from typing (or typing_extensions) and
aiosqlite.Connection is referenced so the annotations resolve.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: bbb8a851-23a4-443e-9410-80cab7004d24
📒 Files selected for processing (28)
polylogue/lib/conversation_runtime.pypolylogue/lib/projection_transform_mixin.pypolylogue/lib/provider_semantics.pypolylogue/lib/raw_payload_sampling_extract.pypolylogue/mcp/server_maintenance_tools.pypolylogue/mcp/server_prompts.pypolylogue/pipeline/services/acquisition.pypolylogue/schemas/extraction.pypolylogue/schemas/operator_inference.pypolylogue/schemas/relational_inference_strings.pypolylogue/showcase/generators.pypolylogue/site/index_pages.pypolylogue/sources/drive_source_client.pypolylogue/sources/emitter.pypolylogue/sources/parsers/chatgpt.pypolylogue/sources/parsers/claude_ai_parser.pypolylogue/sources/parsers/codex.pypolylogue/sources/parsers/drive_support_blocks.pypolylogue/sources/parsers/drive_support_text.pypolylogue/storage/backends/async_sqlite.pypolylogue/storage/backends/queries/conversations_identity.pypolylogue/storage/backends/queries/message_query_reads.pypolylogue/storage/backends/queries/message_query_stats.pypolylogue/storage/search_providers/fts5.pypolylogue/storage/session_product_timeline_rows.pypolylogue/sync_bridge.pypolylogue/ui/__init__.pypyproject.toml
💤 Files with no reviewable changes (1)
- pyproject.toml
| index_exists=index_exists_value if isinstance(index_exists_value, bool) else False, | ||
| indexed_messages=indexed_messages_value if isinstance(indexed_messages_value, int) else 0, |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
In Python, is boola subclass ofint, and does isinstance(True, int)returnTrue?
💡 Result:
Yes, bool is a subclass of int in Python, and isinstance(True, int) returns True. This is confirmed by official Python documentation for versions up to 3.14. The bool class explicitly inherits from int, as stated in the built-in types documentation: "Booleans are a subtype of integers" and "bool is a subclass of int". The C API documentation also states: "Booleans in Python are implemented as a subclass of integers." Interactive examples from sources like Stack Overflow and Python's help output show: - issubclass(bool, int) returns True - isinstance(True, int) returns True - bool.mro includes (<class 'bool'>, <class 'int'>, <class 'object'>) This design originates from PEP 285 for backwards compatibility, allowing True and False to behave like 1 and 0 in numeric contexts. No changes to this inheritance have occurred in recent Python versions (3.12-3.14), only minor internal optimizations like making True/False immortal.
Citations:
- 1: https://peps.python.org/pep-0285/
- 2: https://docs.python.org/3/library/functions.html?highlight=isinstance
- 3: https://docs.python.org/3/library/stdtypes.html
- 4: https://docs.python.org/3/library/functions.html
- 5: https://docs.python.org/3.14/c-api/bool.html
- 6: https://stackoverflow.com/questions/8169001/why-is-bool-a-subclass-of-int
- 7: https://stackoverflow.com/questions/8169001/why-is-bool-a-subclass-of-int/8169049
- 8: https://stackoverflow.com/questions/37888620/comparing-boolean-and-int-using-isinstance
- 9: https://docs.python.org/3.12/c-api/bool.html
🏁 Script executed:
cat -n polylogue/mcp/server_maintenance_tools.py | sed -n '20,50p'Repository: Sinity/polylogue
Length of output: 1722
🏁 Script executed:
rg -B 5 -A 10 "class MCPMutationStatusPayload" polylogue/Repository: Sinity/polylogue
Length of output: 845
Use None for unknown/missing state instead of False/0, and exclude bool from indexed_messages type check.
The index_exists and indexed_messages fields are typed as bool | None and int | None respectively in MCPMutationStatusPayload. Using False and 0 as fallbacks misrepresents unknown/missing state as definitive values. Additionally, isinstance(x, int) returns True for booleans since bool is a subclass of int in Python, so the indexed_messages check needs an explicit not isinstance(indexed_messages_value, bool) guard.
Suggested fix
- index_exists=index_exists_value if isinstance(index_exists_value, bool) else False,
- indexed_messages=indexed_messages_value if isinstance(indexed_messages_value, int) else 0,
+ index_exists=index_exists_value if isinstance(index_exists_value, bool) else None,
+ indexed_messages=(
+ indexed_messages_value
+ if isinstance(indexed_messages_value, int) and not isinstance(indexed_messages_value, bool)
+ else None
+ ),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@polylogue/mcp/server_maintenance_tools.py` around lines 30 - 31, The code
currently defaults index_exists to False and indexed_messages to 0, which masks
unknown state and misinterprets booleans as ints; update the assignment to use
None for unknown/missing values and prevent bools being treated as ints: set
index_exists = index_exists_value if isinstance(index_exists_value, bool) else
None, and set indexed_messages = indexed_messages_value if
isinstance(indexed_messages_value, int) and not
isinstance(indexed_messages_value, bool) else None so MCPMutationStatusPayload
reflects bool | None and int | None correctly.
| summaries = [] | ||
| for conv in convs: | ||
| first_msgs = [m.text[:150] for m in conv.messages[:3] if m.text] | ||
| first_msgs = [m.text[:150] for m in conv.messages.to_list()[:3] if m.text] |
There was a problem hiding this comment.
Avoid full-list copy when only first 3 messages are needed.
At Line 177, conv.messages.to_list()[:3] materializes the entire message list per conversation, then slices it. This can add unnecessary O(n) copying for long threads.
⚡ Proposed fix (type-safe and bounded)
+from itertools import islice
@@
- first_msgs = [m.text[:150] for m in conv.messages.to_list()[:3] if m.text]
+ first_msgs = [m.text[:150] for m in islice(conv.messages, 3) if m.text]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| first_msgs = [m.text[:150] for m in conv.messages.to_list()[:3] if m.text] | |
| from itertools import islice | |
| # ... (at the location where the import should be added at the top of the file) ... | |
| first_msgs = [m.text[:150] for m in islice(conv.messages, 3) if m.text] |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@polylogue/mcp/server_prompts.py` at line 177, The current code materializes
the entire message list via conv.messages.to_list() before slicing; change it to
iterate only the first three items (e.g., use itertools.islice) so you avoid an
O(n) copy: replace conv.messages.to_list()[:3] with an iterator-limited form
such as itertools.islice(conv.messages, 3) and keep the rest of the
comprehension (m.text[:150] for m ... if m.text) intact; ensure you import
itertools.islice and update the expression where first_msgs is constructed.
|
|
||
|
|
||
| def viewport_block_payload(block) -> dict[str, object] | None: | ||
| def viewport_block_payload(block: Any) -> dict[str, object] | None: |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Call sites =="
rg -nP --type=py '\bviewport_block_payload\s*\(' -C2
echo
echo "== Attributes currently used in viewport_block_payload =="
rg -nP '\bblock\.(type|text|language|mime_type|raw|url)\b' polylogue/sources/parsers/drive_support_blocks.pyRepository: Sinity/polylogue
Length of output: 1018
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Searching for all calls to viewport_block_payload =="
rg -rn 'viewport_block_payload' --type=py | head -30
echo
echo "== Full context of the function to confirm attribute usage =="
sed -n '12,40p' polylogue/sources/parsers/drive_support_blocks.pyRepository: Sinity/polylogue
Length of output: 1640
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Context around the _n(cb) call in drive.py =="
rg -B5 -A5 '_n\(cb\)' polylogue/sources/parsers/drive.py
echo
echo "== Check the imports and function signatures in drive.py =="
head -50 polylogue/sources/parsers/drive.pyRepository: Sinity/polylogue
Length of output: 108
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Check what n is imported as and where it's used =="
rg -B2 -A10 'from.*drive_support.*import' polylogue/sources/parsers/drive.py
echo
echo "== Look for block_payload or similar function calls =="
rg -n 'block_payload\|_n\(' polylogue/sources/parsers/drive.py | head -20Repository: Sinity/polylogue
Length of output: 1113
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Find calls to _viewport_block_payload =="
rg -n '_viewport_block_payload' polylogue/sources/parsers/drive.py -A3 -B3
echo
echo "== Look for what cb/block objects are =="
rg -n 'for.*in.*content_blocks\|viewport_block' polylogue/sources/parsers/drive.py -B2 -A5Repository: Sinity/polylogue
Length of output: 653
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Find gem variable definition context =="
rg -B10 'gem.extract_content_blocks()' polylogue/sources/parsers/drive.py | head -30
echo
echo "== Search for extract_content_blocks method definition =="
rg -n 'def extract_content_blocks' --type=py
echo
echo "== Check imports and type hints in drive_support_blocks.py =="
head -30 polylogue/sources/parsers/drive_support_blocks.pyRepository: Sinity/polylogue
Length of output: 2302
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Find ContentBlock definition =="
rg -n 'class ContentBlock|ContentBlockType' polylogue/types.py -A15 | head -50
echo
echo "== Check what ContentBlock has =="
rg -n '^class ContentBlock' --type=py -A30Repository: Sinity/polylogue
Length of output: 7374
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Find ContentType definition =="
rg -n 'class ContentType|ContentType.*=' polylogue/lib/viewport_models.py -B2 -A5 | head -40
echo
echo "== Check imports in viewport_models.py =="
head -30 polylogue/lib/viewport_models.pyRepository: Sinity/polylogue
Length of output: 93
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Search for ContentType definition across codebase =="
rg -n '^class ContentType|^ContentType\s*=' --type=py
echo
echo "== Check imports in viewport_models.py to see where ContentType comes from =="
rg -n 'ContentType|from|import' polylogue/lib/viewport_models.py | head -20Repository: Sinity/polylogue
Length of output: 831
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== Get full ContentBlock definition =="
sed -n '104,112p' polylogue/lib/viewport_models.py
echo
echo "== Get ContentType definition =="
cat polylogue/lib/viewport_enums.pyRepository: Sinity/polylogue
Length of output: 1110
Use a Protocol to replace Any for better type safety.
The function currently receives ContentBlock objects from extract_content_blocks() and accesses only type, text, language, mime_type, raw, and url. A Protocol that defines these attributes would document the expected interface and enable static type checking without losing flexibility.
♻️ Suggested refactor
-from typing import Any
+from typing import Protocol
+class _ViewportBlock(Protocol):
+ type: object # ContentType enum with .value attribute
+ text: str | None
+ language: str | None
+ mime_type: str | None
+ raw: dict[str, object]
+ url: str | None
-def viewport_block_payload(block: Any) -> dict[str, object] | None:
+def viewport_block_payload(block: _ViewportBlock) -> dict[str, object] | None:🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@polylogue/sources/parsers/drive_support_blocks.py` at line 12, Define a
lightweight Protocol (e.g., ContentBlockProtocol) that declares the attributes
accessed by viewport_block_payload — type, text, language, mime_type, raw, and
url — and import Protocol from typing; then change the viewport_block_payload
signature from block: Any to block: ContentBlockProtocol (or
Optional[ContentBlockProtocol] if nullable) so static checkers can verify usage
while keeping structural flexibility, and update any related imports/annotations
accordingly.
| message_range=( | ||
| int(payload.get("message_range", [record.start_index, record.end_index])[0]), | ||
| int(payload.get("message_range", [record.start_index, record.end_index])[1]), |
There was a problem hiding this comment.
Harden message_range hydration against malformed payloads.
Line 303 and Line 304 assume at least two items whenever message_range exists. If stored data contains [], [x], or a non-sequence, hydration will raise and fail the whole row load.
🛠️ Proposed defensive fix
def hydrate_session_phase(record: SessionPhaseRecord) -> SessionPhase:
payload = {**record.evidence_payload, **record.inference_payload}
+ raw_message_range = payload.get("message_range")
+ if (
+ isinstance(raw_message_range, (list, tuple))
+ and len(raw_message_range) >= 2
+ ):
+ message_range = (int(raw_message_range[0]), int(raw_message_range[1]))
+ else:
+ message_range = (int(record.start_index), int(record.end_index))
+
return SessionPhase(
start_time=(datetime.fromisoformat(str(payload["start_time"])) if payload.get("start_time") else None),
end_time=(datetime.fromisoformat(str(payload["end_time"])) if payload.get("end_time") else None),
canonical_session_date=(
datetime.fromisoformat(str(payload["canonical_session_date"])).date()
if payload.get("canonical_session_date")
else None
),
- message_range=(
- int(payload.get("message_range", [record.start_index, record.end_index])[0]),
- int(payload.get("message_range", [record.start_index, record.end_index])[1]),
- ),
+ message_range=message_range,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@polylogue/storage/session_product_timeline_rows.py` around lines 302 - 304,
The message_range hydration currently assumes payload.get("message_range") is a
two-item sequence and directly indexes [0] and [1]; update the code that builds
message_range to first retrieve msg_range = payload.get("message_range"),
validate it's a sequence (list/tuple) with at least two items, and safely coerce
each element to int with try/except/TypeError fallback to record.start_index and
record.end_index as defaults; if msg_range is missing, not a sequence, or
elements are invalid, use (record.start_index, record.end_index). Ensure you
reference payload, message_range, and record.start_index/record.end_index when
replacing the existing two-index construction.
## Summary Finish the repo-wide mypy cleanup by removing the remaining per-file exclusions and tightening type contracts across `polylogue/`, `tests/`, and `devtools/`. The branch also folds in the repo-root cleanup and devshell MOTD improvements that landed during the sweep. ## Problem The strict type-checking gate had been restored only for a subset of the repository, with a long tail of excluded source, test, and maintenance files in `pyproject.toml`. That debt was slowing down refactors, hiding real contract problems behind the exclude list, and leaving the repo in an awkward half-green state. In parallel, some disposable cache roots had leaked into the top level and the devshell entry messaging had stopped being useful. ## Solution - Remove the remaining `[tool.mypy] exclude` debt and take the configured gate to full-repo coverage across `polylogue`, `tests`, and `devtools`. - Rewrite protocol-heavy and hydration-heavy modules wholesale where needed instead of patching around symptoms, making runtime field contracts, provider metadata, projection/filter mixins, storage helpers, and large test support files explicit and typed. - Tighten CLI, pipeline, storage, source, product, and verification surfaces so they pass `mypy --strict` and `ruff` without blanket ignores or compatibility shims. - Clean the repo root and devshell entrypoint by sweeping legacy cache leaks in `.envrc` / `flake.nix` and replacing the old MOTD with a more useful project status/help surface backed by tests. ## Verification - `devtools verify` - `mypy polylogue tests devtools`
Finishes the repo-wide mypy-strict cleanup started in #205 by removing the remaining per-file exclusions across `polylogue/`, `tests/`, and `devtools/`. The strict gate was previously green on a subset only; a long tail of excluded source, test, and maintenance files was slowing refactors, hiding real contract problems behind the exclude list, and leaving the repo half-green. Rather than patching around each symptom, the protocol-heavy and hydration-heavy modules get rewritten wholesale where needed so that runtime field contracts, provider metadata, projection/filter mixins, storage helpers, and large test support files become explicit and typed. CLI, pipeline, storage, source, product, and verification surfaces all pass `mypy --strict` and `ruff` without blanket ignores or compatibility shims. Also folds in cleanup work that surfaced during the sweep: disposable cache roots leaking into the top level get swept in `.envrc` / `flake.nix`, and the devshell entry MOTD — no longer useful — is replaced with a project status/help surface backed by tests. Verification: devtools verify green; mypy clean on the full polylogue + tests + devtools tree with no exclude entries.
Finishes the repo-wide mypy-strict cleanup started in #205 by removing the remaining per-file exclusions across `polylogue/`, `tests/`, and `devtools/`. The strict gate was previously green on a subset only; a long tail of excluded source, test, and maintenance files was slowing refactors, hiding real contract problems behind the exclude list, and leaving the repo half-green. Rather than patching around each symptom, the protocol-heavy and hydration-heavy modules get rewritten wholesale where needed so that runtime field contracts, provider metadata, projection/filter mixins, storage helpers, and large test support files become explicit and typed. CLI, pipeline, storage, source, product, and verification surfaces all pass `mypy --strict` and `ruff` without blanket ignores or compatibility shims. Also folds in cleanup work that surfaced during the sweep: disposable cache roots leaking into the top level get swept in `.envrc` / `flake.nix`, and the devshell entry MOTD — no longer useful — is replaced with a project status/help surface backed by tests. Verification: devtools verify green; mypy clean on the full polylogue + tests + devtools tree with no exclude entries.
Finishes the repo-wide mypy-strict cleanup started in #205 by removing the remaining per-file exclusions across `polylogue/`, `tests/`, and `devtools/`. The strict gate was previously green on a subset only; a long tail of excluded source, test, and maintenance files was slowing refactors, hiding real contract problems behind the exclude list, and leaving the repo half-green. Rather than patching around each symptom, the protocol-heavy and hydration-heavy modules get rewritten wholesale where needed so that runtime field contracts, provider metadata, projection/filter mixins, storage helpers, and large test support files become explicit and typed. CLI, pipeline, storage, source, product, and verification surfaces all pass `mypy --strict` and `ruff` without blanket ignores or compatibility shims. Also folds in cleanup work that surfaced during the sweep: disposable cache roots leaking into the top level get swept in `.envrc` / `flake.nix`, and the devshell entry MOTD — no longer useful — is replaced with a project status/help surface backed by tests. Verification: devtools verify green; mypy clean on the full polylogue + tests + devtools tree with no exclude entries.
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Finish the repo-wide mypy cleanup by removing the remaining per-file exclusions and tightening type contracts across
polylogue/,tests/, anddevtools/. The branch also folds in the repo-root cleanup and devshell MOTD improvements that landed during the sweep.Problem
The strict type-checking gate had been restored only for a subset of the repository, with a long tail of excluded source, test, and maintenance files in
pyproject.toml. That debt was slowing down refactors, hiding real contract problems behind the exclude list, and leaving the repo in an awkward half-green state. In parallel, some disposable cache roots had leaked into the top level and the devshell entry messaging had stopped being useful.Solution
[tool.mypy] excludedebt and take the configured gate to full-repo coverage acrosspolylogue,tests, anddevtools.mypy --strictandruffwithout blanket ignores or compatibility shims..envrc/flake.nixand replacing the old MOTD with a more useful project status/help surface backed by tests.Verification
devtools verifymypy polylogue tests devtools