Skip to content

feat: strengthen typing and remove suppressions#451

Merged
tcoratger merged 1 commit intoleanEthereum:mainfrom
morelucks:feat/typing-cleanup
Mar 11, 2026
Merged

feat: strengthen typing and remove suppressions#451
tcoratger merged 1 commit intoleanEthereum:mainfrom
morelucks:feat/typing-cleanup

Conversation

@morelucks
Copy link
Contributor

This PR is a pure cleanup pass that strengthens typing and removes # type: ignore suppressions across three modules, making the code more Pythonic without introducing any behavioral changes.

Changes made

  1. Discovery Transport:
    • Replaced # type: ignore[assignment] suppressions with explicit assert isinstance(x, asyncio.DatagramTransport) type narrowing guards in transport.py. This ensures it fails fast if an unexpected transport type is received.
  2. Node logging:
    • Removed defensive duck-typing (hasattr checks) in node.py. Checkpoint.root is explicitly typed as Bytes32, which always provides .hex().
  3. Sync Service:
    • Narrowed the _publish_agg_fn callback from Coroutine[Any, Any, None] to Coroutine[None, None, None] in service.py, since these coroutines are never .send()-ed into.
    • Removed the typing.Any import.

Verification

  • uvx tox -e all-checks passes successfully (formatting, linting, MyPy check).
  • uvx tox -e pytest (full suite of 2,672 tests) passes successfully with no regressions.

- Replaced '# type: ignore' suppressions in discovery transport with 'assert isinstance' guards

- Removed hasattr defensive checks in node.py (Checkpoint.root is Bytes32, always provides .hex())

- Narrowed Coroutine[Any, Any, None] to Coroutine[None, None, None] in sync service and removed typing.Any import

- Updated unit test mocks to provide spec matching assertions
@morelucks morelucks marked this pull request as draft March 11, 2026 19:28
@morelucks morelucks marked this pull request as ready for review March 11, 2026 19:28
@tcoratger tcoratger merged commit 65938cf into leanEthereum:main Mar 11, 2026
12 checks passed
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