Skip to content

mypy: clear gently/mesh/* type errors (Phase 4 of #49)#59

Open
subindevs wants to merge 1 commit into
gently-project:developmentfrom
subindevs:49-phase4-mypy-mesh
Open

mypy: clear gently/mesh/* type errors (Phase 4 of #49)#59
subindevs wants to merge 1 commit into
gently-project:developmentfrom
subindevs:49-phase4-mypy-mesh

Conversation

@subindevs

Copy link
Copy Markdown
Collaborator

Phase 4 of the incremental mypy effort (#49) — takes the gently/mesh/* cluster (15 errors / 3 modules) to clean and removes its entries from [[tool.mypy.overrides]].

Chose mesh as the first Phase-4 slice because it's the smallest self-contained cluster and low-risk. Deliberately skipped the denser gently/dataset/* cluster since #16 plans to retire that legacy SQLite code.

Changes

File Errors Fix
peer_client.py 13 × union-attr Single root cause: self._session: ClientSession | None used after _ensure_session(). _ensure_session() now returns the non-None session; the 12 call sites use the returned local instead of self._session, so mypy can prove non-None. Behavior unchanged.
discovery.py 1 × override _MeshProtocol.connection_made narrowed the param vs asyncio.BaseProtocol. Widened to BaseTransport (matches supertype) + assert isinstance(..., DatagramTransport) to narrow for the typed attribute.
capability_provider.py 1 × attr-defined ctypes.windll is Windows-only in typeshed; targeted # type: ignore[attr-defined] on the already platform-guarded branch.
pyproject.toml Removed the 3 mesh entries from the mypy override list.

Verification

  • mypy . — no issues in 300 source files (deps-less, as CI runs)
  • ruff check + ruff format --check — clean

Note: mesh unit tests were not run locally (environment lacks the py3.10–3.12 + uv + aiohttp deps). Changes are behavior-preserving by construction.

Part of #49.

🤖 Generated with Claude Code

Type the mesh cluster (15 errors / 3 modules) and drop its entries from the
[[tool.mypy.overrides]] ignore list.

- peer_client.py (13 union-attr): _ensure_session() now returns the non-None
  aiohttp.ClientSession; call sites use the returned local instead of
  self._session, so mypy can prove non-None. Behavior unchanged.
- discovery.py (override): widen _MeshProtocol.connection_made to BaseTransport
  to match asyncio.BaseProtocol, narrowing to DatagramTransport via assert.
- capability_provider.py (attr-defined): targeted ignore for the Windows-only
  ctypes.windll in the platform-guarded branch.

mypy . is clean (300 files, deps-less, as CI runs); ruff check/format pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant