Skip to content

chore: clean 3 single-error mypy files, add types-PyYAML stubs - #207

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

Sinity merged 1 commit into
masterfrom
feature/chore/mypy-tranche-2

Conversation

@Sinity

@Sinity Sinity commented Apr 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

Three excluded files each carrying a single mypy error — cleaned and promoted into the gate. Gate grows from 389 → 392 files under mypy --strict.

Problem

From running mypy against the full exclude list, 29 files had exactly one reported error. These three resolved without cascade work:

  1. polylogue/cli/commands/check.py:96 — _make_schema_progress_callback() wrapper missing return annotation, but the underlying impl in check_support.py explicitly returns Any.
  2. polylogue/mcp/server.py:63 — extract_fenced_code=lambda text, language="": _extract_fenced_code(text, language). Mypy could not infer the lambda against Callable[[str, str], list[dict[str, str]]] when a default argument was involved.
  3. polylogue/rendering/formatting.py:107 — import yaml raised import-untyped because PyYAML stubs were never declared.

Solution

  • check.py: annotate the wrapper as -> Any to propagate the impl's declared return.
  • server.py: drop the forwarding lambda and pass _extract_fenced_code directly — signatures match exactly.
  • pyproject.toml: add types-PyYAML>=6.0 to the dev extra. Re-lock uv.lock. The source file needed no change.

Verification

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

Full devtools verify (with pytest) deferred to CI.

🤖 Generated with Claude Code

Three files each carrying a single mypy error that the #205 mechanical
pass did not resolve — now cleaned and removed from the exclude list.

- polylogue/cli/commands/check.py: `_make_schema_progress_callback()`
  wrapper missing return annotation. Impl (`check_support.py`) returns
  Any; annotate wrapper as `-> Any` to match.

- polylogue/mcp/server.py: `extract_fenced_code` was wrapped in a lambda
  with a default argument, which mypy could not infer against
  `Callable[[str, str], list[dict[str, str]]]`. The wrapper was pure
  forwarding — pass `_extract_fenced_code` directly.

- polylogue/rendering/formatting.py: `import yaml` triggered
  `import-untyped` because stubs were absent. Add `types-PyYAML>=6.0`
  under the `[project.optional-dependencies] dev` extra and re-lock
  uv.lock. File itself needs no source change.

Gate grows from 389 → 392 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: 3e976492-a5a0-41a4-b6a4-f904a1dc5e7e

📥 Commits

Reviewing files that changed from the base of the PR and between 0cbe050 and 3a3ba11.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (3)
  • polylogue/cli/commands/check.py
  • polylogue/mcp/server.py
  • pyproject.toml

📝 Walkthrough

Walkthrough

Three modules undergo type-checking improvements: check.py receives an explicit return type annotation, server.py replaces a lambda wrapper with a direct function reference, and pyproject.toml adds YAML type stubs while removing mypy strict-type-check exclusions from these modules.

Changes

Cohort / File(s) Summary
Type Annotations & Mypy Strictness
polylogue/cli/commands/check.py, polylogue/mcp/server.py, pyproject.toml
Added explicit -> Any return type to _make_schema_progress_callback in check.py; refactored extract_fenced_code callback from lambda wrapper to direct function reference in server.py; added types-PyYAML>=6.0 dev dependency and removed mypy strict-type-check exclusions from check.py, server.py, and formatting.py to enable stricter type checking.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A lambda bows to function's grace,
Types now shine in every place,
YAML stubs arrive to aid the quest,
Mypy's strictness puts us to the test—
Cleaner code, more type-aware! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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 and specifically summarizes the main changes: cleaning three mypy-excluded files with single errors and adding type stubs for PyYAML.
Description check ✅ Passed The description follows the required template with all sections completed: Summary (1 sentence), Problem (3 specific issues detailed), Solution (3 corresponding fixes), and Verification (exact commands with results).

✏️ 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-tranche-2

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

@Sinity
Sinity merged commit 0e361ac into master Apr 17, 2026
14 checks passed
@Sinity
Sinity deleted the feature/chore/mypy-tranche-2 branch April 17, 2026 12:32
Sinity added a commit that referenced this pull request Apr 22, 2026
## Summary

