Skip to content

chore: clean 4 mypy-excluded files with shadowing/untyped-self patterns - #206

Merged
Sinity merged 1 commit into
masterfrom
feature/chore/mypy-real-issues
Apr 17, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/chore/mypy-real-issues

Conversation

@Sinity

@Sinity Sinity commented Apr 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

Problem

During the #205 mechanical sweep I skipped four files where straight dict[str, Any] / self: Any sprays either failed or exposed design cruft:

  1. polylogue/lib/filters.py — ConversationFilter.list() shadows the builtin in its own return annotation. async def list(self) -> list[Conversation]: fails because list in that scope resolves to the method, not the builtin.
  2. polylogue/schemas/operator_annotations.py — JSON-schema walkers with untyped dict parameters.
  3. polylogue/schemas/synthetic/build_records.py and build_wire_formats.py — module-level helpers bound to SyntheticCorpus via class-body assignment (_generate_tree_json = _generate_tree_json), with untyped self and dict parameters.

Solution

  • filters.py: reference builtins.list[Conversation] / builtins.list[ConversationSummary] for the three methods that return lists and share the name. Add typed property returns for _since_date, _until_date, _continuation, _sidechain, _has_branches. Localized # type: ignore[no-any-return] on three call-sites that cross into polylogue.lib.query_plan_execution (still in the exclude list — these markers drop naturally when that module is cleaned).
  • operator_annotations.py: adopt dict[str, Any] consistent with sibling polylogue/schemas/audit_walkers.py and audit_checks.py.
  • build_records.py, build_wire_formats.py: adopt self: Any pattern already present in polylogue/schemas/synthetic/runtime.py, plus dict[str, Any] for JSON payloads.

Verification

Commands run:

  • nix develop -c mypy --config-file pyproject.toml polylogue/ — Success: no issues found in 389 source files
  • nix develop -c devtools verify --quick — all checks passed (format, lint, mypy, render-all --check)
  • git push — pre-push hook (devtools verify --quick) passed

Full devtools verify including pytest deferred to CI (local btrfs metadata pressure, unrelated to this change).

🤖 Generated with Claude Code

Annotate four files held out of the mechanical mypy pass in #205 because
straightforward `dict[str, Any]` / `self: Any` sprays surfaced design
friction:

- polylogue/lib/filters.py: ConversationFilter.list() shadows the
  builtin in its own return annotation. Resolved by referencing
  `builtins.list[...]` for the three methods that return lists. The
  three return-type annotations point at Conversation /
  ConversationSummary, deferred-imported under TYPE_CHECKING; calls into
  polylogue.lib.query_plan_execution still land in excluded territory
  and carry localized `# type: ignore[no-any-return]` markers that can
  drop once that module is cleaned.

- polylogue/schemas/operator_annotations.py: JSON-schema walker. Use
  `dict[str, Any]` consistent with audit_walkers.py and audit_checks.py.

- polylogue/schemas/synthetic/build_records.py and build_wire_formats.py:
  module-level functions bound onto SyntheticCorpus via class-body
  assignment. Adopt `self: Any` pattern already used in
  polylogue/schemas/synthetic/runtime.py plus `dict[str, Any]` for
  payloads.

Gate grows from 385 → 389 files checked under mypy --strict.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 17, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 36321798-728b-4b65-a399-902f72230fd3

📥 Commits

Reviewing files that changed from the base of the PR and between c4bcc6d and e0621b1.

📒 Files selected for processing (5)
  • polylogue/lib/filters.py
  • polylogue/schemas/operator_annotations.py
  • polylogue/schemas/synthetic/build_records.py
  • polylogue/schemas/synthetic/build_wire_formats.py
  • pyproject.toml
💤 Files with no reviewable changes (1)
  • pyproject.toml

📝 Walkthrough

Walkthrough

The pull request enhances type safety across the polylogue library by adding explicit type annotations to previously untyped or loosely-typed methods, properties, and function parameters. Four modules receive tighter type hints using standard library types and generics (e.g., dict[str, Any], list[Conversation], datetime | None). The mypy configuration is updated to remove these modules from the strict type-checking exclusion list.

Changes