Three excluded files each carrying a single mypy error — cleaned and promoted into the gate. Gate grows from 389 → 392 files under `mypy --strict`.

## Problem

From running mypy against the full exclude list, 29 files had exactly one reported error. These three resolved without cascade work:

1. `polylogue/cli/commands/check.py:96` — `_make_schema_progress_callback()` wrapper missing return annotation, but the underlying impl in `check_support.py` explicitly returns `Any`.
2. `polylogue/mcp/server.py:63` — `extract_fenced_code=lambda text, language="": _extract_fenced_code(text, language)`. Mypy could not infer the lambda against `Callable[[str, str], list[dict[str, str]]]` when a default argument was involved.
3. `polylogue/rendering/formatting.py:107` — `import yaml` raised `import-untyped` because PyYAML stubs were never declared.

## Solution

- `check.py`: annotate the wrapper as `-> Any` to propagate the impl's declared return.
- `server.py`: drop the forwarding lambda and pass `_extract_fenced_code` directly — signatures match exactly.
- `pyproject.toml`: add `types-PyYAML>=6.0` to the `dev` extra. Re-lock `uv.lock`. The source file needed no change.

## Verification

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

Full `devtools verify` (with pytest) deferred to CI.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sinity added a commit that referenced this pull request Apr 22, 2026
Three excluded files each carrying exactly one mypy error, cleaned
without cascade work.

`cli/commands/check.py`: `_make_schema_progress_callback()` wrapper
missing return annotation; the underlying impl already returns
`Any`. Annotate the wrapper as `-> Any`.

`mcp/server.py`:
`extract_fenced_code=lambda text, language="": _extract_fenced_code(text, language)`
— mypy couldn't infer the lambda against the declared callable type
with a default argument. Drop the forwarding lambda and pass
`_extract_fenced_code` directly; signatures match.

`rendering/formatting.py`: `import yaml` raised `import-untyped`
because PyYAML stubs were never declared. Add `types-PyYAML>=6.0`
to the dev extra; re-lock `uv.lock`. Source file unchanged.

Gate grows from 389 → 392 files. Verification: mypy clean on 392
files; devtools verify --quick green.
Sinity added a commit that referenced this pull request Apr 22, 2026
Three excluded files each carrying exactly one mypy error, cleaned
without cascade work.

`cli/commands/check.py`: `_make_schema_progress_callback()` wrapper
missing return annotation; the underlying impl already returns
`Any`. Annotate the wrapper as `-> Any`.

`mcp/server.py`:
`extract_fenced_code=lambda text, language="": _extract_fenced_code(text, language)`
— mypy couldn't infer the lambda against the declared callable type
with a default argument. Drop the forwarding lambda and pass
`_extract_fenced_code` directly; signatures match.

`rendering/formatting.py`: `import yaml` raised `import-untyped`
because PyYAML stubs were never declared. Add `types-PyYAML>=6.0`
to the dev extra; re-lock `uv.lock`. Source file unchanged.

Gate grows from 389 → 392 files. Verification: mypy clean on 392
files; devtools verify --quick green.
Sinity added a commit that referenced this pull request Apr 22, 2026
Three excluded files each carrying exactly one mypy error, cleaned
without cascade work.

`cli/commands/check.py`: `_make_schema_progress_callback()` wrapper
missing return annotation; the underlying impl already returns
`Any`. Annotate the wrapper as `-> Any`.

`mcp/server.py`:
`extract_fenced_code=lambda text, language="": _extract_fenced_code(text, language)`
— mypy couldn't infer the lambda against the declared callable type
with a default argument. Drop the forwarding lambda and pass
`_extract_fenced_code` directly; signatures match.

`rendering/formatting.py`: `import yaml` raised `import-untyped`
because PyYAML stubs were never declared. Add `types-PyYAML>=6.0`
to the dev extra; re-lock `uv.lock`. Source file unchanged.

Gate grows from 389 → 392 files. Verification: mypy clean on 392
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. Keep them coming!

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