Cohort / File(s) Summary
Type Annotations for Filter Module
polylogue/lib/filters.py
Added explicit imports (builtins, datetime) and tightened type signatures for ConversationFilter properties (_since_date, _until_date, _continuation, _sidechain, _has_branches) and async public methods (list, list_summaries, first). Return types now explicitly specify generic containers and union types with None.
Type Annotations for Schemas Modules
polylogue/schemas/operator_annotations.py, polylogue/schemas/synthetic/build_records.py, polylogue/schemas/synthetic/build_wire_formats.py
Refined function parameter and return type annotations to use parameterized generics (dict[str, Any], list[dict[str, Any]]). Added self: Any annotations to helper methods in synthetic modules and reformatted function signatures for clarity. No functional or control-flow changes.
Mypy Configuration Update
pyproject.toml
Removed four modules from mypy's strict type-checking exclusion list: polylogue/lib/filters.py, polylogue/schemas/operator_annotations.py, and polylogue/schemas/synthetic/build_records.py and build_wire_formats.py. Enables strict type checking on these now-annotated modules.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Hark! Type hints bloom like clover in the spring,
Explicit generics make the type-checker sing,
No logic shifts, just clarity refined,
Four modules now know just what they'll find,
Mypy's keen eyes shall catch what once was blind! 📋✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: cleaning four mypy-excluded files by addressing shadowing and untyped-self patterns.
Description check ✅ Passed The description covers all required template sections with clear problem statement, detailed solution, and comprehensive verification steps.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/chore/mypy-real-issues

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity merged commit 0cbe050 into master Apr 17, 2026
14 checks passed
@Sinity
Sinity deleted the feature/chore/mypy-real-issues branch April 17, 2026 12:09
Sinity added a commit that referenced this pull request Apr 22, 2026
…ns (#206)

## Summary

- Four files held out of the #205 mechanical tier surfaced non-trivial annotation issues. This PR resolves each and removes them from the mypy `exclude`.
- Gate grows from 385 → 389 files checked under `mypy --strict`.

## Problem

During the #205 mechanical sweep I skipped four files where straight `dict[str, Any]` / `self: Any` sprays either failed or exposed design cruft:

1. `polylogue/lib/filters.py` — `ConversationFilter.list()` shadows the builtin in its own return annotation. `async def list(self) -> list[Conversation]:` fails because `list` in that scope resolves to the method, not the builtin.
2. `polylogue/schemas/operator_annotations.py` — JSON-schema walkers with untyped `dict` parameters.
3. `polylogue/schemas/synthetic/build_records.py` and `build_wire_formats.py` — module-level helpers bound to `SyntheticCorpus` via class-body assignment (`_generate_tree_json = _generate_tree_json`), with untyped `self` and `dict` parameters.

## Solution

- `filters.py`: reference `builtins.list[Conversation]` / `builtins.list[ConversationSummary]` for the three methods that return lists and share the name. Add typed property returns for `_since_date`, `_until_date`, `_continuation`, `_sidechain`, `_has_branches`. Localized `# type: ignore[no-any-return]` on three call-sites that cross into `polylogue.lib.query_plan_execution` (still in the exclude list — these markers drop naturally when that module is cleaned).
- `operator_annotations.py`: adopt `dict[str, Any]` consistent with sibling `polylogue/schemas/audit_walkers.py` and `audit_checks.py`.
- `build_records.py`, `build_wire_formats.py`: adopt `self: Any` pattern already present in `polylogue/schemas/synthetic/runtime.py`, plus `dict[str, Any]` for JSON payloads.

## Verification

Commands run:
- `nix develop -c mypy --config-file pyproject.toml polylogue/` — `Success: no issues found in 389 source files`
- `nix develop -c devtools verify --quick` — all checks passed (format, lint, mypy, render-all --check)
- `git push` — pre-push hook (`devtools verify --quick`) passed

Full `devtools verify` including pytest deferred to CI (local btrfs metadata pressure, unrelated to this change).

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@Sinity Sinity added area:parser Parser tool:claude Claude type:chore Maintenance labels Apr 22, 2026
Sinity added a commit that referenced this pull request Apr 22, 2026
…ns (#206)

Four files held out of the #205 mechanical sweep because straight
`dict[str, Any]` / `self: Any` sprays either failed or exposed
design cruft.

`lib/filters.py`: `ConversationFilter.list()` shadowed the builtin
in its own return annotation (`async def list(self) ->
list[Conversation]` resolves `list` to the method, not the type).
Reference `builtins.list[...]` on the three methods that return
lists and share the name. Add typed property returns for the
`_since_date` / `_until_date` / `_continuation` / `_sidechain` /
`_has_branches` accessors.

`schemas/operator_annotations.py`: adopt `dict[str, Any]` consistent
with sibling `audit_walkers.py` and `audit_checks.py`.

`schemas/synthetic/build_records.py` and `build_wire_formats.py`:
adopt `self: Any` pattern already present in `runtime.py`, plus
`dict[str, Any]` for JSON payloads.

Gate grows from 385 → 389 files. Verification: mypy clean on 389
files; devtools verify --quick green.
Sinity added a commit that referenced this pull request Apr 22, 2026
…ns (#206)

Four files held out of the #205 mechanical sweep because straight
`dict[str, Any]` / `self: Any` sprays either failed or exposed
design cruft.

`lib/filters.py`: `ConversationFilter.list()` shadowed the builtin
in its own return annotation (`async def list(self) ->
list[Conversation]` resolves `list` to the method, not the type).
Reference `builtins.list[...]` on the three methods that return
lists and share the name. Add typed property returns for the
`_since_date` / `_until_date` / `_continuation` / `_sidechain` /
`_has_branches` accessors.

`schemas/operator_annotations.py`: adopt `dict[str, Any]` consistent
with sibling `audit_walkers.py` and `audit_checks.py`.

`schemas/synthetic/build_records.py` and `build_wire_formats.py`:
adopt `self: Any` pattern already present in `runtime.py`, plus
`dict[str, Any]` for JSON payloads.

Gate grows from 385 → 389 files. Verification: mypy clean on 389
files; devtools verify --quick green.
Sinity added a commit that referenced this pull request Apr 22, 2026
…ns (#206)

Four files held out of the #205 mechanical sweep because straight
`dict[str, Any]` / `self: Any` sprays either failed or exposed
design cruft.

`lib/filters.py`: `ConversationFilter.list()` shadowed the builtin
in its own return annotation (`async def list(self) ->
list[Conversation]` resolves `list` to the method, not the type).
Reference `builtins.list[...]` on the three methods that return
lists and share the name. Add typed property returns for the
`_since_date` / `_until_date` / `_continuation` / `_sidechain` /
`_has_branches` accessors.

`schemas/operator_annotations.py`: adopt `dict[str, Any]` consistent
with sibling `audit_walkers.py` and `audit_checks.py`.

`schemas/synthetic/build_records.py` and `build_wire_formats.py`:
adopt `self: Any` pattern already present in `runtime.py`, plus
`dict[str, Any]` for JSON payloads.

Gate grows from 385 → 389 files. Verification: mypy clean on 389
files; devtools verify --quick green.
@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ 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".

@Sinity
Sinity requested a review from Copilot May 1, 2026 01:51
@Sinity
Sinity removed the request for review from Copilot May 1, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant